Skip to content

Conversation

@goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Jul 21, 2025

Description

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Expanded test coverage for default null ordering in SQL queries across multiple connectors (BigQuery, MySQL, Postgres, Oracle, MSSQL).
    • Added new test models and sample data to validate null ordering behavior.
    • Introduced user-friendly error handling for MSSQL queries requiring limits with order-by clauses.
  • Bug Fixes

    • Enforced default null ordering as "NULLS LAST" for SQL ORDER BY clauses when unspecified.
  • Chores

    • Updated dependencies by removing legacy event modules and integrating OpenTelemetry support.
    • Disabled unsupported roundtrip SQL-to-AST tests for improved stability.
  • Documentation

    • Refined test assertions and added clarifications on null ordering behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

Walkthrough

This change set standardizes the default SQL null ordering to "NULLS LAST" across multiple connectors and engines. It introduces new or updated tests for BigQuery, MySQL, Postgres, Oracle, and MSSQL connectors to verify this behavior, updates Java and Rust core logic to enforce and test the default, and adjusts dependency management and tracing modules as part of a broader upgrade.

Changes

Files/Paths Change Summary
ibis-server/tests/routers/v2/connector/test_bigquery.py
ibis-server/tests/routers/v2/connector/test_mysql.py
ibis-server/tests/routers/v2/connector/test_postgres.py
ibis-server/tests/routers/v2/connector/test_mssql.py
Added new async test functions test_order_by_nulls_last for each connector, verifying that queries without explicit null ordering return results with non-null values first and nulls last. For MSSQL, also added test_order_by_require_limit to check error handling when ordering without a limit. Added new "null_test" table creation and data insertion for MSSQL tests.
ibis-server/tests/routers/v3/connector/bigquery/test_query.py
ibis-server/tests/routers/v3/connector/oracle/test_query.py
ibis-server/tests/routers/v3/connector/postgres/test_query.py
Added new model "null_test" to manifests and new async test functions to verify null ordering (asc/desc) in query results for each connector.
ibis-server/tests/routers/v3/connector/oracle/conftest.py
ibis-server/tests/routers/v3/connector/postgres/conftest.py
Added setup logic to create and populate a new "null_test" table with null and non-null values for use in null ordering tests.
ibis-server/app/model/connector.py Added GenericUserError exception class and overridden query method in MSSqlConnector to catch specific error code (1033) and raise a user-friendly error when order-by queries lack a limit.
wren-core-legacy/pom.xml
wren-core-legacy/wren-server/pom.xml
wren-core-legacy/wren-tests/pom.xml
Updated and removed dependencies: Airlift upgraded (269→305), io.airlift:event removed, OpenTelemetry dependencies added/updated.
wren-core-legacy/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java
wren-core-legacy/trino-parser/src/main/java/io/trino/sql/QueryUtil.java
Changed default null ordering in SQL formatting and query utilities to use NULLS LAST instead of UNDEFINED, and updated comments and control flow accordingly.
wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java
wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestStatementBuilder.java
Disabled several tests that depend on roundtrip SQL-AST conversion not supported by Wren; updated null ordering in some tests from UNDEFINED to LAST.
wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java
wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java
Replaced Airlift event module with a new OpenTelemetry module providing a no-op tracer for dependency injection.
wren-core-legacy/wren-tests/src/main/java/io/wren/testing/TestingWrenServer.java Removed Airlift event module from Guice bootstrap modules.
wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResource.java Relaxed error message assertion in test to match error text regardless of newlines.
wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java Added new test verifying default null ordering in generated SQL; minor assertion formatting fixes.
wren-core/core/src/mdl/context.rs Set "datafusion.sql_parser.default_null_ordering" to "nulls_last" in session context builder.
wren-core/core/src/mdl/mod.rs Added async test verifying default null ordering in transformed SQL for various order by clauses.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Suite
    participant API as Query Endpoint
    participant DB as Database Connector

    Test->>API: POST /query (ORDER BY column with NULLs)
    API->>DB: Execute SQL with ORDER BY (no explicit NULLS)
    DB-->>API: Results (NULLs ordered last)
    API-->>Test: Response (rows with NULLs last)
Loading
sequenceDiagram
    participant Core as Core Engine
    participant Config as Config Builder

    Core->>Config: Build session context
    Config->>Config: Set "datafusion.sql_parser.default_null_ordering" = "nulls_last"
    Config-->>Core: Session context with default null ordering
Loading

Estimated code review effort

3 (120 minutes)

Suggested labels

ci

Suggested reviewers

  • onlyjackfrost
  • douenergy

Poem

In the warren of code where the nulls used to roam,
Now "NULLS LAST" is the rule, wherever we comb.
From BigQuery to Oracle, MySQL to Postgres,
Our queries are tidy—no nulls in the mess!
🐇✨
A hop and a skip, our tests all agree:
The last shall be null, as neat as can be!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.6)
wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16c9c3c and 0b14820.

⛔ Files ignored due to path filters (1)
  • wren-core-py/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • ibis-server/app/model/connector.py (2 hunks)
  • ibis-server/tests/routers/v2/connector/test_bigquery.py (1 hunks)
  • ibis-server/tests/routers/v2/connector/test_mssql.py (3 hunks)
  • ibis-server/tests/routers/v2/connector/test_mysql.py (1 hunks)
  • ibis-server/tests/routers/v2/connector/test_postgres.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/bigquery/test_query.py (3 hunks)
  • ibis-server/tests/routers/v3/connector/oracle/conftest.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/oracle/test_query.py (2 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/conftest.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/test_query.py (2 hunks)
  • wren-core-legacy/pom.xml (2 hunks)
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java (1 hunks)
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/QueryUtil.java (1 hunks)
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java (10 hunks)
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestStatementBuilder.java (3 hunks)
  • wren-core-legacy/wren-server/pom.xml (1 hunks)
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java (2 hunks)
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java (1 hunks)
  • wren-core-legacy/wren-tests/pom.xml (0 hunks)
  • wren-core-legacy/wren-tests/src/main/java/io/wren/testing/TestingWrenServer.java (0 hunks)
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResource.java (1 hunks)
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java (3 hunks)
  • wren-core/core/src/mdl/context.rs (1 hunks)
  • wren-core/core/src/mdl/mod.rs (1 hunks)
💤 Files with no reviewable changes (2)
  • wren-core-legacy/wren-tests/pom.xml
  • wren-core-legacy/wren-tests/src/main/java/io/wren/testing/TestingWrenServer.java
✅ Files skipped from review due to trivial changes (3)
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/QueryUtil.java
  • wren-core-legacy/pom.xml
🚧 Files skipped from review as they are similar to previous changes (19)
  • ibis-server/tests/routers/v3/connector/oracle/conftest.py
  • wren-core/core/src/mdl/context.rs
  • wren-core-legacy/wren-server/pom.xml
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResource.java
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java
  • ibis-server/app/model/connector.py
  • ibis-server/tests/routers/v3/connector/postgres/conftest.py
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestStatementBuilder.java
  • ibis-server/tests/routers/v3/connector/bigquery/test_query.py
  • ibis-server/tests/routers/v3/connector/oracle/test_query.py
  • wren-core/core/src/mdl/mod.rs
  • ibis-server/tests/routers/v2/connector/test_postgres.py
  • ibis-server/tests/routers/v2/connector/test_bigquery.py
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java
  • ibis-server/tests/routers/v2/connector/test_mysql.py
  • ibis-server/tests/routers/v2/connector/test_mssql.py
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java
  • ibis-server/tests/routers/v3/connector/postgres/test_query.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: clippy
  • GitHub Check: cargo test (amd64)
  • GitHub Check: check Cargo.toml formatting
  • GitHub Check: test
  • GitHub Check: cargo test (macos-aarch64)
  • GitHub Check: cargo test (macos)
  • GitHub Check: cargo test (win64)
  • GitHub Check: ci
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added core bigquery ibis rust Pull requests that update Rust code python Pull requests that update Python code labels Jul 21, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java (1)

22-34: LGTM: OpenTelemetry module implementation is correct.

The implementation properly creates a no-op OpenTelemetry instance and binds it to the Guice injector. This approach correctly addresses the Airlift 305 tracing requirements while maintaining minimal overhead.

The comment on line 22 clearly explains the rationale for this module.

Consider for future enhancement: Making this configurable so users can optionally enable real tracing when needed, rather than always using no-op.

wren-core-legacy/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java (1)

1195-1206: Consider improving code formatting and comment placement.

The logic consolidation is correct and aligns with the PR objective. However, the comment placement between case labels could be improved for better readability.

Consider this formatting improvement:

            switch (input.getNullOrdering()) {
                case FIRST:
                    builder.append(" NULLS FIRST");
                    break;
+               // Wren engine prefers to use "NULLS LAST" by default null ordering
                case LAST:
-                    // wren engine prefer to use "NULLS LAST" by default null ordering
                case UNDEFINED:
                    builder.append(" NULLS LAST");
                    break;
                default:
                    throw new UnsupportedOperationException("unknown null ordering: " + input.getNullOrdering());
            }

This places the comment before the relevant cases and improves readability while maintaining the same functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb53f33 and 007071a.

⛔ Files ignored due to path filters (1)
  • wren-core-py/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • ibis-server/tests/routers/v2/connector/test_bigquery.py (1 hunks)
  • ibis-server/tests/routers/v2/connector/test_mysql.py (1 hunks)
  • ibis-server/tests/routers/v2/connector/test_postgres.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/bigquery/test_query.py (3 hunks)
  • ibis-server/tests/routers/v3/connector/oracle/conftest.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/oracle/test_query.py (2 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/conftest.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/test_query.py (2 hunks)
  • wren-core-legacy/pom.xml (2 hunks)
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java (1 hunks)
  • wren-core-legacy/trino-parser/src/main/java/io/trino/sql/QueryUtil.java (1 hunks)
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java (10 hunks)
  • wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestStatementBuilder.java (3 hunks)
  • wren-core-legacy/wren-server/pom.xml (1 hunks)
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java (2 hunks)
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java (1 hunks)
  • wren-core-legacy/wren-tests/pom.xml (0 hunks)
  • wren-core-legacy/wren-tests/src/main/java/io/wren/testing/TestingWrenServer.java (0 hunks)
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResource.java (1 hunks)
  • wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java (3 hunks)
  • wren-core/core/src/mdl/context.rs (1 hunks)
  • wren-core/core/src/mdl/mod.rs (1 hunks)
💤 Files with no reviewable changes (2)
  • wren-core-legacy/wren-tests/pom.xml
  • wren-core-legacy/wren-tests/src/main/java/io/wren/testing/TestingWrenServer.java
🧰 Additional context used
🧠 Learnings (3)
ibis-server/tests/routers/v3/connector/postgres/test_query.py (1)
Learnt from: goldmedal
PR: Canner/wren-engine#1014
File: wren-core-base/tests/data/mdl.json:8-9
Timestamp: 2024-12-26T04:12:10.888Z
Learning: In test JSON files used for serialization/deserialization, it is acceptable to have empty table references, per the user’s clarification.
ibis-server/tests/routers/v3/connector/oracle/test_query.py (1)
Learnt from: goldmedal
PR: Canner/wren-engine#1014
File: wren-core-base/tests/data/mdl.json:8-9
Timestamp: 2024-12-26T04:12:10.888Z
Learning: In test JSON files used for serialization/deserialization, it is acceptable to have empty table references, per the user’s clarification.
ibis-server/tests/routers/v3/connector/bigquery/test_query.py (1)
Learnt from: goldmedal
PR: Canner/wren-engine#1014
File: wren-core-base/tests/data/mdl.json:8-9
Timestamp: 2024-12-26T04:12:10.888Z
Learning: In test JSON files used for serialization/deserialization, it is acceptable to have empty table references, per the user’s clarification.
🧬 Code Graph Analysis (6)
wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java (1)
wren-core-legacy/wren-server/src/main/java/io/wren/server/module/OpenTelemetryModule.java (1)
  • OpenTelemetryModule (23-34)
ibis-server/tests/routers/v3/connector/postgres/test_query.py (8)
ibis-server/tests/routers/v3/connector/bigquery/test_query.py (2)
  • test_order_by_nulls_last (353-388)
  • manifest_str (76-77)
ibis-server/tests/routers/v2/connector/test_bigquery.py (2)
  • test_order_by_nulls_last (497-511)
  • manifest_str (73-74)
ibis-server/tests/routers/v2/connector/test_mysql.py (2)
  • test_order_by_nulls_last (478-493)
  • manifest_str (83-84)
ibis-server/tests/routers/v3/connector/oracle/test_query.py (2)
  • test_order_by_nulls_last (225-260)
  • manifest_str (82-83)
ibis-server/tests/routers/v2/connector/test_postgres.py (2)
  • test_order_by_nulls_last (1029-1044)
  • manifest_str (125-126)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v3/connector/postgres/test_fallback_v2.py (1)
  • manifest_str (30-31)
ibis-server/tests/routers/v3/connector/postgres/conftest.py (1)
  • connection_info (45-52)
wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java (2)
wren-core-base/manifest-macro/src/lib.rs (1)
  • manifest (26-56)
mcp-server/app/dto.py (1)
  • Manifest (41-47)
ibis-server/tests/routers/v2/connector/test_mysql.py (4)
ibis-server/tests/routers/v2/connector/test_bigquery.py (2)
  • test_order_by_nulls_last (497-511)
  • manifest_str (73-74)
ibis-server/tests/routers/v2/connector/test_postgres.py (2)
  • test_order_by_nulls_last (1029-1044)
  • manifest_str (125-126)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v2/connector/test_clickhouse.py (1)
  • manifest_str (109-110)
ibis-server/tests/routers/v3/connector/oracle/test_query.py (7)
ibis-server/tests/routers/v3/connector/bigquery/test_query.py (2)
  • test_order_by_nulls_last (353-388)
  • manifest_str (76-77)
ibis-server/tests/routers/v2/connector/test_bigquery.py (2)
  • test_order_by_nulls_last (497-511)
  • manifest_str (73-74)
ibis-server/tests/routers/v2/connector/test_mysql.py (2)
  • test_order_by_nulls_last (478-493)
  • manifest_str (83-84)
ibis-server/tests/routers/v2/connector/test_postgres.py (2)
  • test_order_by_nulls_last (1029-1044)
  • manifest_str (125-126)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v3/connector/oracle/test_function.py (1)
  • manifest_str (31-32)
ibis-server/tests/routers/v3/connector/oracle/conftest.py (1)
  • connection_info (102-111)
ibis-server/tests/routers/v3/connector/bigquery/test_query.py (5)
ibis-server/tests/routers/v3/connector/oracle/test_query.py (2)
  • test_order_by_nulls_last (225-260)
  • manifest_str (82-83)
ibis-server/tests/routers/v3/connector/postgres/test_query.py (2)
  • test_order_by_nulls_last (726-761)
  • manifest_str (134-135)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v3/connector/bigquery/test_functions.py (1)
  • manifest_str (31-32)
ibis-server/tests/routers/v3/connector/bigquery/conftest.py (1)
  • connection_info (24-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: ci
  • GitHub Check: cargo test (macos)
  • GitHub Check: cargo test (macos-aarch64)
  • GitHub Check: cargo check
  • GitHub Check: cargo test (win64)
  • GitHub Check: test
🔇 Additional comments (40)
wren-core-legacy/wren-server/pom.xml (1)

57-60: LGTM: OpenTelemetry dependency addition is correct.

The addition of the io.opentelemetry:opentelemetry-api dependency properly supports the new OpenTelemetryModule introduced in this change set.

wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java (2)

29-29: LGTM: Import replacement is correct.

The import change from EventModule to OpenTelemetryModule properly aligns with the Airlift 305 upgrade and tracing infrastructure migration.


48-48: LGTM: Module instantiation correctly updated.

The replacement of EventModule with OpenTelemetryModule in the module list is consistent with the import change and properly supports the new tracing infrastructure.

wren-core-legacy/pom.xml (1)

67-67: Manual Compatibility Verification: Airlift 305

We’ve confirmed extensive use of Airlift APIs throughout the codebase—upgrading from 269 to 305 may introduce breaking changes or renamed/removed modules. Please cross-check Airlift 305 release notes for any API or module changes (e.g., HttpServerModule, JaxrsModule, JsonModule, NodeModule, AbstractConfigurationAwareModule, ConfigBinder).

Key areas to review:

  • wren-core-legacy/wren-server/src/main/java/io/wren/server/WrenServer.java
  • wren-core-legacy/wren-server/src/main/java/io/wren/server/module/*Module.java
  • wren-core-legacy/wren-tests/** (all classes importing io.airlift.*)
  • wren-core-legacy/wren-base/** and wren-main/** (configuration & logging imports)

No EventModule references remain.

wren-core/core/src/mdl/context.rs (1)

65-68: LGTM! Correctly implements default NULLS LAST policy.

The configuration setting properly establishes the default null ordering behavior in DataFusion's SQL parser. This change aligns with the PR objective and ensures consistent null ordering across the query engine.

ibis-server/tests/routers/v3/connector/oracle/conftest.py (1)

91-96: LGTM! Well-structured test fixture for null ordering validation.

The null_test table setup correctly provides test data with NULL values to support null ordering behavior tests. The use of quoted identifiers and proper Oracle SQL syntax is appropriate.

wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResource.java (1)

100-100: LGTM! Improved error message matching robustness.

The simplified regex pattern with the DOTALL flag ((?s)) makes the test more resilient to formatting changes in error messages while maintaining the essential validation.

wren-core-legacy/trino-parser/src/main/java/io/trino/sql/QueryUtil.java (1)

174-174: LGTM! Correctly implements default NULLS LAST for ascending sorts.

The change from NullOrdering.UNDEFINED to NullOrdering.LAST properly establishes the default null ordering behavior for ascending sorts, directly supporting the PR objective.

ibis-server/tests/routers/v3/connector/postgres/conftest.py (1)

32-38: LGTM! Consistent test fixture for null ordering validation.

The null_test table setup provides appropriate test data with NULL values for validating null ordering behavior. The implementation is clean and consistent with similar fixtures across other connectors.

ibis-server/tests/routers/v2/connector/test_bigquery.py (1)

497-511: LGTM! Test correctly validates default NULLS LAST behavior.

The test implementation properly verifies that when no explicit null ordering is specified, null values are ordered last by default. The test data and assertions are well-structured to validate this behavior across the BigQuery connector.

ibis-server/tests/routers/v2/connector/test_postgres.py (1)

1029-1044: Confirm PostgreSQL default null ordering isn’t masking connector-specific behavior.

We ran repository-wide searches for any explicit NULLS FIRST/LAST clauses and found no matches. As PostgreSQL by default sorts NULL values last in ascending order, this test may simply be exercising native behavior rather than a connector override.
Please verify that:

  • The goal is to enforce or customize null ordering in the PostgreSQL connector (not just rely on the database default).
  • If so, ensure the connector layer explicitly applies NULLS LAST (or document why the default is sufficient).
  • Otherwise, consider whether this test is redundant.
ibis-server/tests/routers/v2/connector/test_mysql.py (1)

478-494: LGTM! Test correctly validates default NULLS LAST ordering behavior.

The test implementation is consistent with similar tests across other connectors (BigQuery, Postgres, Oracle) and correctly validates that NULL values are ordered last by default when no explicit NULLS FIRST/LAST is specified. The inline VALUES clause approach provides a clean way to test this behavior without requiring additional test data setup.

wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestStatementBuilder.java (3)

20-20: Appropriate import addition for JUnit 5 @disabled annotation.


46-49: Good practice: Clear explanation for test disabling.

The comment clearly explains why the test is disabled - Wren engine doesn't support SQL-to-AST roundtrip conversion, which is a deliberate architectural divergence from Trino. This helps future maintainers understand the reasoning.


348-351: Consistent test disabling with clear rationale.

The same rationale and approach as the previous disabled test, maintaining consistency in the codebase.

ibis-server/tests/routers/v3/connector/oracle/test_query.py (2)

66-76: Well-structured test model for null ordering validation.

The "null_test" model is appropriately defined with simple integer and varchar columns to support null ordering tests. The table reference follows Oracle naming conventions.


225-260: Comprehensive null ordering test with both ASC and DESC scenarios.

The test implementation is thorough and well-structured:

  • Tests both ascending and descending order scenarios
  • Uses quoted identifiers in the second query, which is appropriate for Oracle
  • Properly disables DuckDB fallback to ensure Oracle connector behavior is tested
  • Expected results correctly validate that NULL values are ordered last in both cases
  • Consistent with similar tests in other v3 connectors (BigQuery)

This provides robust validation of the default NULLS LAST policy for Oracle.

wren-core-legacy/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java (16)

200-200: LGTM! Import addition is correct.

The import of @Disabled annotation is properly added to support disabling specific test methods throughout the file.


251-251: LGTM! Static import addition supports null ordering changes.

The static import of LAST from SortItem.NullOrdering is correctly added to support the updated test expectations for default null ordering behavior.


642-643: LGTM! Test properly disabled for Wren engine compatibility.

The @Disabled annotation is correctly applied to exclude this test that doesn't work with Wren engine's SQL-to-AST roundtrip behavior.


1147-1148: LGTM! Clear explanatory comments added.

The comments provide valuable context explaining why tests are disabled due to Wren engine's different SQL-to-AST roundtrip expectations.


1149-1150: LGTM! Test properly disabled for consistency.

The @Disabled annotation is consistently applied to the testSelectWithOrderBy method following the same pattern as other disabled tests.


2769-2770: LGTM! Consistent explanatory comments.

The comments maintain consistency with other disabled test explanations throughout the file.


2771-2772: LGTM! Test disabling follows established pattern.

The @Disabled annotation is consistently applied to the testShowStatsForQuery method.


2994-2995: LGTM! Documentation consistency maintained.

The explanatory comments are consistently applied across all disabled tests.


2996-2997: LGTM! Consistent test disabling pattern.

The @Disabled annotation is properly applied to the testAggregationWithOrderBy method.


3006-3006: LGTM! Null ordering standardized to LAST.

The change from UNDEFINED to LAST for SortItem.NullOrdering aligns with the PR objective to standardize default null ordering to "NULLS LAST" behavior.


3018-3018: LGTM! Consistent null ordering standardization.

The change from UNDEFINED to LAST maintains consistency with the null ordering standardization across test expectations.


3480-3481: LGTM! Consistent documentation pattern.

The explanatory comments follow the same pattern as other disabled tests in the file.


3482-3483: LGTM! Test disabling pattern maintained.

The @Disabled annotation is consistently applied to the testWindowClause method.


3506-3506: LGTM! Null ordering change maintains consistency.

The change from UNDEFINED to LAST in the OrderBy construction is consistent with the null ordering standardization throughout the file.


3513-3514: LGTM! Documentation consistency maintained.

The explanatory comments are consistently applied across all disabled tests.


3515-3516: LGTM! Final test disabling completes the pattern.

The @Disabled annotation is consistently applied to the testWindowFrameWithPatternRecognition method, completing the pattern of disabled tests.

wren-core-legacy/wren-tests/src/test/java/io/wren/testing/TestMDLResourceV2.java (2)

309-309: LGTM: Clean formatting improvements

These formatting fixes improve code consistency by removing trailing spaces and cleaning up string literals.

Also applies to: 329-329, 361-362


364-473: Excellent test coverage for default null ordering behavior

This test comprehensively validates the new default "NULLS LAST" policy across three key scenarios:

  1. Default ascending orderASC NULLS LAST
  2. Descending orderDESC NULLS LAST
  3. Explicit nulls firstASC NULLS FIRST

The test structure follows established patterns and provides thorough verification of the SQL generation logic. The assertions correctly validate that the default behavior applies "NULLS LAST" when no explicit null ordering is specified, while respecting explicit "NULLS FIRST" directives.

ibis-server/tests/routers/v3/connector/postgres/test_query.py (2)

110-120: Well-structured model definition for null ordering tests

The null_test model follows the established manifest pattern and provides the necessary table structure for testing null ordering behavior. The simple schema with id and letter columns is appropriate for the test scenarios.


726-761: Integration test for NULL ordering is correctly set up

The null_test fixture in ibis-server/tests/routers/v3/connector/postgres/conftest.py confirms:

  • Table creation: CREATE TABLE null_test (id INT, letter TEXT)
  • Data insertion: (1, 'one'), (2, 'two'), (NULL, 'three')

With the setup verified, the test_order_by_nulls_last integration test is valid and can be approved.

wren-core/core/src/mdl/mod.rs (1)

2872-2931: Excellent test coverage for default NULLS LAST behavior!

This test function comprehensively validates the default null ordering functionality across multiple scenarios:

  • Basic ORDER BY (defaulting to ASC NULLS LAST)
  • Explicit ASC/DESC directions (both get NULLS LAST by default)
  • Explicit NULLS FIRST/LAST preservation
  • Multiple column ordering with mixed directions
  • Complex scenarios with both default and explicit null ordering

The use of snapshot testing ensures exact SQL transformation verification, which is critical for this feature. The test implementation aligns perfectly with the PR objective of standardizing default null ordering to "NULLS LAST" across connectors.

ibis-server/tests/routers/v3/connector/bigquery/test_query.py (2)

7-7: LGTM: Import addition is correct.

The import of X_WREN_FALLBACK_DISABLE is properly placed and necessary for the new null ordering test to ensure BigQuery native behavior is tested.


60-70: LGTM: Model definition is properly structured.

The "null_test" model definition correctly follows the established manifest pattern with appropriate column types for testing null ordering behavior.

@goldmedal
Copy link
Contributor Author

BigQuery has been tested locally

poetry run pytest -m 'bigquery'
========================================================================================================================== test session starts ===========================================================================================================================
platform darwin -- Python 3.11.11, pytest-8.4.1, pluggy-1.5.0
rootdir: /Users/jax/git/wren-engine/ibis-server
configfile: pyproject.toml
plugins: anyio-4.9.0
collected 392 items / 353 deselected / 39 selected                                                                                                                                                                                                                       

tests/routers/v2/connector/test_bigquery.py .......................                                                                                                                                                                                                [ 58%]
tests/routers/v3/connector/bigquery/test_functions.py ...                                                                                                                                                                                                          [ 66%]
tests/routers/v3/connector/bigquery/test_query.py .............  

@goldmedal goldmedal requested a review from douenergy July 21, 2025 04:05
@goldmedal goldmedal force-pushed the feat/default-null-last branch from 16c9c3c to 0b14820 Compare July 21, 2025 06:30
@goldmedal
Copy link
Contributor Author

BigQuery has been tested locally. Let's ignore the CI bigquery failed.

@douenergy douenergy merged commit df63b73 into Canner:main Jul 21, 2025
15 of 16 checks passed
@douenergy
Copy link
Contributor

Thanks @goldmedal

@goldmedal goldmedal deleted the feat/default-null-last branch July 22, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bigquery core ibis python Pull requests that update Python code rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants