Skip to content

Commit d506652

Browse files
committed
[SQL] Better handling of DROP TABLE (only used in SLT tests)
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent c6214c7 commit d506652

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/CalciteToDBSPCompiler.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,6 +3205,19 @@ DBSPNode compileCreateType(CreateTypeStatement stat) {
32053205
return null;
32063206
}
32073207

3208+
@SuppressWarnings("UnusedReturnValue")
3209+
@Nullable
3210+
DBSPNode compileDropTable(DropTableStatement drop) {
3211+
ProgramIdentifier tableName = drop.tableName;
3212+
this.metadata.removeTable(tableName);
3213+
DBSPCircuit circuit = this.getCircuit();
3214+
IInputOperator input = circuit.getInput(tableName);
3215+
Objects.requireNonNull(input);
3216+
circuit.allOperators.remove(input.asOperator());
3217+
circuit.sourceOperators.remove(tableName);
3218+
return null;
3219+
}
3220+
32083221
@Nullable
32093222
DBSPNode compileCreateTable(CreateTableStatement create) {
32103223
ProgramIdentifier tableName = create.relationName;
@@ -3395,6 +3408,9 @@ public DBSPNode compile(RelStatement statement) {
33953408
if (create != null) {
33963409
// We create an input for the circuit.
33973410
return this.compileCreateTable(create);
3411+
} else {
3412+
DropTableStatement drop = statement.as(DropTableStatement.class);
3413+
this.compileDropTable(drop);
33983414
}
33993415
return null;
34003416
} else if (statement.is(TableModifyStatement.class)) {

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/calciteCompiler/Catalog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ protected Multimap<String, Function> getFunctionMultimap() {
100100

101101
public void dropTable(ProgramIdentifier tableName) {
102102
this.tableMap.remove(tableName.name());
103+
this.definition.remove(tableName.name());
103104
}
104105

105106
public boolean addType(ProgramIdentifier name, IErrorReporter reporter, RelStatement statement) {

0 commit comments

Comments
 (0)