You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/01/24 08:37:39 UTC

[GitHub] [incubator-kyuubi] link3280 commented on a change in pull request #1822: [KYUUBI #1778] Support Flink Set/Reset Operations

link3280 commented on a change in pull request #1822:
URL: https://github.com/apache/incubator-kyuubi/pull/1822#discussion_r790511904



##########
File path: externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala
##########
@@ -139,6 +146,58 @@ class ExecuteStatement(
     setState(OperationState.FINISHED)
   }
 
+  private def runSetOperation(setOperation: SetOperation): Unit = {
+    if (setOperation.getKey.isPresent) {
+      val key: String = setOperation.getKey.get.trim
+
+      if (setOperation.getValue.isPresent) {
+        val newValue: String = setOperation.getValue.get.trim
+        executor.setSessionProperty(sessionId, key, newValue)
+      }
+
+      val value = executor.getSessionConfigMap(sessionId).getOrDefault(key, "")
+      resultSet = ResultSet.builder
+        .resultKind(ResultKind.SUCCESS_WITH_CONTENT)
+        .columns(Column.physical("set", DataTypes.STRING()))
+        .data(Array(Row.of(PROPERTY_FORMAT.format(key, value))))
+        .build
+    } else {
+      // show all properties if set without key
+      val properties: util.Map[String, String] = executor.getSessionConfigMap(sessionId)
+
+      val entries = ArrayBuffer.empty[Row]
+      properties.forEach((key, value) => entries.append(Row.of(PROPERTY_FORMAT.format(key, value))))
+
+      if (entries.nonEmpty) {
+        val prettyEntries = entries.sortBy(_.getField(0).asInstanceOf[String])
+        resultSet = ResultSet.builder
+          .resultKind(ResultKind.SUCCESS_WITH_CONTENT)
+          .columns(Column.physical("set", DataTypes.STRING()))

Review comment:
       > Is it more convenient to return 2 columns, one for the key and the other for the value?
   
   Yes, I thought about this as well. But I found spark/hive/flink are returning key-value pairs, so I adopt the common format.




-- 
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: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org