mihaibudiu commented on code in PR #3863:
URL: https://github.com/apache/calcite/pull/3863#discussion_r1681460397
##########
core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java:
##########
@@ -126,6 +139,19 @@ public OracleSqlDialect(Context context) {
return false;
}
+ @Override public void unparseBoolLiteral(SqlWriter writer,
+ SqlBoolLiteral literal, int leftPrec, int rightPrec) {
+ Boolean value = (Boolean) literal.getValue();
+ if (value == null || majorVersion >= 23) {
+ super.unparseBoolLiteral(writer, literal, leftPrec, rightPrec);
+ return;
+ }
+ // low version oracle not support bool literal
+ SqlCall call =
Review Comment:
Creating a call seems overkill, you can just emit the expected output
directly.
The expression emitted would also require parentheses.
##########
core/src/main/java/org/apache/calcite/sql/SqlBoolLiteral.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * A SQL literal representing a BOOLEAN value,
+ * for example <code>BOOLEAN 'TRUE'</code>.
+ *
+ * <p>Create values using {@link SqlLiteral#createBoolean}.
+ */
+public class SqlBoolLiteral extends SqlLiteral {
Review Comment:
I don't know if it's this easy to create this class.
It looks that currently SqlLiteral is used to represent Boolean literals.
With this change there will be two possible representations.
Unless you audit the whole codebase and make sure that SqlLiteral is never
used to represent Booleans, everybody will handle both cases.
You can do that by asserting in SqlLiteral that the value is never a
Boolean, and then you can see how many tests fail.
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -466,6 +466,12 @@ public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec,
}
}
+ public void unparseBoolLiteral(SqlWriter writer,
+ SqlBoolLiteral literal, int leftPrec, int rightPrec) {
+ writer.keyword(
+ literal.getValue() == null ? "UNKNOWN" : (Boolean) literal.getValue()
? "TRUE" : "FALSE");
Review Comment:
if you use a separate class you can probably add a method getBooleanValue in
SqlBooleanLiteral
--
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]