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/12/08 11:32:12 UTC

[GitHub] [incubator-kyuubi] Yikf commented on a diff in pull request #3944: [KYUUBI #3926] Introduce antlr4 to parse query statement

Yikf commented on code in PR #3944:
URL: https://github.com/apache/incubator-kyuubi/pull/3944#discussion_r1043252646


##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSqlBaseParser.g4:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+parser grammar KyuubiSqlBaseParser;
+
+options { tokenVocab = KyuubiSqlBaseLexer; }
+
+singleStatement
+    : statement SEMICOLON* EOF
+    ;
+
+statement
+    : runnableCommand                                               #kyuubiRunnable
+    | .*?                                                           #passThrough
+    ;
+
+runnableCommand
+    : SHOW KYUUBI_SESSIONS                                          #showKyuubiSessions

Review Comment:
   Yea, `SHOW TABLES` will not match the `SHOW KYUUBI_SESSIONS` syntax and will be parse to an `PassThroughNode` by the parser, which is a marked node and will not be executed by the server.
   
   We plan to have four types of nodes:
   1. `RunnableCommand`, it can be executed directly on the kyuubi server
   2. `TranslateNode` with Mysql frontend protocol, it will perform sql translation to be compatible with the mysql protocol, like `RENAME TABLE identifier TO identifier` -> `ALTER TABLE identifier RENAME TO identifier`
   3. `TranslateNode` with Trino frontend protocol,  it will perform sql translation to be compatible with the Trino protocol, like `SELECT TABLE_CAT FROM system.jdbc.catalogs` -> `GetCatalogs`
   4. `PassThroughNode`, it will be ignored, just as it was before



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