-
Notifications
You must be signed in to change notification settings - Fork 938
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
[KYUUBI #2721] Implement dedicated set/get catalog/database operators #2728
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2728 +/- ##
============================================
+ Coverage 61.79% 62.02% +0.22%
+ Complexity 385 273 -112
============================================
Files 433 431 -2
Lines 20345 20070 -275
Branches 2760 2728 -32
============================================
- Hits 12572 12448 -124
+ Misses 6541 6424 -117
+ Partials 1232 1198 -34
Continue to review full report at Codecov.
|
Thanks @cxzl25, I verified this patch works w/ DBeaver/Spark |
Thank you for helping me test, I haven't tested it yet, I'll add some UT later. |
assert(statement.execute("drop catalog cat_a")) | ||
}) | ||
} | ||
|
||
test("execute statement - create/alter/drop database") { | ||
// TODO: validate table results after FLINK-25558 is resolved |
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.
@link3280 I see you comment it's fixed by FLINK-24685, should we update it?
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.
Yes, the comment could be deleted now.
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/OperationManager.scala
Outdated
Show resolved
Hide resolved
@@ -452,4 +452,28 @@ trait HiveEngineTests extends HiveJDBCTestHelper { | |||
assert(resultSet.getString(1) === "hive.query.name=test") | |||
} | |||
} | |||
|
|||
test("test set/get catalog") { | |||
assume(SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_1_8)) |
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.
where the restriction comes from?
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.
Emm..., I see, it comes from Hive
Thanks @cxzl25, the change LGTM overall, only one concern, if user use Kyuubi driver to connect HS2/STS and invokes setCatalog/getCatalog setSchema/getSchema, will it break? |
If the connection is not to the kyuubi server, there should be problems in calling these methods. |
...trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentCatalog.scala
Outdated
Show resolved
Hide resolved
...rino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentDatabase.scala
Outdated
Show resolved
Hide resolved
...k-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SetCurrentCatalog.scala
Show resolved
Hide resolved
|
||
public ResultSet executeGetCurrentCatalog() throws SQLException { | ||
if (!executeWithConfOverlay( | ||
"", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) { |
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.
any special reason to use such hacky way? no SQL supported?
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.
Explained in #2721
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.
Because different engines get and set the sql of the catalog database differently.
setCatalog | getCatalog | setSchema | getSchema | |
---|---|---|---|---|
Spark | USE catalog_1.db_1 | SELECT current_catalog() (Since 3.1) | USE db_1 | SELECT current_database() |
Flink | USE CATALOG catalog_1 | SHOW CURRENT CATALOG | USE db_1 | SHOW CURRENT DATABASE |
Trino | USE catalog_1.db_1 | x | USE db_1 | x |
Hive | x | x | USE db_1 | SELECT current_database() |
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.
How about using placeholders for the statement
argement?
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.
For example SELECT 'kyuubi.operation.get.current.catalog'
?
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.
yes, maybe something like _SET_CATALOG_${catalogName} / _GET_CATALOG
Thanks, merging to master |
Why are the changes needed?
close #2721
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 locally before make a pull request