Skip to content

Commit 439a7f1

Browse files
authored
Upgrade to sql-logic-test release 0.3 (#263)
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 14bb04d commit 439a7f1

3 files changed

Lines changed: 21 additions & 40 deletions

File tree

sql-to-dbsp-compiler/SQL-compiler/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
<dependency>
206206
<groupId>net.hydromatic</groupId>
207207
<artifactId>sql-logic-test</artifactId>
208-
<version>0.2</version>
208+
<version>0.3</version>
209209
</dependency>
210210
<dependency>
211211
<groupId>junit</groupId>

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
import java.util.concurrent.atomic.AtomicReference;
6060

6161
/**
62-
* Sql test executor that uses DBSP as a SQL runtime.
63-
* Does not support arbitrary tests: only tests that can be recast as a standing query will work.
62+
* Sql test executor that uses DBSP for query execution.
6463
*/
6564
public class DBSPExecutor extends SqlSltTestExecutor {
6665
/**
@@ -273,7 +272,7 @@ boolean runBatch(TestStatistics result) {
273272
System.err.println("Error while compiling " + testQuery.getQuery() + ": " + ex.getMessage());
274273
result.addFailure(
275274
new TestStatistics.FailedTestDescription(testQuery,
276-
"Exception during test", ex, options.verbosity > 0));
275+
"Exception during test", "", ex));
277276
return false;
278277
}
279278
queryNo++;
@@ -290,9 +289,10 @@ boolean runBatch(TestStatistics result) {
290289
System.out.println(elapsedTime(queryNo));
291290
this.cleanupFilesystem();
292291
if (this.execute)
293-
result.setPassed(result.getPassed() + queryNo); // This is not entirely correct, but I am not parsing the rust output
292+
// This is not entirely correct, but I am not parsing the rust output
293+
result.setPassedTestCount(result.getPassedTestCount() + queryNo);
294294
else
295-
result.setIgnored(result.getIgnored() + queryNo);
295+
result.setIgnoredTestCount(result.getIgnoredTestCount() + queryNo);
296296
} catch (SQLException | IOException | InterruptedException e) {
297297
throw new RuntimeException(e);
298298
}
@@ -423,7 +423,7 @@ public TestStatistics execute(SltTestFile file, OptionsParser.SuppliedOptions op
423423
// Used for debugging
424424
int toSkip = 0; // file.getTestCount() - 10;
425425

426-
TestStatistics result = new TestStatistics(options.stopAtFirstError);
426+
TestStatistics result = new TestStatistics(options.stopAtFirstError, options.verbosity);
427427
boolean seenQueries = false;
428428
int remainingInBatch = batchSize;
429429
for (ISqlTestOperation operation: file.fileContents) {
@@ -436,22 +436,17 @@ public TestStatistics execute(SltTestFile file, OptionsParser.SuppliedOptions op
436436
remainingInBatch = batchSize;
437437
seenQueries = false;
438438
}
439-
boolean status;
440439
try {
441440
if (this.buggyOperations.contains(stat.statement)) {
442441
this.options.message("Skipping buggy test " + stat.statement + "\n", 1);
443-
status = stat.shouldPass;
444442
} else {
445-
status = this.statement(stat);
443+
this.statement(stat);
446444
}
447445
} catch (SQLException ex) {
448-
this.options.error(ex);
449-
status = false;
446+
if (stat.shouldPass)
447+
this.options.error(ex);
450448
}
451449
this.statementsExecuted++;
452-
if (//this.options.validateStatus &&
453-
status != stat.shouldPass)
454-
throw new RuntimeException("Statement " + stat.statement + " status " + status + " expected " + stat.shouldPass);
455450
} else {
456451
SqlTestQuery query = operation.to(options.err, SqlTestQuery.class);
457452
if (toSkip > 0) {
@@ -632,7 +627,7 @@ void reset() {
632627
this.queriesToRun.clear();
633628
}
634629

635-
public String writeCodeToFile(
630+
public void writeCodeToFile(
636631
DBSPCompiler compiler,
637632
List<DBSPFunction> inputFunctions,
638633
List<ProgramAndTester> functions
@@ -649,12 +644,13 @@ public String writeCodeToFile(
649644
rust.add(pt.tester);
650645
}
651646
rust.writeAndClose();
652-
return testFileName;
653647
}
654648

655649
public static void register(OptionsParser parser) {
656650
AtomicReference<Boolean> jit = new AtomicReference<>();
651+
jit.set(false);
657652
AtomicReference<Boolean> incremental = new AtomicReference<>();
653+
incremental.set(false);
658654
parser.registerOption("-j", null, "Emit JIT code", o-> {
659655
jit.set(true);
660656
return true;

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqllogictest/executors/DbspJdbcExecutor.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import net.hydromatic.sqllogictest.SltSqlStatement;
2828
import net.hydromatic.sqllogictest.SltTestFile;
2929
import net.hydromatic.sqllogictest.TestStatistics;
30-
import net.hydromatic.sqllogictest.executors.HsqldbExecutor;
3130
import net.hydromatic.sqllogictest.executors.JdbcExecutor;
3231
import org.dbsp.sqlCompiler.compiler.CompilerOptions;
3332
import org.dbsp.sqlCompiler.compiler.backend.DBSPCompiler;
@@ -46,6 +45,7 @@
4645
import java.sql.*;
4746
import java.util.ArrayList;
4847
import java.util.List;
48+
import java.util.Objects;
4949
import java.util.Set;
5050
import java.util.regex.Matcher;
5151
import java.util.regex.Pattern;
@@ -57,10 +57,6 @@
5757
public class DbspJdbcExecutor extends DBSPExecutor {
5858
private final JdbcExecutor statementExecutor;
5959
private final List<String> tablesCreated;
60-
// TODO: remove this field.
61-
private final Connection fakeConnection;
62-
63-
static int counter = 0;
6460

6561
/**
6662
* @param compilerOptions Compilation options.
@@ -73,18 +69,10 @@ public DbspJdbcExecutor(JdbcExecutor executor,
7369
super(options, compilerOptions, "csv");
7470
this.statementExecutor = executor;
7571
this.tablesCreated = new ArrayList<>();
76-
try {
77-
this.fakeConnection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + counter++, "", "");
78-
} catch (SQLException e) {
79-
throw new RuntimeException(e);
80-
}
8172
}
8273

8374
Connection getStatementExecutorConnection() {
84-
// TODO: once a new version of the org.hydromatic.sql-logic-test package
85-
// is published replace this with its connection.
86-
// return this.statementExecutor.getConnection();
87-
return this.fakeConnection;
75+
return this.statementExecutor.getConnection();
8876
}
8977

9078
public DBSPZSetLiteral getTableContents(String table) throws SQLException {
@@ -281,17 +269,14 @@ public static void register(OptionsParser parser) {
281269
parser.registerExecutor("hybrid", () -> {
282270
OptionsParser.SuppliedOptions options = parser.getOptions();
283271
try {
284-
// TODO: replace there on the next version of sql-logic-test.
285-
// JdbcExecutor inner = parser.getExecutorByName("hsql");
286-
JdbcExecutor inner = new HsqldbExecutor(options);
287-
// DBSPExecutor unused = parser.getExecutorByName("dbsp").to(DBSPExecutor.class);
288-
// boolean validateJIT = unused.validateJIT;
289-
boolean validateJIT = false;
290-
// CompilerOptions compilerOptions = unused.compilerOptions;
291-
CompilerOptions compilerOptions = new CompilerOptions();
272+
JdbcExecutor inner = Objects.requireNonNull(options.getExecutorByName("hsql"))
273+
.as(JdbcExecutor.class);
274+
DBSPExecutor dbsp = Objects.requireNonNull(options.getExecutorByName("dbsp"))
275+
.as(DBSPExecutor.class);
276+
CompilerOptions compilerOptions = Objects.requireNonNull(dbsp).compilerOptions;
292277
compilerOptions.optimizerOptions.throwOnError = options.stopAtFirstError;
293278
DbspJdbcExecutor result = new DbspJdbcExecutor(
294-
inner, options, compilerOptions);
279+
Objects.requireNonNull(inner), options, compilerOptions);
295280
Set<String> bugs = options.readBugsFile();
296281
result.avoid(bugs);
297282
return result;

0 commit comments

Comments
 (0)