Skip to content
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

Closed
wants to merge 14 commits into from

Conversation

cxzl25
Copy link
Contributor

@cxzl25 cxzl25 commented May 23, 2022

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

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2022

Codecov Report

Merging #2728 (698fbbd) into master (49352b5) will increase coverage by 0.22%.
The diff coverage is 79.20%.

❗ Current head 698fbbd differs from pull request most recent head 8bc40b9. Consider uploading reports for the commit 8bc40b9 to get more accurate results

@@             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     
Impacted Files Coverage Δ
...he/kyuubi/engine/spark/shim/CatalogShim_v2_4.scala 71.64% <0.00%> (-4.55%) ⬇️
...he/kyuubi/engine/spark/shim/SparkCatalogShim.scala 78.26% <ø> (ø)
.../org/apache/kyuubi/config/KyuubiReservedKeys.scala 0.00% <ø> (ø)
.../org/apache/kyuubi/jdbc/hive/KyuubiConnection.java 3.96% <0.00%> (-0.06%) ⬇️
...a/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java 23.96% <0.00%> (-1.30%) ⬇️
...ubi/engine/spark/operation/SetCurrentCatalog.scala 66.66% <66.66%> (ø)
...bi/engine/spark/operation/SetCurrentDatabase.scala 66.66% <66.66%> (ø)
...rg/apache/kyuubi/operation/GetCurrentCatalog.scala 80.00% <80.00%> (ø)
...g/apache/kyuubi/operation/GetCurrentDatabase.scala 80.00% <80.00%> (ø)
...ubi/engine/flink/operation/GetCurrentCatalog.scala 83.33% <83.33%> (ø)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49352b5...8bc40b9. Read the comment docs.

@pan3793
Copy link
Member

pan3793 commented May 24, 2022

Thanks @cxzl25, I verified this patch works w/ DBeaver/Spark
image

@cxzl25
Copy link
Contributor Author

cxzl25 commented May 24, 2022

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.

@cxzl25 cxzl25 marked this pull request as ready for review May 24, 2022 17:15
assert(statement.execute("drop catalog cat_a"))
})
}

test("execute statement - create/alter/drop database") {
// TODO: validate table results after FLINK-25558 is resolved
Copy link
Member

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?

Copy link
Contributor

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.

@@ -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))
Copy link
Member

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?

Copy link
Member

@pan3793 pan3793 May 25, 2022

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

@pan3793
Copy link
Member

pan3793 commented May 25, 2022

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?

@pan3793 pan3793 requested review from turboFei and yaooqinn May 25, 2022 04:36
@cxzl25
Copy link
Contributor Author

cxzl25 commented May 25, 2022

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.
Maybe add an option to the client to keep it compatible?(e.g. useKyuubiCatalogSchemaMethod)


public ResultSet executeGetCurrentCatalog() throws SQLException {
if (!executeWithConfOverlay(
"", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in #2721

Copy link
Contributor Author

@cxzl25 cxzl25 May 25, 2022

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()

Copy link
Member

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?

Copy link
Contributor Author

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' ?

Copy link
Member

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

@github-actions github-actions bot added the kind:documentation Documentation is a feature! label May 25, 2022
cxzl25 added 6 commits May 26, 2022 02:13
# Conflicts:
#	docs/deployment/settings.md
#	kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
@pan3793 pan3793 requested a review from yaooqinn May 26, 2022 08:15
@pan3793
Copy link
Member

pan3793 commented May 26, 2022

Thanks, merging to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement dedicated set/get catalog/database operators
5 participants