Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): sync DataFusion for the latest SQL syntax #1017

Merged

Conversation

goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Dec 27, 2024

Description

Copy link

coderabbitai bot commented Dec 27, 2024

Walkthrough

This pull request introduces several modifications across the Wren Core project, focusing on SQL expression handling, dependency updates, and refinements in function signatures. The changes primarily involve updating the datafusion dependency, modifying how wildcard options and array element access are processed, and adjusting type signatures for user-defined functions. The modifications aim to improve the SQL parsing and transformation capabilities of the Wren MDL framework.

Changes

File Change Summary
wren-core/Cargo.toml Updated datafusion dependency branch from wren/support-array-struct to wren/foward-to-compund-access
wren-core/core/src/logical_plan/analyze/plan.rs Modified ModelPlanNodeBuilder::build method to use boxed WildcardOptions and improved error handling
wren-core/core/src/mdl/dialect/utils.rs Added Span import and updated scalar_function_to_sql_internal with span and uses_odbc_syntax fields
wren-core/core/src/mdl/dialect/wren_dialect.rs Updated array element access with CompoundFieldAccess and added span to identifier creation
wren-core/core/src/mdl/function.rs Corrected type signature from TypeSignature::NullAry to TypeSignature::Nullary for UDFs
wren-core/core/src/mdl/mod.rs Enhanced SQL expression handling with ExprWithAlias and updated sql_to_expr method return type
ibis-server/tests/conftest.py Incremented DATAFUSION_FUNCTION_COUNT from 270 to 271
ibis-server/tests/routers/v3/connector/postgres/test_functions.py Adjusted assertion in test_function_list to expect DATAFUSION_FUNCTION_COUNT + 34
wren-core-py/tests/test_modeling_core.py Updated assertions in test_read_function_list to expect increased function counts

Sequence Diagram

sequenceDiagram
    participant Parser as SQL Parser
    participant Dialect as WrenDialect
    participant MDL as WrenMDL
    
    Parser->>Dialect: Parse SQL Expression
    Dialect->>Dialect: Process Array Access
    Dialect->>Dialect: Handle Identifiers
    Dialect->>MDL: Transform Expression
    MDL->>MDL: Infer Source Column
    MDL-->>Parser: Return Transformed Expression with Alias
Loading

Possibly Related PRs

Suggested Reviewers

  • wwwy3y3

Poem

🐰 In the realm of Wren's core delight,
SQL expressions dance with might,
Branches shift, and parsers gleam,
Transforming data like a dream!
Hop along the coding trail, where magic never fails! 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 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 22da36d and f7998b5.

⛔ Files ignored due to path filters (3)
  • ibis-server/poetry.lock is excluded by !**/*.lock
  • wren-core-py/Cargo.lock is excluded by !**/*.lock
  • wren-core-py/poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • ibis-server/tests/conftest.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/test_functions.py (1 hunks)
  • wren-core-py/tests/test_modeling_core.py (2 hunks)
🔇 Additional comments (4)
ibis-server/tests/conftest.py (1)

14-14: Incremented DATAFUSION_FUNCTION_COUNT to match new function additions.

This increment aligns with the additional function(s) introduced in the codebase, based on the PR description. Ensure that related tests referencing this constant remain consistent with this updated count.

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

60-60: Reduced offset from +35 to +34.

This change suggests that the function list now yields one less function when using the remote function list path. Verify that this is indeed the intended logic and that all references to this offset are appropriately updated in downstream tests or related modules.

wren-core-py/tests/test_modeling_core.py (2)

109-109: Increased expected function list length from 272 to 273.

This increment reflects an additional function being recognized by the system. Confirm that the relevant code accurately registers and handles all newly added functions.


121-121: Increased expected function list length from 270 to 271.

This additional function count should remain consistent across the entire test suite. Double-check any references to DATAFUSION_FUNCTION_COUNT or its variants to avoid discrepancies.
[approve]


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 dependencies Pull requests that update a dependency file rust Pull requests that update Rust code labels Dec 27, 2024
Copy link

@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: 0

🧹 Nitpick comments (1)
wren-core/Cargo.toml (1)

18-18: Fix typo in branch name: "foward" should be "forward"

The branch name contains a typo: wren/foward-to-compund-access should be wren/forward-to-compound-access.

-datafusion = { git = "https://github.com/goldmedal/datafusion.git", branch = "wren/foward-to-compund-access" }
+datafusion = { git = "https://github.com/goldmedal/datafusion.git", branch = "wren/forward-to-compound-access" }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bdf25ea and 22da36d.

📒 Files selected for processing (6)
  • wren-core/Cargo.toml (1 hunks)
  • wren-core/core/src/logical_plan/analyze/plan.rs (1 hunks)
  • wren-core/core/src/mdl/dialect/utils.rs (3 hunks)
  • wren-core/core/src/mdl/dialect/wren_dialect.rs (3 hunks)
  • wren-core/core/src/mdl/function.rs (3 hunks)
  • wren-core/core/src/mdl/mod.rs (3 hunks)
🔇 Additional comments (14)
wren-core/core/src/mdl/mod.rs (3)

20-20: Include ExprWithAlias for advanced SQL expression handling

This import is necessary for parsing expressions with potential aliases. The change looks correct and aligns with the updated usage in the codebase.


217-221: Utilize column alias if available during source column inference

Extracting expr and alias from ExprWithAlias and defaulting to the column's original name if the alias is missing is a sensible approach. This logic ensures that user-defined aliases are preserved whenever possible.


233-233: Confirm updated return type for SQL parsing

Changing the function signature to return ExprWithAlias is a breaking change for callers expecting a simple Expr. Please verify that all callers and downstream usages now accommodate the alias structure.

wren-core/core/src/mdl/dialect/utils.rs (3)

23-23: Import of Span from tokenizer

This addition appears necessary to populate the function or identifier span info. No issues detected.


59-59: Set function name span to empty

Using Span::empty() on the function name is appropriate for consistent construction of the Function AST node when no precise span data is available.


71-71: Explicitly disable ODBC syntax usage

Setting uses_odbc_syntax to false clarifies the function definition in contexts that need to avoid ODBC function parsing differences. Looks good.

wren-core/core/src/mdl/dialect/wren_dialect.rs (3)

26-27: Expanded imports for advanced SQL constructs

Importing AccessExpr, Array, Value, and Span broadens handling of complex expressions in the dialect. This is consistent with new expression parsing requirements.


122-124: Switch to CompoundFieldAccess for array elements

The move from Subscript to a CompoundFieldAccess containing a subscript index is well-structured. It improves clarity for expressions accessing array elements and ensures future extensibility for nested access patterns.


188-188: Provide empty span for quoted identifiers

Using Span::empty() for identifier creation is consistent with the approach used elsewhere, ensuring that quoting logic remains unaffected by uninitialized span data.

wren-core/core/src/mdl/function.rs (3)

74-74: Correct usage of TypeSignature::Nullary

Replacing NullAry with Nullary aligns with the revised DataFusion type signature enumeration. This fix prevents potential runtime mismatches.


118-118: Match updated DataFusion signature conventions

As above, adding TypeSignature::Nullary ensures the function signature is correctly recognized for no-argument function variants.


162-162: Unified UDF signature definitions

Consistently applying TypeSignature::Nullary in all custom UDF structs promotes uniformity and avoids unexpected errors during query planning.

wren-core/core/src/logical_plan/analyze/plan.rs (1)

296-296: Initialize wildcard options as a boxed struct

Converting WildcardOptions::default() into a boxed value supports recent DataFusion changes that expect a pointer-like structure. This update is safe and compatible with future expansions to wildcard behaviors.

wren-core/Cargo.toml (1)

18-18: Verify fork's sync status with upstream DataFusion

The dependency points to a fork of DataFusion. Let's verify its sync status with the upstream repository to ensure we're not diverging significantly.

✅ Verification successful

Fork is relatively in sync with upstream DataFusion

The fork appears to be well-maintained:

  • Created recently (May 2024) and last updated recently (Dec 2024)
  • Only 5 commits behind the upstream main branch
  • Contains 5 custom commits ahead of upstream, which is reasonable for a feature branch

The divergence is minimal and the fork is actively maintained, suggesting no immediate concerns with using this dependency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the fork's sync status with upstream DataFusion

# Get the latest commit from the specified branch in the fork
echo "Latest commit in the fork:"
gh api repos/goldmedal/datafusion/branches/wren/foward-to-compund-access --jq '.commit.sha'

# Get the fork's creation date and last update
echo "Fork details:"
gh api repos/goldmedal/datafusion --jq '[.created_at, .updated_at, .parent.full_name]'

# Check if the fork is ahead/behind the upstream main branch
gh api repos/goldmedal/datafusion/compare/apache:datafusion:main...goldmedal:datafusion:wren/foward-to-compund-access --jq '[.ahead_by, .behind_by]'

Length of output: 546

@github-actions github-actions bot added ibis python Pull requests that update Python code labels Dec 27, 2024
@goldmedal goldmedal requested a review from wwwy3y3 December 27, 2024 09:10
@goldmedal goldmedal merged commit 441743e into Canner:main Dec 27, 2024
18 checks passed
@goldmedal goldmedal deleted the chore/sync-datafusion-for-nested-access branch December 27, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core dependencies Pull requests that update a dependency file 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