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

Move TableConstraint to Constraints conversion #12953

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

findepi
Copy link
Member

@findepi findepi commented Oct 15, 2024

Reduce datafusion-common dependency on sqlparser

Reduce datafusion-common dependency on sqlparser
@github-actions github-actions bot added sql SQL Planner common Related to common crate labels Oct 15, 2024
Copy link
Contributor

@goldmedal goldmedal left a comment

Choose a reason for hiding this comment

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

Thanks @findepi it makes sense to me 👍 . Just one minor suggestion.

@@ -1262,6 +1263,74 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
)))
}

/// Convert each `TableConstraint` to corresponding `Constraint`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can improve the doc:

Suggested change
/// Convert each `TableConstraint` to corresponding `Constraint`
/// Convert each [TableConstraint] to corresponding [Constraint]

Copy link
Member Author

Choose a reason for hiding this comment

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

-> #12995

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @findepi and @goldmedal

I wonder how far we are from being able to remove the dependency entirely:

sqlparser = { workspace = true }

🤔

@alamb alamb merged commit 54bd26e into apache:main Oct 17, 2024
24 checks passed
@findepi findepi deleted the findepi/unparse-common branch October 18, 2024 08:44
@findepi
Copy link
Member Author

findepi commented Oct 18, 2024

thanks for review @goldmedal and the merge @alamb !

I wonder how far we are from being able to remove the dependency entirely:

datafusion/datafusion/common/Cargo.toml

That's a good question. Actually this is where i'd like to get to eventually. It should be possible to use datafusion without pulling sqlparser-rs dependency, which anyone with their own grammar should not use.

There is couple places where this is used.

  • DataFusionError::SQL -- this can be put behind a feature cfg, or maybe we add some dyn trait to DataFusionError to allow for dynamic binding
  • identifiers:
    • Column::from_qualified_name_ignore_case
    • Column::from_qualified_name
    • TableReference::parse_str

@alamb what would you suggest?

@alamb
Copy link
Contributor

alamb commented Oct 20, 2024

@alamb what would you suggest?

this can be put behind a feature cfg, or maybe we add some dyn trait to DataFusionError to allow for dynamic binding

A feature cfg is probably best I suppose

identifiers:

We could make a trait in datafusion-sql maybe

Though now that I see this list, I think maybe the extra code overhead of breaking this out won't really add much so perhaps it is not worth doing anything more at this time

@findepi
Copy link
Member Author

findepi commented Oct 22, 2024

The cost/benefit trade off depends on the perspective.
At SDF, we have our own SQL frontend(s), so sqlparser-rs dependency is redundant.
Being able to remove it would not only reduce binary size (probably not a lot), but more importantly, it would provide guarantees that some unwanted DF's SQL frontend related behavior isn't inherited (relates to #12723)

A feature cfg is probably best I suppose

i will give it a try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to common crate sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants