Skip to content

Commit

Permalink
[SQL] More issues attached to errors
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
  • Loading branch information
mihaibudiu committed Oct 14, 2024
1 parent a0b4b7a commit 6bc305f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ public final class InternalCompilerError extends BaseCompilerException {
@Nullable
public final IDBSPNode dbspNode;

static String makeMessage(String message) {
return message + System.lineSeparator() +
"We would appreciate if you could report an issue at https://github.com/feldera/feldera/issues";
}

InternalCompilerError(String message, CalciteObject node,
@Nullable IDBSPNode dbspNode) {
super(message, node);
super(makeMessage(message), node);
this.dbspNode = dbspNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ protected UnimplementedException(String message, @Nullable IDBSPNode node, Calci

public UnimplementedException(String message, int issue, CalciteObject object) {
this(makeMessage(message + System.lineSeparator() +
"This is tracked by issue https://github.com/feldera/feldera/issues/" + issue), object);
"This is tracked by issue https://github.com/feldera/feldera/issues/" +
issue + System.lineSeparator()), object);
}

public UnimplementedException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ void processAvg(SqlAvgAggFunction function) {
AggregateBase implementation = switch (function.getKind()) {
case AVG -> this.doAverage(function);
case STDDEV_POP, STDDEV_SAMP -> this.doStddev(function);
default -> throw new UnimplementedException("Statistical aggregate function not yet implemented", node);
default -> throw new UnimplementedException("Statistical aggregate function not yet implemented", 172, node);
};
this.setResult(implementation);
}
Expand All @@ -730,7 +730,7 @@ public AggregateBase compile() {
this.process(this.aggFunction, SqlSingleValueAggFunction.class, this::processSingle) ||
this.process(this.aggFunction, SqlAbstractGroupFunction.class, this::processGrouping);
if (!success || this.result == null)
throw new UnimplementedException("Aggregate function " + this.aggFunction + " not yet implemented",
throw new UnimplementedException("Aggregate function " + this.aggFunction + " not yet implemented", 172,
CalciteObject.create(this.aggFunction));
return this.result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,22 +540,22 @@ void compileHop(LogicalTableFunctionScan scan, RexCall call) {
this.assignOperator(scan, hop);
}

void visitTableFunction(LogicalTableFunctionScan scan) {
CalciteObject node = CalciteObject.create(scan);
RexNode operation = scan.getCall();
void visitTableFunction(LogicalTableFunctionScan tf) {
CalciteObject node = CalciteObject.create(tf);
RexNode operation = tf.getCall();
assert operation instanceof RexCall;
RexCall call = (RexCall) operation;
switch (call.getOperator().getName()) {
case "HOP":
this.compileHop(scan, call);
this.compileHop(tf, call);
return;
case "TUMBLE":
this.compileTumble(scan, call);
this.compileTumble(tf, call);
return;
default:
break;
}
throw new UnimplementedException("Logical table function not yet implemented", node);
throw new UnimplementedException("Table function " + tf + " not yet implemented", node);
}

void visitUncollect(Uncollect uncollect) {
Expand Down Expand Up @@ -1511,7 +1511,8 @@ private void visitCollect(Collect collect) {
break;
}
default:
throw new UnimplementedException(node);
throw new UnimplementedException("Aggregation to " + collect.getCollectionType() +
" not yet implemented", node);
}
DBSPAggregate aggregate = new DBSPAggregate(node, row, Linq.list(agg));
DBSPOperator aggregateOperator = new DBSPAggregateOperator(
Expand Down Expand Up @@ -2361,7 +2362,7 @@ void visitSort(LogicalSort sort) {
return;
}
if (sort.offset != null)
throw new UnimplementedException("OFFSET in SORT not yet implemented", node);
throw new UnimplementedException("OFFSET in SORT not yet implemented", 172, node);

DBSPExpression limit = null;
if (sort.fetch != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ node, new DBSPTypeBool(CalciteObject.EMPTY, false), DBSPOpcode.EQ,
return switch (opName) {
case "||" -> makeBinaryExpression(node, type, DBSPOpcode.CONCAT, ops);
default -> throw new UnimplementedException("Support for operation/function " +
Utilities.singleQuote(opName) + " not yet implemented", node);
Utilities.singleQuote(opName) + " not yet implemented", 1265, node);
};
}
case EXTRACT: {
Expand Down Expand Up @@ -1435,7 +1435,7 @@ else if (!elemType.sameType(arg1.type.setMayBeNull(elemType.mayBeNull))) {
case DOT:
default:
throw new UnimplementedException("Function " + Utilities.singleQuote(operationName)
+ " not yet implemented", node);
+ " not yet implemented", 1265, node);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ List<RelColumnMetadata> createTableColumnsMetadata(SqlNodeList list, SqlIdentifi
col instanceof SqlForeignKey) {
continue;
} else {
throw new UnimplementedException("Column constraint not yet implemented", CalciteObject.create(col));
throw new UnimplementedException("Column constraint not yet implemented", 1198,
CalciteObject.create(col));
}

String colName = name.getSimple();
Expand Down Expand Up @@ -1112,7 +1113,7 @@ public FrontEndStatement compile(
SqlInsert insert = (SqlInsert) node;
SqlNode table = insert.getTargetTable();
if (!(table instanceof SqlIdentifier id))
throw new UnimplementedException("INSERT statement expected a table name", CalciteObject.create(table));
throw new CompilationError("INSERT statement expected a table name", CalciteObject.create(table));
TableModifyStatement stat = new TableModifyStatement(node, true, sqlStatement, id.toString(), insert.getSource());
RelRoot values = converter.convertQuery(stat.data, true, true);
values = values.withRel(this.optimize(values.rel));
Expand All @@ -1125,7 +1126,7 @@ public FrontEndStatement compile(
if (node instanceof SqlRemove insert) {
SqlNode table = insert.getTargetTable();
if (!(table instanceof SqlIdentifier id))
throw new UnimplementedException("REMOVE statement expected a table name", CalciteObject.create(table));
throw new CompilationError("REMOVE statement expected a table name", CalciteObject.create(table));
TableModifyStatement stat = new TableModifyStatement(node, false, sqlStatement, id.toString(), insert.getSource());
RelRoot values = converter.convertQuery(stat.data, true, true);
values = values.withRel(this.optimize(values.rel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void unsupported(DBSPExpression source, DBSPType type) {
}

@Nullable DBSPExpression convertToVariant(DBSPExpression source, boolean mayBeNull) {
DBSPExpression expression = source;
DBSPExpression expression;
if (source.type.is(DBSPTypeTuple.class)) {
// Convert a tuple to a VARIANT MAP indexed by the field names
DBSPTypeTuple tuple = source.getType().to(DBSPTypeTuple.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ public void postorder(DBSPSourceMultisetOperator operator) {
// Currently we only support at most 1 watermark column per table.
// TODO: support multiple fields.
if (minimums.size() > 1) {
throw new UnimplementedException("More than 1 watermark per table not yet supported", operator.getNode());
throw new UnimplementedException("More than 1 watermark per table not yet supported", 2734, operator.getNode());
}

if (!minimums.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ create table FULFILLMENT (
public void testTypeErrorMessage() {
// TODO: this test may become invalid once we add support for ROW types
this.statementsFailingInCompilation("CREATE VIEW V AS SELECT ROW(2, 2);",
"error: Not yet implemented: Function 'ROW' not yet implemented:ROW(2, 2)\nYou can suggest");
"error: Not yet implemented: Function 'ROW' not yet implemented\n" +
"This is tracked by issue");
}

@Test
Expand Down

0 comments on commit 6bc305f

Please sign in to comment.