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/11/03 10:47:22 UTC
[GitHub] [incubator-kyuubi] Yikf opened a new pull request, #3756: [KYUUBI #] Add the base parser framework for kyuubi server
Yikf opened a new pull request, #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/CONTRIBUTING.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
This pr aims to add the base parser framework to kyuubi server for the following purposes:
- Add syntax that is executable on the server side to enhance capabilities
- Add the ability to translate SQL
### _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] wForget commented on pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
wForget commented on PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#issuecomment-1304974129
I prefer syntax like iceberg spark procedures:
```
CALL func(params)
```
FYI: #1301
--
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 #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1015133376
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+grammar KyuubiSQL;
+
+@members {
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+tokens {
+ DELIMITER
+}
+
+singleStatement
+ : statement ';'* EOF
+ ;
+
+statement
+ : runnable #logicalRunnable
+ | translate #logicalTranslate
+ | .*? #passThrough
+ ;
+
+runnable
+ : KILL ENGINE #killEngine
+ | LAUNCH ENGINE #launchEngine
+ | ALTER SESSION SET propertyList #alterEngineConfig
+ ;
+
+translate
+ : RENAME TABLE identifier TO identifier #renameTable
Review Comment:
we should be careful about extending the syntax, currently, the generic Kyuubi SQL scope is narrowed for resource management. it says, the typical ANSI-like SQL is
```
SHOW <RESOURCES>
CREATE <RESOURCE> ...
ALTER <RESOURCE> SET/UNSET ...
DROP <RESOURCE> ...
```
In Kyuubi case, I think we can start w/ the resource `SESSION` or `ENGINE`.
The "translate" should be protocol-specific, e.g. we only need it for MySQL FE 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] yaooqinn commented on a diff in pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1014964556
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
Review Comment:
can we separate Lexer and Parser?
--
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] [kyuubi] Yikf closed pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
Yikf closed pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
URL: https://github.com/apache/kyuubi/pull/3756
--
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] Yikf commented on a diff in pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
Yikf commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1015410235
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
Review Comment:
Thanks, will separate Lexer and Parser files
--
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] cfmcgrady commented on a diff in pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
cfmcgrady commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1017347581
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+grammar KyuubiSQL;
+
+@members {
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+tokens {
+ DELIMITER
+}
+
+singleStatement
+ : statement ';'* EOF
+ ;
+
+statement
+ : runnable #logicalRunnable
+ | translate #logicalTranslate
+ | .*? #passThrough
+ ;
+
+runnable
+ : KILL ENGINE #killEngine
+ | LAUNCH ENGINE #launchEngine
+ | ALTER SESSION SET propertyList #alterEngineConfig
Review Comment:
then the `ALTER` DDL still works? for instance:
```sql
ALTER TABLE loc_orc SET fileformat orc;
```
--
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] Yikf commented on a diff in pull request #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
Yikf commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1015415841
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+grammar KyuubiSQL;
+
+@members {
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+tokens {
+ DELIMITER
+}
+
+singleStatement
+ : statement ';'* EOF
+ ;
+
+statement
+ : runnable #logicalRunnable
+ | translate #logicalTranslate
+ | .*? #passThrough
+ ;
+
+runnable
+ : KILL ENGINE #killEngine
+ | LAUNCH ENGINE #launchEngine
+ | ALTER SESSION SET propertyList #alterEngineConfig
+ ;
+
+translate
+ : RENAME TABLE identifier TO identifier #renameTable
Review Comment:
Thanks for your thoughts, That's great; and thanks @wForget, prefer this style to that of `CALL func(params)`, what do you think~
@pan3793 I like this style for extending the syntaxm, but and have a bit weird if we use `CREATE ENGINE` for launch engine, `DROP ENGINE` for kill/stop engine.
--
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 #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1015133376
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+grammar KyuubiSQL;
+
+@members {
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+tokens {
+ DELIMITER
+}
+
+singleStatement
+ : statement ';'* EOF
+ ;
+
+statement
+ : runnable #logicalRunnable
+ | translate #logicalTranslate
+ | .*? #passThrough
+ ;
+
+runnable
+ : KILL ENGINE #killEngine
+ | LAUNCH ENGINE #launchEngine
+ | ALTER SESSION SET propertyList #alterEngineConfig
+ ;
+
+translate
+ : RENAME TABLE identifier TO identifier #renameTable
Review Comment:
we should be careful about extending the syntax, currently, the generic Kyuubi SQL scope is narrowed to management. it says, the typical ANSI-like SQL is
```
SHOW <RESOURCES>
CREATE <RESOURCE> ...
ALTER <RESOURCE> SET ...
DROP <RESOURCE> ...
```
In Kyuubi case, I think we can start w/ the resource `SESSION` or `ENGINE`.
The "translate" should be protocol-specific, e.g. we only need it for MySQL FE 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 #3756: [KYUUBI #3764] Introduce the base parser framework for kyuubi server
Posted by GitBox <gi...@apache.org>.
pan3793 commented on code in PR #3756:
URL: https://github.com/apache/incubator-kyuubi/pull/3756#discussion_r1015133376
##########
kyuubi-server/src/main/antlr4/org/apache/kyuubi/sql/KyuubiSQL.g4:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+grammar KyuubiSQL;
+
+@members {
+ /**
+ * Verify whether current token is a valid decimal token (which contains dot).
+ * Returns true if the character that follows the token is not a digit or letter or underscore.
+ *
+ * For example:
+ * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
+ * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
+ * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
+ * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
+ * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
+ * which is not a digit or letter or underscore.
+ */
+ public boolean isValidDecimal() {
+ int nextChar = _input.LA(1);
+ if (nextChar >= 'A' && nextChar <= 'Z' || nextChar >= '0' && nextChar <= '9' ||
+ nextChar == '_') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+tokens {
+ DELIMITER
+}
+
+singleStatement
+ : statement ';'* EOF
+ ;
+
+statement
+ : runnable #logicalRunnable
+ | translate #logicalTranslate
+ | .*? #passThrough
+ ;
+
+runnable
+ : KILL ENGINE #killEngine
+ | LAUNCH ENGINE #launchEngine
+ | ALTER SESSION SET propertyList #alterEngineConfig
+ ;
+
+translate
+ : RENAME TABLE identifier TO identifier #renameTable
Review Comment:
we should be careful about extending the syntax, currently, the generic Kyuubi SQL scope is narrowed for resource management. it says, the typical ANSI-like SQL is
```
SHOW <RESOURCES>
CREATE <RESOURCE> ...
ALTER <RESOURCE> SET ...
DROP <RESOURCE> ...
```
In Kyuubi case, I think we can start w/ the resource `SESSION` or `ENGINE`.
The "translate" should be protocol-specific, e.g. we only need it for MySQL FE 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