YesOrNo828 commented on code in PR #5585:
URL: https://github.com/apache/kyuubi/pull/5585#discussion_r1378267410


##########
externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala:
##########
@@ -59,16 +66,49 @@ class ExecuteStatement(
   private def executeStatement(): Unit = {
     try {
       setState(OperationState.RUNNING)
+
+      val operation = parseExtendedStatement(statement)
+      if (operation.isPresent && operation.get().isInstanceOf[HelpOperation]) {
+        resultSet = ResultSetUtil.helpMessageResultSet
+        setState(OperationState.FINISHED)
+        return
+      }
+
       val resultFetcher = executor.executeStatement(
         new OperationHandle(getHandle.identifier),
         statement)
       jobId = FlinkEngineUtils.getResultJobId(resultFetcher)
-      resultSet = ResultSetUtil.fromResultFetcher(resultFetcher, 
resultMaxRows, resultFetchTimeout)
+      resultSet = ResultSetUtil
+        .fromResultFetcher(resultFetcher, resultMaxRows, resultFetchTimeout)
       setState(OperationState.FINISHED)
     } catch {
       onError(cancel = true)
     } finally {
       shutdownTimeoutMonitor()
     }
   }
+
+  private def parseExtendedStatement(statement: String): Optional[Operation] = 
{
+    val plannerModuleClassLoader: ClassLoader = getPlannerModuleClassLoader
+    val extendedParser: AnyRef =
+      DynConstructors.builder()
+        .loader(plannerModuleClassLoader)
+        .impl("org.apache.flink.table.planner.parse.ExtendedParser")
+        .build().newInstance()
+    invokeAs(extendedParser, "parse", (classOf[String], statement))
+      .asInstanceOf[Optional[Operation]]
+  }
+
+  private def getPlannerModuleClassLoader: ClassLoader = {
+    try {
+      val plannerModule =
+        invokeAs("org.apache.flink.table.planner.loader.PlannerModule", 
"getInstance")

Review Comment:
   `PlannerModule` is package-private, we can't invoke it directly here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to