Skip to content

Commit ce7916c

Browse files
yanghuapan3793
authored andcommitted
[KYUUBI #1647] Implement GetTableTypes operation
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> ### _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 #1686 from yanghua/KYUUBI-1647. Closes #1647 c25f5ca [yanghua] retrigger ci 52ae1a8 [yanghua] [KYUUBI #1647] Implement GetTableTypes operation Authored-by: yanghua <yanghua1127@gmail.com> Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent 628719f commit ce7916c

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/FlinkSQLOperationManager.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class FlinkSQLOperationManager extends OperationManager("FlinkSQLOperationManage
5252
tableName: String,
5353
tableTypes: util.List[String]): Operation = null
5454

55-
override def newGetTableTypesOperation(session: Session): Operation = null
55+
override def newGetTableTypesOperation(session: Session): Operation = {
56+
val op = new GetTableTypes(session)
57+
addOperation(op)
58+
}
5659

5760
override def newGetColumnsOperation(
5861
session: Session,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.kyuubi.engine.flink.operation
19+
20+
import scala.collection.JavaConverters.seqAsJavaListConverter
21+
22+
import org.apache.kyuubi.engine.flink.result.{Constants, OperationUtil}
23+
import org.apache.kyuubi.operation.OperationType
24+
import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_TYPE
25+
import org.apache.kyuubi.session.Session
26+
27+
class GetTableTypes(session: Session)
28+
extends FlinkOperation(OperationType.GET_TABLE_TYPES, session) {
29+
30+
override protected def runInternal(): Unit = {
31+
resultSet = OperationUtil.stringListToResultSet(
32+
Constants.SUPPORTED_TABLE_TYPES.toList.asJava,
33+
TABLE_TYPE)
34+
}
35+
}

externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import org.scalatest.concurrent.PatienceConfiguration.Timeout
2121
import org.scalatest.time.SpanSugar._
2222

2323
import org.apache.kyuubi.engine.flink.WithFlinkSQLEngine
24+
import org.apache.kyuubi.engine.flink.result.Constants
2425
import org.apache.kyuubi.operation.HiveJDBCTestHelper
26+
import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_TYPE
2527
import org.apache.kyuubi.service.ServiceState._
2628

2729
class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
@@ -52,6 +54,19 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
5254
}
5355
}
5456

57+
test("get table type for flink sql") {
58+
withJdbcStatement() { statement =>
59+
val meta = statement.getConnection.getMetaData
60+
val types = meta.getTableTypes
61+
val expected = Constants.SUPPORTED_TABLE_TYPES.toIterator
62+
while (types.next()) {
63+
assert(types.getString(TABLE_TYPE) === expected.next())
64+
}
65+
assert(!expected.hasNext)
66+
assert(!types.next())
67+
}
68+
}
69+
5570
test("execute statement - select column name with dots") {
5671
withJdbcStatement() { statement =>
5772
val resultSet = statement.executeQuery("select 'tmp.hello'")

0 commit comments

Comments
 (0)