Skip to content

Commit

Permalink
Remove SqlBoolLiteral.java
Browse files Browse the repository at this point in the history
  • Loading branch information
suibianwanwank committed Jul 17, 2024
1 parent d853c39 commit 0b16645
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 60 deletions.
50 changes: 0 additions & 50 deletions core/src/main/java/org/apache/calcite/sql/SqlBoolLiteral.java

This file was deleted.

5 changes: 3 additions & 2 deletions core/src/main/java/org/apache/calcite/sql/SqlDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,10 @@ public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec,
}

public void unparseBoolLiteral(SqlWriter writer,
SqlBoolLiteral literal, int leftPrec, int rightPrec) {
SqlLiteral literal, int leftPrec, int rightPrec) {
Object value = literal.getValue();
writer.keyword(
literal.getValue() == null ? "UNKNOWN" : (Boolean) literal.getValue() ? "TRUE" : "FALSE");
!(value instanceof Boolean) ? "UNKNOWN" : (Boolean) value ? "TRUE" : "FALSE");
}

public void unparseDateTimeLiteral(SqlWriter writer,
Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ public static SqlLiteral createNull(SqlParserPos pos) {
public static SqlLiteral createBoolean(
boolean b,
SqlParserPos pos) {
return b ? new SqlBoolLiteral(Boolean.TRUE, SqlTypeName.BOOLEAN, pos)
: new SqlBoolLiteral(Boolean.FALSE, SqlTypeName.BOOLEAN, pos);
return b ? new SqlLiteral(Boolean.TRUE, SqlTypeName.BOOLEAN, pos)
: new SqlLiteral(Boolean.FALSE, SqlTypeName.BOOLEAN, pos);
}

public static SqlLiteral createUnknown(SqlParserPos pos) {
Expand Down Expand Up @@ -754,8 +754,7 @@ public String getStringValue() {
int rightPrec) {
switch (typeName) {
case BOOLEAN:
writer.keyword(
value == null ? "UNKNOWN" : (Boolean) value ? "TRUE" : "FALSE");
writer.getDialect().unparseBoolLiteral(writer, this, leftPrec, rightPrec);
break;
case NULL:
writer.keyword("NULL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
import org.apache.calcite.sql.SqlAbstractDateTimeLiteral;
import org.apache.calcite.sql.SqlAlienSystemTypeNameSpec;
import org.apache.calcite.sql.SqlBoolLiteral;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlDataTypeSpec;
import org.apache.calcite.sql.SqlDateLiteral;
Expand Down Expand Up @@ -140,7 +139,7 @@ public OracleSqlDialect(Context context) {
}

@Override public void unparseBoolLiteral(SqlWriter writer,
SqlBoolLiteral literal, int leftPrec, int rightPrec) {
SqlLiteral literal, int leftPrec, int rightPrec) {
Boolean value = (Boolean) literal.getValue();
if (value == null || majorVersion >= 23) {
super.unparseBoolLiteral(writer, literal, leftPrec, rightPrec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7702,8 +7702,7 @@ private void checkLiteral2(String expression, String expected) {

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6482">[CALCITE-6482]
* Oracle dialect convert bool literal when version < 23</a>.
*/
* Oracle dialect convert bool literal when version < 23</a>.*/
@Test void testBoolLiteralOracle() {
String query = "SELECT \"e1\".\"department_id\" "
+ "FROM \"employee\" \"e1\""
Expand Down

0 comments on commit 0b16645

Please sign in to comment.