You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/05/23 21:15:04 UTC
[GitHub] [incubator-kyuubi] cxzl25 opened a new pull request, #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
cxzl25 opened a new pull request, #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728
### _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](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] cxzl25 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
cxzl25 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881241674
##########
externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentCatalog.scala:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.trino.operation
+
+import com.google.common.collect.ImmutableList
+import io.trino.client.{ClientSession, ClientTypeSignature, ClientTypeSignatureParameter, Column}
+import io.trino.client.ClientStandardTypes.VARCHAR
+import io.trino.client.ClientTypeSignature.VARCHAR_UNBOUNDED_LENGTH
+
+import org.apache.kyuubi.operation.{IterableFetchIterator, OperationType}
+import org.apache.kyuubi.session.Session
+
+class SetCurrentCatalog(session: Session, catalog: String)
+ extends TrinoOperation(OperationType.EXECUTE_STATEMENT, session) {
+
+ override protected def runInternal(): Unit = {
+ try {
+ val session = trinoContext.clientSession.get
+ var builder = ClientSession.builder(session)
+ builder = builder.withCatalog(catalog)
+ trinoContext.clientSession.set(builder.build())
+
+ val clientTypeSignature = new ClientTypeSignature(
+ VARCHAR,
+ ImmutableList.of(ClientTypeSignatureParameter.ofLong(VARCHAR_UNBOUNDED_LENGTH)))
+ val column = new Column("TABLE_CAT", VARCHAR, clientTypeSignature)
Review Comment:
How about setting schema "output" in set catalog/db schema? Or set to no resultset, similar to Hive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881243957
##########
externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentCatalog.scala:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.trino.operation
+
+import com.google.common.collect.ImmutableList
+import io.trino.client.{ClientSession, ClientTypeSignature, ClientTypeSignatureParameter, Column}
+import io.trino.client.ClientStandardTypes.VARCHAR
+import io.trino.client.ClientTypeSignature.VARCHAR_UNBOUNDED_LENGTH
+
+import org.apache.kyuubi.operation.{IterableFetchIterator, OperationType}
+import org.apache.kyuubi.session.Session
+
+class SetCurrentCatalog(session: Session, catalog: String)
+ extends TrinoOperation(OperationType.EXECUTE_STATEMENT, session) {
+
+ override protected def runInternal(): Unit = {
+ try {
+ val session = trinoContext.clientSession.get
+ var builder = ClientSession.builder(session)
+ builder = builder.withCatalog(catalog)
+ trinoContext.clientSession.set(builder.build())
+
+ val clientTypeSignature = new ClientTypeSignature(
+ VARCHAR,
+ ImmutableList.of(ClientTypeSignatureParameter.ofLong(VARCHAR_UNBOUNDED_LENGTH)))
+ val column = new Column("TABLE_CAT", VARCHAR, clientTypeSignature)
Review Comment:
better empty
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1135194013
# [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#2728](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (21e5787) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/5b9d92e96cad7e0a91b13328c46225f3dd7adcbb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5b9d92e) will **decrease** coverage by `0.77%`.
> The diff coverage is `2.40%`.
```diff
@@ Coverage Diff @@
## master #2728 +/- ##
============================================
- Coverage 62.02% 61.24% -0.78%
Complexity 238 238
============================================
Files 407 427 +20
Lines 19626 19870 +244
Branches 2635 2662 +27
============================================
- Hits 12173 12170 -3
- Misses 6290 6527 +237
- Partials 1163 1173 +10
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ubi/engine/flink/operation/GetCurrentCatalog.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1mbGluay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9mbGluay9vcGVyYXRpb24vR2V0Q3VycmVudENhdGFsb2cuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
| [...bi/engine/flink/operation/GetCurrentDatabase.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1mbGluay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9mbGluay9vcGVyYXRpb24vR2V0Q3VycmVudERhdGFiYXNlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
| [...ubi/engine/flink/operation/SetCurrentCatalog.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1mbGluay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9mbGluay9vcGVyYXRpb24vU2V0Q3VycmVudENhdGFsb2cuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
| [...bi/engine/flink/operation/SetCurrentDatabase.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1mbGluay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9mbGluay9vcGVyYXRpb24vU2V0Q3VycmVudERhdGFiYXNlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
| [...uubi/engine/hive/operation/GetCurrentCatalog.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1oaXZlLXNxbC1lbmdpbmUvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvZW5naW5lL2hpdmUvb3BlcmF0aW9uL0dldEN1cnJlbnRDYXRhbG9nLnNjYWxh) | `0.00% <0.00%> (ø)` | |
| [...ubi/engine/hive/operation/GetCurrentDatabase.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1oaXZlLXNxbC1lbmdpbmUvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvZW5naW5lL2hpdmUvb3BlcmF0aW9uL0dldEN1cnJlbnREYXRhYmFzZS5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
| [...uubi/engine/hive/operation/SetCurrentCatalog.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1oaXZlLXNxbC1lbmdpbmUvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvZW5naW5lL2hpdmUvb3BlcmF0aW9uL1NldEN1cnJlbnRDYXRhbG9nLnNjYWxh) | `0.00% <0.00%> (ø)` | |
| [...ubi/engine/hive/operation/SetCurrentDatabase.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1oaXZlLXNxbC1lbmdpbmUvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvZW5naW5lL2hpdmUvb3BlcmF0aW9uL1NldEN1cnJlbnREYXRhYmFzZS5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
| [...ubi/engine/spark/operation/GetCurrentCatalog.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9vcGVyYXRpb24vR2V0Q3VycmVudENhdGFsb2cuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
| [...bi/engine/spark/operation/GetCurrentDatabase.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9vcGVyYXRpb24vR2V0Q3VycmVudERhdGFiYXNlLnNjYWxh) | `0.00% <0.00%> (ø)` | |
| ... and [28 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [5b9d92e...21e5787](https://codecov.io/gh/apache/incubator-kyuubi/pull/2728?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1135367971
Thanks @cxzl25, I verified this patch works w/ DBeaver/Spark
<img width="998" alt="image" src="https://user-images.githubusercontent.com/26535726/169944192-52317ba7-8c5d-483b-8910-7966aa49da3d.png">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881238272
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
Explained in https://github.com/apache/incubator-kyuubi/issues/2721
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881205489
##########
kyuubi-common/src/test/scala/org/apache/kyuubi/HiveEngineTests.scala:
##########
@@ -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))
Review Comment:
Emm..., I see, it comes from Hive
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1138370627
Thanks, merging to master
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881232723
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SetCurrentCatalog.scala:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.spark.operation
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.types.StructType
+
+import org.apache.kyuubi.engine.spark.shim.SparkCatalogShim
+import org.apache.kyuubi.operation.{IterableFetchIterator, OperationType}
+import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_CAT
+import org.apache.kyuubi.session.Session
+
+class SetCurrentCatalog(session: Session, catalog: String)
+ extends SparkOperation(OperationType.EXECUTE_STATEMENT, session) {
+
+ override protected def resultSchema: StructType = {
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881241348
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
How about using placeholders for the `statement` argement?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881205175
##########
kyuubi-common/src/test/scala/org/apache/kyuubi/HiveEngineTests.scala:
##########
@@ -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))
Review Comment:
where the restriction comes from?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] cxzl25 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
cxzl25 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881238505
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
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() |
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
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() |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881230074
##########
externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentCatalog.scala:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.trino.operation
+
+import com.google.common.collect.ImmutableList
+import io.trino.client.{ClientSession, ClientTypeSignature, ClientTypeSignatureParameter, Column}
+import io.trino.client.ClientStandardTypes.VARCHAR
+import io.trino.client.ClientTypeSignature.VARCHAR_UNBOUNDED_LENGTH
+
+import org.apache.kyuubi.operation.{IterableFetchIterator, OperationType}
+import org.apache.kyuubi.session.Session
+
+class SetCurrentCatalog(session: Session, catalog: String)
+ extends TrinoOperation(OperationType.EXECUTE_STATEMENT, session) {
+
+ override protected def runInternal(): Unit = {
+ try {
+ val session = trinoContext.clientSession.get
+ var builder = ClientSession.builder(session)
+ builder = builder.withCatalog(catalog)
+ trinoContext.clientSession.set(builder.build())
+
+ val clientTypeSignature = new ClientTypeSignature(
+ VARCHAR,
+ ImmutableList.of(ClientTypeSignatureParameter.ofLong(VARCHAR_UNBOUNDED_LENGTH)))
+ val column = new Column("TABLE_CAT", VARCHAR, clientTypeSignature)
Review Comment:
this is incorrect, the result schema is not TABLE_CAT
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] cxzl25 commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
cxzl25 commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1135397476
> 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881233558
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
any special reason to use such hacky way? no SQL supported?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881300926
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
yes, maybe something like `_SET_CATALOG_${catalogName} / _GET_CATALOG`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881191006
##########
externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala:
##########
@@ -665,6 +665,18 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
})
}
+ test("execute statement - set/get catalog") {
+ withJdbcStatement()({ statement =>
+ statement.executeQuery("create catalog cat_a with ('type'='generic_in_memory')")
+ val catalog = statement.getConnection.getCatalog
+ assert(catalog == "default_catalog")
+ statement.getConnection.setCatalog("cat_a")
+ val changedCatalog = statement.getConnection.getCatalog
+ assert(changedCatalog == "cat_a")
+ assert(statement.execute("drop catalog cat_a"))
+ })
+ }
+
test("execute statement - create/alter/drop database") {
// TODO: validate table results after FLINK-25558 is resolved
Review Comment:
@link3280 I see you comment it's fixed by FLINK-24685, should we update it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] link3280 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
link3280 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881193470
##########
externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala:
##########
@@ -665,6 +665,18 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
})
}
+ test("execute statement - set/get catalog") {
+ withJdbcStatement()({ statement =>
+ statement.executeQuery("create catalog cat_a with ('type'='generic_in_memory')")
+ val catalog = statement.getConnection.getCatalog
+ assert(catalog == "default_catalog")
+ statement.getConnection.setCatalog("cat_a")
+ val changedCatalog = statement.getConnection.getCatalog
+ assert(changedCatalog == "cat_a")
+ assert(statement.execute("drop catalog cat_a"))
+ })
+ }
+
test("execute statement - create/alter/drop database") {
// TODO: validate table results after FLINK-25558 is resolved
Review Comment:
Yes, the comment could be deleted now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881205489
##########
kyuubi-common/src/test/scala/org/apache/kyuubi/HiveEngineTests.scala:
##########
@@ -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))
Review Comment:
Emm..., I see, it's comes from Hive
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] cxzl25 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
cxzl25 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881244468
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiStatement.java:
##########
@@ -512,6 +512,36 @@ public ResultSet executeScala(String code) throws SQLException {
return resultSet;
}
+ public void executeSetCurrentCatalog(String catalog) throws SQLException {
+ if (executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.set.current.catalog", catalog))) {
+ resultSet.close();
+ }
+ }
+
+ public ResultSet executeGetCurrentCatalog() throws SQLException {
+ if (!executeWithConfOverlay(
+ "", Collections.singletonMap("kyuubi.operation.get.current.catalog", ""))) {
Review Comment:
For example `SELECT 'kyuubi.operation.get.current.catalog'` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881204723
##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/OperationManager.scala:
##########
@@ -21,6 +21,7 @@ import org.apache.hive.service.rpc.thrift._
import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiReservedKeys.{KYUUBI_OPERATION_GET_CURRENT_CATALOG, KYUUBI_OPERATION_GET_CURRENT_DATABASE, KYUUBI_OPERATION_SET_CURRENT_CATALOG, KYUUBI_OPERATION_SET_CURRENT_DATABASE}
Review Comment:
import org.apache.kyuubi.config.KyuubiReservedKeys._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1136716293
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] pan3793 closed pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
pan3793 closed pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
URL: https://github.com/apache/incubator-kyuubi/pull/2728
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] cxzl25 commented on pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
cxzl25 commented on PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#issuecomment-1136720366
> 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.
Maybe add an option to the client to keep it compatible?(e.g. `useKyuubiSetCatalogDatabase`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2728: [KYUUBI #2721] Implement dedicated set/get catalog/database operators
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2728:
URL: https://github.com/apache/incubator-kyuubi/pull/2728#discussion_r881230191
##########
externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/operation/SetCurrentDatabase.scala:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.trino.operation
+
+import com.google.common.collect.ImmutableList
+import io.trino.client.{ClientSession, ClientTypeSignature, ClientTypeSignatureParameter, Column}
+import io.trino.client.ClientStandardTypes.VARCHAR
+import io.trino.client.ClientTypeSignature.VARCHAR_UNBOUNDED_LENGTH
+
+import org.apache.kyuubi.operation.{IterableFetchIterator, OperationType}
+import org.apache.kyuubi.session.Session
+
+class SetCurrentDatabase(session: Session, database: String)
+ extends TrinoOperation(OperationType.EXECUTE_STATEMENT, session) {
+
+ override protected def runInternal(): Unit = {
+ try {
+ val session = trinoContext.clientSession.get
+ var builder = ClientSession.builder(session)
+ builder = builder.withSchema(database)
+ trinoContext.clientSession.set(builder.build())
+
+ val clientTypeSignature = new ClientTypeSignature(
+ VARCHAR,
+ ImmutableList.of(ClientTypeSignatureParameter.ofLong(VARCHAR_UNBOUNDED_LENGTH)))
+ val column = new Column("TABLE_SCHEM", VARCHAR, clientTypeSignature)
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org