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

Databricks: support for lambda functions #1257

Merged
merged 3 commits into from
May 6, 2024
Merged

Databricks: support for lambda functions #1257

merged 3 commits into from
May 6, 2024

Conversation

jmhain
Copy link
Contributor

@jmhain jmhain commented May 4, 2024

No description provided.

/// ```sql
/// SELECT transform(array(1, 2, 3), x -> x + 1); -- returns [2,3,4]
/// ```
fn supports_lambda_functions(&self) -> bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I was unsure of here is whether to enable this for the generic dialect. Our policy is to enable everything for generic, but this syntax conflicts with the -> operator from dialects like Postgres. So supporting this would be a breaking change of somewhat dubious benefit, since we both gain and lose a feature in generic. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this makes sense to not support via GenericDialect when there is a conflict

🤔 that might be a good thing to add to the policy https://github.com/sqlparser-rs/sqlparser-rs?tab=readme-ov-file#new-syntax

@coveralls
Copy link

coveralls commented May 4, 2024

Pull Request Test Coverage Report for Build 8952370439

Details

  • 84 of 93 (90.32%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.006%) to 89.193%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialect/databricks.rs 1 2 50.0%
src/dialect/mod.rs 1 2 50.0%
src/parser/mod.rs 25 27 92.59%
tests/sqlparser_databricks.rs 44 46 95.65%
tests/sqlparser_common.rs 5 8 62.5%
Files with Coverage Reduction New Missed Lines %
tests/sqlparser_common.rs 2 89.43%
Totals Coverage Status
Change from base Build 8944343130: 0.006%
Covered Lines: 24305
Relevant Lines: 27250

💛 - Coveralls

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! cc @alamb


let res = databricks().parse_sql_statements("SELECT EXISTS (");
assert_eq!(
// TODO: improve this error message...
Copy link
Contributor

Choose a reason for hiding this comment

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

was the todo meant for this PR or as a general improvement/followup with error reporting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the latter

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.

lGTM -- thank you @jmhain

databricks().verified_only_select(sql).projection[0]
);

databricks().verified_expr(
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty neat!

/// ```sql
/// SELECT transform(array(1, 2, 3), x -> x + 1); -- returns [2,3,4]
/// ```
fn supports_lambda_functions(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this makes sense to not support via GenericDialect when there is a conflict

🤔 that might be a good thing to add to the policy https://github.com/sqlparser-rs/sqlparser-rs?tab=readme-ov-file#new-syntax

@alamb
Copy link
Contributor

alamb commented May 6, 2024

Thanks again for the review @iffyio

@alamb alamb merged commit d9d69a2 into apache:main May 6, 2024
10 checks passed
@jmhain jmhain deleted the lambda branch May 6, 2024 17:42
JichaoS pushed a commit to luabase/sqlparser-rs that referenced this pull request May 7, 2024
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.

4 participants