Skip to content

Commit 4f877dd

Browse files
mihaibudiugz
authored andcommitted
[SQL/SLT] SLT tests were broken when the error view was introduced
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent b769f95 commit 4f877dd

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/tools/BaseSQLTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ protected void starting(final Description description) {
211211

212212
public static int testsExecuted = 0;
213213

214-
/**
215-
* Collect here all the tests to run and execute them using a single Rust compilation.
216-
*/
214+
/** Collect here all the tests to run and execute them using a single Rust compilation. */
217215
static final List<TestCase> testsToRun = new ArrayList<>();
218216

219217
@BeforeClass

sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/tools/TestCase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.dbsp.sqlCompiler.circuit.DBSPCircuit;
44
import org.dbsp.sqlCompiler.circuit.operator.DBSPSinkOperator;
55
import org.dbsp.sqlCompiler.compiler.errors.UnimplementedException;
6-
import org.dbsp.sqlCompiler.compiler.frontend.calciteCompiler.ProgramIdentifier;
76
import org.dbsp.sqlCompiler.compiler.frontend.calciteObject.CalciteObject;
87
import org.dbsp.sqlCompiler.ir.DBSPFunction;
98
import org.dbsp.sqlCompiler.ir.expression.DBSPApplyExpression;

sql-to-dbsp-compiler/slt/src/main/java/org/dbsp/sqllogictest/executors/DBSPExecutor.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.hydromatic.sqllogictest.TestStatistics;
3333
import net.hydromatic.sqllogictest.executors.SqlSltTestExecutor;
3434
import org.dbsp.sqlCompiler.circuit.DBSPCircuit;
35+
import org.dbsp.sqlCompiler.circuit.operator.DBSPSinkOperator;
3536
import org.dbsp.sqlCompiler.compiler.CompilerOptions;
3637
import org.dbsp.sqlCompiler.compiler.DBSPCompiler;
3738
import org.dbsp.sqlCompiler.compiler.backend.rust.RustFileWriter;
@@ -288,20 +289,28 @@ ProgramAndTester generateTestCase(
288289
}
289290
compiler.compileStatement(dbspQuery);
290291
compiler.throwIfErrorsOccurred();
291-
DBSPCircuit dbsp = compiler.getFinalCircuit(false);
292+
DBSPCircuit circuit = compiler.getFinalCircuit(false);
293+
circuit.setName("circuit" + suffix);
292294
DBSPNode.done();
293295

294-
if (dbsp.getOutputCount() != 1)
295-
throw new RuntimeException(
296-
"Didn't expect a query to have " + dbsp.getOutputCount() + " outputs");
297-
DBSPTypeZSet outputType = dbsp.getSingleOutputType().to(DBSPTypeZSet.class);
296+
List<DBSPSinkOperator> sinks = Linq.list(circuit.sinkOperators.values());
297+
int outputNumber = 0;
298+
DBSPSinkOperator sink = null;
299+
for (; outputNumber < circuit.getOutputCount(); outputNumber++) {
300+
sink = sinks.get(outputNumber);
301+
// Skip over system views if we are not checking these
302+
if (!sink.metadata.system)
303+
break;
304+
}
305+
assert sink != null;
306+
DBSPTypeZSet outputType = sink.outputType.to(DBSPTypeZSet.class);
298307
DBSPZSetLiteral expectedOutput = null;
299308
if (testQuery.outputDescription.hash == null) {
300309
expectedOutput = DBSPExecutor.convert(testQuery.outputDescription.getQueryResults(), outputType);
301310
}
302311

303312
return createTesterCode(
304-
"tester" + suffix, dbsp,
313+
"tester" + suffix, circuit, outputNumber,
305314
gen.getInputFunction(),
306315
compiler.getTableContents(),
307316
expectedOutput, testQuery.outputDescription);
@@ -410,12 +419,14 @@ public TestStatistics execute(SltTestFile file, OptionsParser.SuppliedOptions op
410419
* @param circuit DBSP circuit that will be tested.
411420
* @param output Expected data from the circuit.
412421
* @param description Description of the expected outputs.
422+
* @param outputNumber Position of data output in output vector.
413423
* @return The code for a function that runs the circuit with the specified
414424
* input and tests the produced output.
415425
*/
416426
static ProgramAndTester createTesterCode(
417427
String name,
418428
DBSPCircuit circuit,
429+
int outputNumber,
419430
DBSPFunction inputGeneratingFunction,
420431
TableContents contents,
421432
@Nullable DBSPZSetLiteral output,
@@ -430,7 +441,9 @@ static ProgramAndTester createTesterCode(
430441
DBSPLetStatement streams = new DBSPLetStatement("streams", cas.getVarReference().field(1));
431442
list.add(streams);
432443

433-
DBSPType circuitOutputType = circuit.getSingleOutputType();
444+
List<DBSPSinkOperator> sinks = Linq.list(circuit.sinkOperators.values());
445+
DBSPSinkOperator sink = sinks.get(outputNumber);
446+
DBSPType circuitOutputType = sink.outputType;
434447
// True if the output is a zset of vectors (generated for order by queries)
435448
boolean isVector = circuitOutputType.to(DBSPTypeZSet.class).elementType.is(DBSPTypeVec.class);
436449

@@ -455,7 +468,7 @@ static ProgramAndTester createTesterCode(
455468
DBSPLetStatement outputStatement =
456469
new DBSPLetStatement("out",
457470
new DBSPApplyExpression("read_output_handle", DBSPTypeAny.getDefault(),
458-
streams.getVarReference().field(circuit.getInputTables().size()).borrow()));
471+
streams.getVarReference().field(circuit.getInputTables().size() + outputNumber).borrow()));
459472
list.add(outputStatement);
460473
DBSPExpression sort = new DBSPEnumValue("SortOrder", description.getOrder().toString());
461474

0 commit comments

Comments
 (0)