NobiGo commented on code in PR #4192:
URL: https://github.com/apache/calcite/pull/4192#discussion_r1953708125


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -8225,6 +8225,27 @@ private void checkLiteral2(String expression, String 
expected) {
         .withOracle(11).ok(expectedVersionLow);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6819";>[CALCITE-6819]
+   * MSSQL doesn't support TRUE/FALSE keywords in its Join predicate</a>. */
+  @Test void testJoinBoolLiteralMSSQL() {
+    final String queryTrue = "SELECT \"hire_date\", \"department_description\" 
FROM \"employee\" "
+        + "LEFT JOIN \"department\" ON TRUE";
+    final String mssqlExpected1 = "SELECT [employee].[hire_date],"
+        + " [department].[department_description]\nFROM 
[foodmart].[employee]\nLEFT JOIN"
+        + " [foodmart].[department] ON (1 = 1)";
+    sql(queryTrue)
+        .dialect(MssqlSqlDialect.DEFAULT).ok(mssqlExpected1);
+
+    final String queryFalse = "SELECT \"hire_date\", 
\"department_description\" FROM \"employee\" "

Review Comment:
   1) As discussed in Jira, this transformation not only affects the Join 
Predicate but also the SELECT, WHERE, and HAVING. Please cover this in the test 
cases.
   2) Change the summary of Jira. Maybe we can remove the "Join predicate". 
This PR has affected other places.



##########
core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java:
##########
@@ -189,6 +189,19 @@ public MssqlSqlDialect(Context context) {
     }
   }
 
+  @Override public void unparseBoolLiteral(SqlWriter writer,
+      SqlLiteral literal, int leftPrec, int rightPrec) {
+    Boolean value = (Boolean) literal.getValue();
+    if (value == null) {
+      return;
+    }
+    final SqlWriter.Frame frame = writer.startList("(", ")");

Review Comment:
   Is the code here the same as that in Oracle Dialect? If so, it can be 
extracted using a static method called RelToSqlConverterUtil.



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