Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join Issues #386

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.datasqrl.error;

import com.google.common.base.Strings;
import java.io.PrintStream;
import java.io.PrintWriter;

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static final class EqualityCondition {
public int rightIndex;

public EqualityCondition(int leftIndex, int rightIndex) {
Preconditions.checkArgument(leftIndex<rightIndex);
Preconditions.checkArgument(leftIndex<rightIndex || rightIndex==NO_INDEX);
Preconditions.checkArgument(leftIndex>=0 || rightIndex>=0);
this.leftIndex = leftIndex;
this.rightIndex = rightIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]])

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down