You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/11/28 12:13:56 UTC

[GitHub] [calcite] strongduanmu opened a new pull request, #2985: [CALCITE-5393] Support MySQL VALUE operator parse

strongduanmu opened a new pull request, #2985:
URL: https://github.com/apache/calcite/pull/2985

   * add `VALUE` kerword to Paser.jj for `INSERT INTO ... VALUE ...` statement
   * add unit test for `INSERT INTO ... VALUE ...` statement


-- 
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@calcite.apache.org

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


[GitHub] [calcite] strongduanmu commented on a diff in pull request #2985: [CALCITE-5393] Support MySQL VALUE operator parse

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #2985:
URL: https://github.com/apache/calcite/pull/2985#discussion_r1040253872


##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -4585,6 +4585,23 @@ void checkPeriodPredicate(Checker checker) {
         .ok(expected);
   }
 
+  /** Tests VALUE, which is equivalent to VALUES but only supported in some
+   * conformance levels (e.g. MYSQL). */
+  @Test void testInsertValue() {
+    final String pattern =
+        "VALUE is not allowed under the current SQL conformance level";
+    final String sql = "insert into emps ^value^ (1, 'Fredkin')";
+    sql(sql)
+        .fails(pattern);
+
+    final String expected = "INSERT INTO `EMPS`\n"
+        + "VALUES (ROW(1, 'Fredkin'))";
+    sql(sql)
+        .withConformance(SqlConformanceEnum.MYSQL_5)
+        .ok(expected)
+        .node(not(isDdl()));
+  }
+

Review Comment:
   Good suggestion, I will merge testInsertValue into testInsertValues and add unit test for VALUE as a top-level query.



-- 
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@calcite.apache.org

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


[GitHub] [calcite] strongduanmu commented on a diff in pull request #2985: [CALCITE-5393] Support MySQL VALUE operator parse

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #2985:
URL: https://github.com/apache/calcite/pull/2985#discussion_r1040250599


##########
core/src/main/java/org/apache/calcite/runtime/CalciteResource.java:
##########
@@ -995,4 +995,6 @@ ExInstWithCause<CalciteException> failedToAccessField(
   @BaseMessage("A table function at most has one input table with row semantics. Table function ''{0}'' has multiple input tables with row semantics")
   ExInst<SqlValidatorException> multipleRowSemanticsTables(String funcName);
 
+  @BaseMessage("VALUE is not allowed under the current SQL conformance level")
+  ExInst<CalciteException> valueNotAllowed();

Review Comment:
   Thank you, I will move it to the best place.



-- 
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@calcite.apache.org

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


[GitHub] [calcite] julianhyde commented on a diff in pull request #2985: [CALCITE-5393] Support MySQL VALUE operator parse

Posted by GitBox <gi...@apache.org>.
julianhyde commented on code in PR #2985:
URL: https://github.com/apache/calcite/pull/2985#discussion_r1038925433


##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -4585,6 +4585,23 @@ void checkPeriodPredicate(Checker checker) {
         .ok(expected);
   }
 
+  /** Tests VALUE, which is equivalent to VALUES but only supported in some
+   * conformance levels (e.g. MYSQL). */
+  @Test void testInsertValue() {
+    final String pattern =
+        "VALUE is not allowed under the current SQL conformance level";
+    final String sql = "insert into emps ^value^ (1, 'Fredkin')";
+    sql(sql)
+        .fails(pattern);
+
+    final String expected = "INSERT INTO `EMPS`\n"
+        + "VALUES (ROW(1, 'Fredkin'))";
+    sql(sql)
+        .withConformance(SqlConformanceEnum.MYSQL_5)
+        .ok(expected)
+        .node(not(isDdl()));
+  }
+

Review Comment:
   I think I would merge this test into `testInsertValues`, since the expected AST is the same.
   
   Can you also test VALUE as a top-level query, not just in INSERT. Maybe modify `testValues`.



##########
core/src/main/java/org/apache/calcite/runtime/CalciteResource.java:
##########
@@ -995,4 +995,6 @@ ExInstWithCause<CalciteException> failedToAccessField(
   @BaseMessage("A table function at most has one input table with row semantics. Table function ''{0}'' has multiple input tables with row semantics")
   ExInst<SqlValidatorException> multipleRowSemanticsTables(String funcName);
 
+  @BaseMessage("VALUE is not allowed under the current SQL conformance level")
+  ExInst<CalciteException> valueNotAllowed();

Review Comment:
   Why do you put it last? If everyone puts things last, we get conflicts. Put it in the best place.



-- 
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@calcite.apache.org

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


[GitHub] [calcite] julianhyde closed pull request #2985: [CALCITE-5393] Support MySQL VALUE operator parse

Posted by GitBox <gi...@apache.org>.
julianhyde closed pull request #2985: [CALCITE-5393] Support MySQL VALUE operator parse
URL: https://github.com/apache/calcite/pull/2985


-- 
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@calcite.apache.org

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