← 输入框|github.com|刷新
Skip to content

Add support for RisingWave - #1376

Open
iany0 wants to merge 1 commit into
sqlancer:mainfrom
iany0:risingwave-pr
Open

iany0 wants to merge 1 commit into
sqlancer:mainfrom
iany0:risingwave-pr

Conversation

@iany0

@iany0 iany0 commented Nov 17, 2026

Copy link
Copy Markdown

Add a RisingWave provider with WHERE, HAVING, and AGGREGATE TLP oracles.

Includes SQL generation, schema discovery, ordinary views and materialized views, and RisingWave-specific synchronization and error handling.

Adds provider registration, a README entry, and a GitHub Actions workflow using the official RisingWave 3.1.0 image to run basic tests for all TLP oracles.

Validation: Maven verification, naming checks, and local tests passed, including live WHERE, HAVING, and AGGREGATE TLP tests against RisingWave 3.1.0.

@mrigger mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR! Added some feedback with some issues that we could address.

public final List<RisingWaveExpression> elements;

public RisingWaveArray(RisingWaveType type, List<RisingWaveExpression> elements) {
if (!type.array() || elements.size() > 5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for the size check here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the size check to keep arrays small. Now the generator uses Randomly.smallNumber() to pick the length. The constructor still checks the element types.

Comment thread README.md
**Understanding SQL generation.** To analyze bug-inducing statements, it is helpful to understand the characteristics of SQLancer. First, SQLancer is expected to always generate SQL statements that are syntactically valid for the DBMS under test. Thus, you should never observe any syntax errors. Second, SQLancer might generate statements that are semantically invalid. For example, SQLancer might attempt to insert duplicate values into a column with a `UNIQUE` constraint, as completely avoiding such semantic errors is challenging. Third, any bug reported by SQLancer is expected to be a real bug, except those reported by CERT (as performance issues are not as clearly defined as other kinds of bugs). If you observe any bugs indicated by SQLancer that you do not consider bugs, something is likely wrong with your setup. Finally, related to the aforementioned point, SQLancer is specific to a version of the DBMS, and you can find the version against which we are tested in our [GitHub Actions workflow](https://github.com/sqlancer/sqlancer/blob/documentation/.github/workflows/main.yml). If you are testing against another version, you might observe various false alarms (e.g., caused by syntax errors). While we would always like for SQLancer to be up-to-date with the latest development version of each DBMS, we lack the resources to achieve this.

**Supported DBMSs.** SQLancer requires DBMS-specific code for each DBMS that it supports. As of January 2025, it provides support for Citus, ClickHouse, Cloudberry, CockroachDB, Databend, (Apache) DataFusion, (Apache) Doris, DuckDB, H2, HSQLDB, MariaDB, Materialize, MySQL, OceanBase, PostgreSQL, Presto, QuestDB, SQLite3, TiDB, VoltDB, and YugabyteDB. The extent to which the individual DBMSs are supported [differs](https://github.com/sqlancer/sqlancer/blob/documentation-approaches/CONTRIBUTING.md).
**Supported DBMSs.** SQLancer requires DBMS-specific code for each DBMS that it supports. As of January 2025, it provides support for Citus, ClickHouse, Cloudberry, CockroachDB, Databend, (Apache) DataFusion, (Apache) Doris, DuckDB, H2, HSQLDB, MariaDB, Materialize, MySQL, OceanBase, PostgreSQL, Presto, QuestDB, RisingWave, SQLite3, TiDB, VoltDB, and YugabyteDB. The extent to which the individual DBMSs are supported [differs](https://github.com/sqlancer/sqlancer/blob/documentation-approaches/CONTRIBUTING.md).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add RisingWave to the CONTRIBUTING.md.

@iany0 iany0 Nov 18, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added RisingWave to the table in CONTRIBUTING.md.

"root", "risingwave", "--oracle", "QUERY_PARTITIONING", "--max-expression-depth", "1",
"--max-relation-depth", "0", "--retain-databases", "NONE" }));
// CompositeTestOracle also increments the counter for WHERE and HAVING.
assertEquals(40, Main.nrQueries.get() - completed);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems a bit too specific. Is there any reason for making it that narrow?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broader test might fail in CI. I ran it locally with the same RisingWave 3.1.0 Docker image and saw some result mismatches. I started with simpler queries to make sure the TLP tests ran on RisingWave. I’ve now changed the test to match the setup used for PostgreSQL and Materialize.


@Override
public TestOracle<RisingWaveGlobalState> create(RisingWaveGlobalState state) {
if (this == QUERY_PARTITIONING) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to make this OOP-like: we could define an abstract method that is implemented by each enum in its constructor?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Each enum value now has its own create() method.

}

public void validate() {
if (expressionDepth < 0 || expressionDepth > 5 || relationDepth < 0 || relationDepth > 3) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to have this? Other implementations don't enforce such bounds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the caps to keep queries simple. I removed them because the numbers were arbitrary. Relation depth still has to be zero or higher.

}

public void setGroupingSets(List<List<RisingWaveExpression>> sets) {
if (sets.size() > 3 || sets.stream().anyMatch(s -> s.size() > 3)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an inherent limitation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just a limit I set to keep generated queries small. I removed the check from setGroupingSets(). The query generator still caps the number of sets and keys.

}

public static boolean supportsModifiers(String name) {
return java.util.Set.of("count", "sum", "avg", "min", "max", "bool_and", "bool_or", "string_agg")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I also saw strings for aggregate functions elsewhere. I think we should make this more OOP-like by declaring them once, as well as what they support and their constraints.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the aggregate names and rules into RisingWaveAggregateFunction, following PostgreSQL and Materialize. The generator and AST now use that enum for the SQL names and result types.

return arrayLiteral(type);
}
switch (type) {
case REAL:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some redundancy between the insert generator and here that we should reduce.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have logic to create special values and cache randomly generated ones in the Randomly class. I guess it's fine to use these ones here for now, but if we can reuse any existing logic from there, it would be great.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the duplicated literal code into RisingWaveLiteralGenerator. The INSERT generator and the expression generator now share the code for array and row literals and for floating-point and TIME edge cases.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have logic to create special values and cache randomly generated ones in the Randomly class. I guess it's fine to use these ones here for now, but if we can reuse any existing logic from there, it would be great.

The shared generator uses Randomly.fromOptions() to pick from the REAL and DOUBLE lists. I kept those lists so we still test signed zero, NaN, and values near each type’s limits.

}

public RisingWaveExpression negatePredicate(RisingWaveExpression predicate) {
return new RisingWaveOperation("NOT", RisingWaveType.BOOLEAN, predicate);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we don't update the expression count here?

@iany0 iany0 Nov 18, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We count NOT when the generator picks it. When the test adds NOT to a condition it already has, we leave the count alone. I added a comment here to explain that.

return new RisingWaveFunctionCall(function.sql, function.result, arguments);
}
return leaf(type, scope);
case 3:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it would be good to try and make the expression generator more readable, for example, by splitting complex/large methods into smaller ones, or randomly selection enum actions, which are more descriptive than integers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the numbered cases with named enum values. The main switch now calls smaller methods for function calls, comparisons, arithmetic, and Boolean predicates.

@iany0

iany0 commented Nov 18, 2026

Copy link
Copy Markdown
Author

Thanks a lot for the PR! Added some feedback with some issues that we could address.

Thanks for taking the time to review this! I’ve pushed an update based on your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants