From 58dd4ca71fcf40adfec59beeea3a7f1c5e5d3a33 Mon Sep 17 00:00:00 2001 From: yanghua Date: Mon, 10 Jan 2022 16:18:22 +0800 Subject: [PATCH] [KYUUBI #1647] Change GetCatalog returned schema key name to support JDBC specification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … ### _Why are the changes needed?_ ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1688 from yanghua/KYUUBI-1687. Closes #1647 d6fda463 [yanghua] [KYUUBI #1647] Change GetCatalog returned schema key name to support JDBC specification Authored-by: yanghua Signed-off-by: Cheng Pan --- .../org/apache/kyuubi/engine/flink/result/Constants.java | 2 -- .../apache/kyuubi/engine/flink/operation/GetCatalogs.scala | 5 +++-- .../kyuubi/engine/flink/operation/FlinkOperationSuite.scala | 3 ++- .../apache/kyuubi/operation/flink/FlinkOperationSuite.scala | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/externals/kyuubi-flink-sql-engine/src/main/java/org/apache/kyuubi/engine/flink/result/Constants.java b/externals/kyuubi-flink-sql-engine/src/main/java/org/apache/kyuubi/engine/flink/result/Constants.java index 617b9f0e42b..9151ed86494 100644 --- a/externals/kyuubi-flink-sql-engine/src/main/java/org/apache/kyuubi/engine/flink/result/Constants.java +++ b/externals/kyuubi-flink-sql-engine/src/main/java/org/apache/kyuubi/engine/flink/result/Constants.java @@ -32,8 +32,6 @@ public class Constants { public static final String SHOW_CURRENT_CATALOG_RESULT = "catalog"; - public static final String SHOW_CATALOGS_RESULT = "catalogs"; - public static final String SHOW_CURRENT_DATABASE_RESULT = "database"; public static final String SHOW_DATABASES_RESULT = "databases"; diff --git a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetCatalogs.scala b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetCatalogs.scala index 3a7a974401e..b01a45a3b8e 100644 --- a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetCatalogs.scala +++ b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetCatalogs.scala @@ -19,8 +19,9 @@ package org.apache.kyuubi.engine.flink.operation import scala.collection.JavaConverters._ -import org.apache.kyuubi.engine.flink.result.{Constants, OperationUtil} +import org.apache.kyuubi.engine.flink.result.OperationUtil import org.apache.kyuubi.operation.OperationType +import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_CAT import org.apache.kyuubi.session.Session class GetCatalogs(session: Session) @@ -33,7 +34,7 @@ class GetCatalogs(session: Session) tableEnv.listCatalogs.toList.asJava resultSet = OperationUtil.stringListToResultSet( catalogs, - Constants.SHOW_CATALOGS_RESULT) + TABLE_CAT) } catch onError() } diff --git a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala index 7174b87e2be..20a8f61a02d 100644 --- a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala +++ b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala @@ -23,6 +23,7 @@ import org.scalatest.time.SpanSugar._ import org.apache.kyuubi.engine.flink.WithFlinkSQLEngine import org.apache.kyuubi.engine.flink.result.Constants import org.apache.kyuubi.operation.HiveJDBCTestHelper +import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_CAT import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_TYPE import org.apache.kyuubi.service.ServiceState._ @@ -47,7 +48,7 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper { val catalogs = meta.getCatalogs val expected = Set("default_catalog").toIterator while (catalogs.next()) { - assert(catalogs.getString("catalogs") === expected.next()) + assert(catalogs.getString(TABLE_CAT) === expected.next()) } assert(!expected.hasNext) assert(!catalogs.next()) diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala index 06202db7094..8915c19786d 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala @@ -21,6 +21,7 @@ import org.apache.kyuubi.WithKyuubiServerAndFlinkLocalCluster import org.apache.kyuubi.config.KyuubiConf import org.apache.kyuubi.config.KyuubiConf.{ENGINE_TYPE, FRONTEND_THRIFT_BINARY_BIND_PORT} import org.apache.kyuubi.operation.HiveJDBCTestHelper +import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_CAT class FlinkOperationSuite extends WithKyuubiServerAndFlinkLocalCluster with HiveJDBCTestHelper { override val conf: KyuubiConf = KyuubiConf() @@ -35,7 +36,7 @@ class FlinkOperationSuite extends WithKyuubiServerAndFlinkLocalCluster with Hive val catalogs = meta.getCatalogs val expected = Set("default_catalog").toIterator while (catalogs.next()) { - assert(catalogs.getString("catalogs") === expected.next()) + assert(catalogs.getString(TABLE_CAT) === expected.next()) } assert(!expected.hasNext) assert(!catalogs.next())