diff --git a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/FlinkSQLOperationManager.scala b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/FlinkSQLOperationManager.scala index 390817ad2..952d8e786 100644 --- a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/FlinkSQLOperationManager.scala +++ b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/FlinkSQLOperationManager.scala @@ -52,7 +52,10 @@ class FlinkSQLOperationManager extends OperationManager("FlinkSQLOperationManage tableName: String, tableTypes: util.List[String]): Operation = null - override def newGetTableTypesOperation(session: Session): Operation = null + override def newGetTableTypesOperation(session: Session): Operation = { + val op = new GetTableTypes(session) + addOperation(op) + } override def newGetColumnsOperation( session: Session, diff --git a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetTableTypes.scala b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetTableTypes.scala new file mode 100644 index 000000000..3564a6292 --- /dev/null +++ b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/GetTableTypes.scala @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.engine.flink.operation + +import scala.collection.JavaConverters.seqAsJavaListConverter + +import org.apache.kyuubi.engine.flink.result.{Constants, OperationUtil} +import org.apache.kyuubi.operation.OperationType +import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_TYPE +import org.apache.kyuubi.session.Session + +class GetTableTypes(session: Session) + extends FlinkOperation(OperationType.GET_TABLE_TYPES, session) { + + override protected def runInternal(): Unit = { + resultSet = OperationUtil.stringListToResultSet( + Constants.SUPPORTED_TABLE_TYPES.toList.asJava, + TABLE_TYPE) + } +} 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 3d0cce438..69f816324 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 @@ -21,7 +21,9 @@ import org.scalatest.concurrent.PatienceConfiguration.Timeout 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_TYPE import org.apache.kyuubi.service.ServiceState._ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper { @@ -52,6 +54,19 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper { } } + test("get table type for flink sql") { + withJdbcStatement() { statement => + val meta = statement.getConnection.getMetaData + val types = meta.getTableTypes + val expected = Constants.SUPPORTED_TABLE_TYPES.toIterator + while (types.next()) { + assert(types.getString(TABLE_TYPE) === expected.next()) + } + assert(!expected.hasNext) + assert(!types.next()) + } + } + test("execute statement - select column name with dots") { withJdbcStatement() { statement => val resultSet = statement.executeQuery("select 'tmp.hello'")