gianm commented on code in PR #5349:
URL: https://github.com/apache/calcite/pull/5349#discussion_r4406887653


##########
site/_docs/reference.md:
##########
@@ -490,6 +495,23 @@ becomes a grouping key; for example,
 but is not standard SQL and is only allowed in certain
 [conformance levels]({{ site.apiRoot 
}}/org/apache/calcite/sql/validate/SqlConformance.html#isFromRequired--).
 
+*pipeOperator* and a standalone `FROM` are only allowed in certain

Review Comment:
   Yes. The main two are 
https://github.com/google/googlesql/blob/master/docs/pipe-syntax.md and the 
paper 
https://research.google/pubs/sql-has-problems-we-can-fix-them-pipe-syntax-in-sql/.
 I linked to the first one, since it is more geared towards end users, and it 
links to the paper.



##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -4929,6 +4929,245 @@ void checkPeriodPredicate(Checker checker) {
         .fails("(?s)Encountered \"select\".*");
   }
 
+  @Test void testFromQuery() {

Review Comment:
   Added.



##########
testkit/src/main/java/org/apache/calcite/sql/parser/SqlParserTest.java:
##########
@@ -4929,6 +4929,245 @@ void checkPeriodPredicate(Checker checker) {
         .fails("(?s)Encountered \"select\".*");
   }
 
+  @Test void testFromQuery() {
+    final SqlConformanceEnum lenient = SqlConformanceEnum.LENIENT;
+    sql("from emp")
+        .withConformance(lenient)
+        .ok("FROM `EMP`");
+    sql("from emp join dept using (deptno)")
+        .withConformance(lenient)
+        .ok("FROM `EMP`\n"
+            + "INNER JOIN `DEPT` USING (`DEPTNO`)");
+    sql("from (from emp)")
+        .withConformance(lenient)
+        .ok("FROM (FROM `EMP`)");
+  }
+
+  @Test void testFromQueryOrderedAndSetOp() {
+    final SqlConformanceEnum lenient = SqlConformanceEnum.LENIENT;
+    sql("(from emp) order by empno")
+        .withConformance(lenient)
+        .ok("(FROM `EMP`)\n"
+            + "ORDER BY `EMPNO`");
+    sql("(from emp) union all (from dept)")
+        .withConformance(lenient)
+        .ok("(FROM `EMP`)\n"
+            + "UNION ALL\n"
+            + "(FROM `DEPT`)");
+    // A FROM query must be in parentheses to be an operand of a
+    // set operator.
+    final String error = "A FROM query must be in parentheses to be an"
+        + " operand of UNION, INTERSECT or EXCEPT";
+    sql("from emp ^union^ all (from dept)")
+        .withConformance(lenient)
+        .fails(error);
+    sql("select * from emp except ^from^ dept")
+        .withConformance(lenient)
+        .fails(error);
+  }
+
+  @Test void testFromQueryConformance() {
+    final String error =
+        "Pipe syntax is not allowed under the current SQL conformance level";
+    final SqlConformanceEnum conformance = SqlConformanceEnum.DEFAULT;
+    sql("^from^ emp")
+        .withConformance(conformance)

Review Comment:
   These aren't because they're just setting DEFAULT. Removed them.



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

Reply via email to