-
Notifications
You must be signed in to change notification settings - Fork 982
[KYUUBI #5507][FLINK] Support Initialize SQL in Flink Engine #5518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b37d62d
[KYUUBI #5507] [FLINK] Support Initialize SQL in Flink Engine
hadoopkandy b864af5
Merge branch 'apache:master' into KYUUBI-5507
hadoopkandy a29ac38
[KYUUBI-5507] Run engine initial SQL at Engine start
link3280 2ce8031
[KYUUBI-5507] Improve tests
link3280 13035f3
Update externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/ky…
link3280 0782738
[KYUUBI-5507] Improve codestyle
link3280 b1720ec
Update externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/ky…
pan3793 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
.../src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkEngineInitializeSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * 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 java.util.UUID | ||
|
|
||
| import org.apache.kyuubi.config.KyuubiConf._ | ||
| import org.apache.kyuubi.config.KyuubiReservedKeys.KYUUBI_SESSION_USER_KEY | ||
| import org.apache.kyuubi.engine.ShareLevel | ||
| import org.apache.kyuubi.engine.flink.{WithDiscoveryFlinkSQLEngine, WithFlinkSQLEngineLocal} | ||
| import org.apache.kyuubi.ha.HighAvailabilityConf.{HA_ENGINE_REF_ID, HA_NAMESPACE} | ||
| import org.apache.kyuubi.operation.{HiveJDBCTestHelper, NoneMode} | ||
|
|
||
| class FlinkEngineInitializeSuite extends HiveJDBCTestHelper | ||
| with WithDiscoveryFlinkSQLEngine with WithFlinkSQLEngineLocal { | ||
|
|
||
| protected def jdbcUrl: String = getFlinkEngineServiceUrl | ||
|
|
||
| protected val ENGINE_INITIALIZE_SQL_VALUE: String = | ||
| "show databases;" | ||
|
|
||
| protected val ENGINE_SESSION_INITIALIZE_SQL_VALUE: String = | ||
| """create catalog cat_b with ('type'='generic_in_memory'); | ||
| |create table blackhole(i int) with ('connector'='blackhole'); | ||
| |create table datagen(i int) with ( | ||
| |'connector'='datagen', | ||
| |'fields.i.kind'='sequence', | ||
| |'fields.i.start'='1', | ||
| |'fields.i.end'='10')""".stripMargin | ||
|
|
||
| override def withKyuubiConf: Map[String, String] = { | ||
| Map( | ||
| "flink.execution.target" -> "remote", | ||
| "flink.high-availability.cluster-id" -> "flink-mini-cluster", | ||
| "flink.app.name" -> "kyuubi_connection_flink_kandy", | ||
| HA_NAMESPACE.key -> namespace, | ||
| HA_ENGINE_REF_ID.key -> engineRefId, | ||
| ENGINE_TYPE.key -> "FLINK_SQL", | ||
| ENGINE_SHARE_LEVEL.key -> shareLevel, | ||
| OPERATION_PLAN_ONLY_MODE.key -> NoneMode.name, | ||
| ENGINE_INITIALIZE_SQL.key -> ENGINE_INITIALIZE_SQL_VALUE, | ||
| ENGINE_SESSION_INITIALIZE_SQL.key -> ENGINE_SESSION_INITIALIZE_SQL_VALUE, | ||
| KYUUBI_SESSION_USER_KEY -> "kandy") | ||
| } | ||
|
|
||
| override protected def engineRefId: String = UUID.randomUUID().toString | ||
|
|
||
| def namespace: String = "/kyuubi/flink-local-engine-test" | ||
|
|
||
| def shareLevel: String = ShareLevel.USER.toString | ||
|
|
||
| def engineType: String = "flink" | ||
|
|
||
| test("execute statement - kyuubi engine initialize") { | ||
| withJdbcStatement() { statement => | ||
| var resultSet = statement.executeQuery("show catalogs") | ||
| val expectedCatalogs = Set("default_catalog", "cat_b") | ||
| var actualCatalogs = Set[String]() | ||
| while (resultSet.next()) { | ||
| actualCatalogs += resultSet.getString(1) | ||
| } | ||
| assert(expectedCatalogs.subsetOf(actualCatalogs)) | ||
|
|
||
| resultSet = statement.executeQuery("show databases") | ||
| assert(resultSet.next()) | ||
| assert(resultSet.getString(1) === "default_database") | ||
| assert(!resultSet.next()) | ||
|
|
||
| val expectedTables = Set("blackhole", "datagen") | ||
| resultSet = statement.executeQuery("show tables") | ||
| while (resultSet.next()) { | ||
| assert(expectedTables.contains(resultSet.getString(1))) | ||
| } | ||
| assert(!resultSet.next()) | ||
|
|
||
| var dropResult = statement.executeQuery("drop catalog cat_b") | ||
| assert(dropResult.next()) | ||
| assert(dropResult.getString(1) === "OK") | ||
|
|
||
| dropResult = statement.executeQuery("drop table blackhole") | ||
| assert(dropResult.next()) | ||
| assert(dropResult.getString(1) === "OK") | ||
|
|
||
| dropResult = statement.executeQuery("drop table datagen") | ||
| assert(dropResult.next()) | ||
| assert(dropResult.getString(1) === "OK") | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the background of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not relevant. It's probably a cleanup of unused codes.