diff --git a/sqrl-base/src/main/java/com/datasqrl/error/CollectedException.java b/sqrl-base/src/main/java/com/datasqrl/error/CollectedException.java index d4287789b..2e7ae7c1e 100644 --- a/sqrl-base/src/main/java/com/datasqrl/error/CollectedException.java +++ b/sqrl-base/src/main/java/com/datasqrl/error/CollectedException.java @@ -1,5 +1,6 @@ package com.datasqrl.error; +import com.google.common.base.Strings; import java.io.PrintStream; import java.io.PrintWriter; @@ -9,6 +10,11 @@ public CollectedException(Throwable cause) { super("Collected exception",cause); } + public boolean isInternalError() { + if (getCause() instanceof NullPointerException) return true; + return Strings.isNullOrEmpty(getMessage()); + } + @Override public String getMessage() { return getCause().getMessage(); diff --git a/sqrl-engines/sqrl-engine-flink/src/main/java/com/datasqrl/util/SqrlRexUtil.java b/sqrl-engines/sqrl-engine-flink/src/main/java/com/datasqrl/util/SqrlRexUtil.java index ef86891b6..d76cda4f5 100644 --- a/sqrl-engines/sqrl-engine-flink/src/main/java/com/datasqrl/util/SqrlRexUtil.java +++ b/sqrl-engines/sqrl-engine-flink/src/main/java/com/datasqrl/util/SqrlRexUtil.java @@ -177,7 +177,7 @@ public static final class EqualityCondition { public int rightIndex; public EqualityCondition(int leftIndex, int rightIndex) { - Preconditions.checkArgument(leftIndex=0 || rightIndex>=0); this.leftIndex = leftIndex; this.rightIndex = rightIndex; diff --git a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/plan/local/analyze/ResolveTest.java b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/plan/local/analyze/ResolveTest.java index 659550e66..041d39d74 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/plan/local/analyze/ResolveTest.java +++ b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/plan/local/analyze/ResolveTest.java @@ -212,6 +212,8 @@ public void tableJoinTest() { "OrderCustomerRight := SELECT coalesce(o._uuid, '') as ouuid, o.id, c.name, o.customerid FROM Orders o RIGHT JOIN Customer c on o.customerid = c.customerid;"); builder.add( "OrderCustomerRightExcluded := SELECT c.customerid, c.name FROM Orders o RIGHT JOIN Customer c on o.customerid = c.customerid WHERE o._uuid IS NULL;"); + builder.add( + "OrderCustomerConstant := SELECT o.id, c.name, o.customerid FROM Orders o JOIN Customer c ON o.customerid = c.customerid AND c.name = 'Robert' AND o.id = 5;"); plan(builder.toString()); validateQueryTable("ordercustomer", TableType.STATE, ExecutionEngine.Type.DATABASE, 6, 2, TimestampTest.fixed(5)); //numCols = 3 selected cols + 2 uuid cols for pk + 1 for timestamp @@ -223,6 +225,8 @@ public void tableJoinTest() { TimestampTest.fixed(5)); validateQueryTable("ordercustomerrightexcluded", TableType.STATE, ExecutionEngine.Type.DATABASE, 4, 1, TimestampTest.fixed(3)); + validateQueryTable("ordercustomerconstant", TableType.STATE, ExecutionEngine.Type.DATABASE, 6, 2, + TimestampTest.fixed(5)); } @Test diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/ResolveTest/tableJoinTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/ResolveTest/tableJoinTest.txt index 07e6058c8..60471410c 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/ResolveTest/tableJoinTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/ResolveTest/tableJoinTest.txt @@ -66,3 +66,15 @@ LogicalProject(_uuid=[$0], customerid=[$2], name=[$4], __timestamp=[$12]) LogicalTableScan(table=[[customer$2]]) LogicalTableScan(table=[[orders$2]]) +>>>ordercustomerconstant$1-lp-STREAM +LogicalProject(_uuid=[$0], _uuid0=[$6], id=[$2], name=[$10], customerid=[$3], __timestamp=[CASE(<($4, $7), $7, $4)]) + LogicalJoin(condition=[AND(=($3, $8), =($10, 'Robert'), =($2, 5))], joinType=[inner]) hints[JoinCostHint options:[STREAM, STREAM, 3, NONE]] + LogicalTableScan(table=[[orders$2]]) + LogicalTableScan(table=[[customer$2]]) + +>>>ordercustomerconstant$1-lp-DATABASE +LogicalProject(_uuid=[$0], _uuid0=[$6], id=[$2], name=[$10], customerid=[$3], __timestamp=[CASE(<($4, $7), $7, $4)]) + LogicalJoin(condition=[AND(=($3, $8), =($10, 'Robert'), =($2, 5))], joinType=[inner]) hints[JoinCostHint options:[STREAM, STREAM, 3, NONE]] + LogicalTableScan(table=[[orders$2]]) + LogicalTableScan(table=[[customer$2]]) + diff --git a/sqrl-testing/sqrl-integration-tests/src/test/java/com/datasqrl/DocumentationExamplesTest.java b/sqrl-testing/sqrl-integration-tests/src/test/java/com/datasqrl/DocumentationExamplesTest.java index 3d5e5cf34..7aad4b056 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/java/com/datasqrl/DocumentationExamplesTest.java +++ b/sqrl-testing/sqrl-integration-tests/src/test/java/com/datasqrl/DocumentationExamplesTest.java @@ -92,6 +92,13 @@ public void createSinkDir(Path rootDir) { Files.createDirectories(rootDir.resolve(DEFAULT_SINK_DIR)); } + + @Test + @Disabled + public void testExternal() { + execute(Path.of("/your/path/cleared_data"), "compile", "rave_enrich2.sqrl", null); + } + public void execute(@NonNull Path rootDir, @NonNull String command, String script, String graphQL, String... options) { this.root = rootDir; //For clean up createSinkDir(rootDir); diff --git a/sqrl-tools/sqrl-cli/src/main/java/com/datasqrl/cmd/AbstractCommand.java b/sqrl-tools/sqrl-cli/src/main/java/com/datasqrl/cmd/AbstractCommand.java index 29a98a5be..ff02b55fa 100644 --- a/sqrl-tools/sqrl-cli/src/main/java/com/datasqrl/cmd/AbstractCommand.java +++ b/sqrl-tools/sqrl-cli/src/main/java/com/datasqrl/cmd/AbstractCommand.java @@ -30,6 +30,7 @@ public void run() { runCommand(collector); root.statusHook.onSuccess(); } catch (CollectedException e) { + if (e.isInternalError()) e.printStackTrace(); root.statusHook.onFailure(e, collector); } catch (Exception e) { //unknown exception collector.getCatcher().handle(e);