sqlancer.duckdb.test.DuckDBQueryPartitioningWhereTester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sqlancer Show documentation
Show all versions of sqlancer Show documentation
SQLancer finds logic bugs in Database Management Systems through automatic testing
package sqlancer.duckdb.test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import sqlancer.ComparatorHelper;
import sqlancer.Randomly;
import sqlancer.duckdb.DuckDBErrors;
import sqlancer.duckdb.DuckDBProvider.DuckDBGlobalState;
import sqlancer.duckdb.DuckDBToStringVisitor;
public class DuckDBQueryPartitioningWhereTester extends DuckDBQueryPartitioningBase {
public DuckDBQueryPartitioningWhereTester(DuckDBGlobalState state) {
super(state);
DuckDBErrors.addGroupByErrors(errors);
}
@Override
public void check() throws SQLException {
super.check();
select.setWhereClause(null);
String originalQueryString = DuckDBToStringVisitor.asString(select);
List resultSet = ComparatorHelper.getResultSetFirstColumnAsString(originalQueryString, errors, state);
boolean orderBy = Randomly.getBooleanWithRatherLowProbability();
if (orderBy) {
select.setOrderByExpressions(gen.generateOrderBys());
}
select.setWhereClause(predicate);
String firstQueryString = DuckDBToStringVisitor.asString(select);
select.setWhereClause(negatedPredicate);
String secondQueryString = DuckDBToStringVisitor.asString(select);
select.setWhereClause(isNullPredicate);
String thirdQueryString = DuckDBToStringVisitor.asString(select);
List combinedString = new ArrayList<>();
List secondResultSet = ComparatorHelper.getCombinedResultSet(firstQueryString, secondQueryString,
thirdQueryString, combinedString, !orderBy, state, errors);
ComparatorHelper.assumeResultSetsAreEqual(resultSet, secondResultSet, originalQueryString, combinedString,
state);
}
}