Repository navigation
Conversation
mrigger
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
What's the rationale for the size check here?
There was a problem hiding this comment.
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.
| **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). |
There was a problem hiding this comment.
We should also add RisingWave to the CONTRIBUTING.md.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
This test seems a bit too specific. Is there any reason for making it that narrow?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
It would be nicer to make this OOP-like: we could define an abstract method that is implemented by each enum in its constructor?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Is there a good reason to have this? Other implementations don't enforce such bounds.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
Is this an inherent limitation?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
There is some redundancy between the insert generator and here that we should reduce.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
We also have logic to create special values and cache randomly generated ones in the
Randomlyclass. 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); |
There was a problem hiding this comment.
Seems we don't update the expression count here?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I replaced the numbered cases with named enum values. The main switch now calls smaller methods for function calls, comparisons, arithmetic, and Boolean predicates.
Thanks for taking the time to review this! I’ve pushed an update based on your feedback. |
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.