Skip to content

Commit

Permalink
Rename TruthValue UNK -> UNKNOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Dec 19, 2024
1 parent 3fc0aa0 commit d810722
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -2816,11 +2816,11 @@ public class org/partiql/ast/expr/TrimSpec : org/partiql/ast/AstEnum {
public class org/partiql/ast/expr/TruthValue : org/partiql/ast/AstEnum {
public static final field FALSE I
public static final field TRUE I
public static final field UNK I
public static final field UNKNOWN I
public fun <init> (I)V
public static fun FALSE ()Lorg/partiql/ast/expr/TruthValue;
public static fun TRUE ()Lorg/partiql/ast/expr/TruthValue;
public static fun UNK ()Lorg/partiql/ast/expr/TruthValue;
public static fun UNKNOWN ()Lorg/partiql/ast/expr/TruthValue;
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
protected fun canEqual (Ljava/lang/Object;)Z
public fun code ()I
Expand Down
10 changes: 5 additions & 5 deletions partiql-ast/src/main/java/org/partiql/ast/expr/TruthValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class TruthValue extends AstEnum {
public static final int TRUE = 0;
public static final int FALSE = 1;
public static final int UNK = 2;
public static final int UNKNOWN = 2;

private final int code;

Expand All @@ -31,8 +31,8 @@ public static TruthValue FALSE() {
return new TruthValue(FALSE);
}

public static TruthValue UNK() {
return new TruthValue(UNK);
public static TruthValue UNKNOWN() {
return new TruthValue(UNKNOWN);
}

@Override
Expand All @@ -46,7 +46,7 @@ public String name() {
switch (code) {
case TRUE: return "TRUE";
case FALSE: return "FALSE";
case UNK: return "UNK";
case UNKNOWN: return "UNKNOWN";
default: throw new IllegalStateException("Invalid TruthValue code: " + code);
}
}
Expand All @@ -56,7 +56,7 @@ public static TruthValue parse(@NotNull String value) {
switch (value) {
case "TRUE": return TruthValue.TRUE();
case "FALSE": return TruthValue.FALSE();
case "UNK": return TruthValue.UNK();
case "UNK": return TruthValue.UNKNOWN();
default: throw new IllegalArgumentException("No enum constant TruthValue." + value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public abstract class SqlDialect : AstVisitor<SqlBlock, SqlBlock>() {
t = t concat when (node.truthValue.code()) {
TruthValue.TRUE -> "TRUE"
TruthValue.FALSE -> "FALSE"
TruthValue.UNK -> "UNKNOWN"
TruthValue.UNKNOWN -> "UNKNOWN"
else -> throw UnsupportedOperationException("Cannot print $node")
}
return t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,15 +1043,15 @@ class SqlDialectTest {
exprBoolTest(
value = v("x"),
not = false,
truthValue = TruthValue.UNK()
truthValue = TruthValue.UNKNOWN()
)
),
expect(
"x IS NOT UNKNOWN",
exprBoolTest(
value = v("x"),
not = true,
truthValue = TruthValue.UNK()
truthValue = TruthValue.UNKNOWN()
)
),
// IS [NOT] NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ internal class PartiQLParserDefault : PartiQLParser {
when (ctx.truthValue.type) {
GeneratedParser.TRUE -> exprBoolTest(expr, not, TruthValue.TRUE())
GeneratedParser.FALSE -> exprBoolTest(expr, not, TruthValue.FALSE())
GeneratedParser.UNKNOWN -> exprBoolTest(expr, not, TruthValue.UNK())
GeneratedParser.UNKNOWN -> exprBoolTest(expr, not, TruthValue.UNKNOWN())
else -> throw error(ctx, "Unexpected value for boolean test IS [NOT] TRUE|FALSE|UNKNOWN")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ internal object RexConverter {
var call = when (node.truthValue.code()) {
TruthValue.TRUE -> call("is_true", value)
TruthValue.FALSE -> call("is_false", value)
TruthValue.UNK -> call("is_unknown", value)
TruthValue.UNKNOWN -> call("is_unknown", value)
else -> error("Unexpected TruthValue: ${node.truthValue}")
}
// See SQL99 6.30 pg 216 Rule 2 for equivalence
Expand Down

0 comments on commit d810722

Please sign in to comment.