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

build(deps): upgrade sqlparser to 0.47.0 #10392

Merged
merged 41 commits into from
Jun 6, 2024
Merged

Conversation

tisonkun
Copy link
Member

@tisonkun tisonkun commented May 6, 2024

Upgrade sqlparser to 0.46.0 0.47.0. This should handle a few of breaking changes:

This is working in progress.

Blocked at sqlparser-rs/sqlparser-rs#1283.

@tisonkun
Copy link
Member Author

tisonkun commented May 7, 2024

@jmhain Thanks for your patch. I've applied it to this branch. Let us continue fixing the breaking changes here when we have time :D

@tisonkun
Copy link
Member Author

tisonkun commented May 8, 2024

Pushed a commit to handle other breaking changes. Now remains the JsonAccess and Agg func refactor. I'm still understanding how they are logically changed ...

Signed-off-by: tison <[email protected]>
operator: JsonOperator::Colon,
right,
} => {
SQLExpr::JsonAccess { value, path } => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@alamb @jmhain, do you have ideas on how we should modify this branch now?

Previously, we handled xxx::yyy in this branch. But now, JsonOperator::Colon no longer exists.

It seems to me that we should handle path.len() == 1 or path.len() == 2 and build a GetFieldAccess::ListRange as the original logic?

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed f29af9d to try it out.

The rest agg parts look much wider that I may hardly handle it by myself in a short time ..

@tisonkun
Copy link
Member Author

Seems that we should merge AggregateExpressionWithFilter and ArrayAgg handle logic into sql_function_to_expr.

@alamb
Copy link
Contributor

alamb commented May 14, 2024

I am going to give this PR a look to see if I can help unstick it

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label May 14, 2024
@alamb
Copy link
Contributor

alamb commented May 14, 2024

There is still a failure which I haven't had a chance to look into:

cargo test --test sqllogictests -- array
...
Running "array_query.slt"
Running "array.slt"
External error: query failed: DataFusion error: SQL error: ParserError("Expected variant object key name, found: 2")
[SQL] select make_array(1, 2, 3)[1:2], make_array(1.0, 2.0, 3.0)[2:3], make_array('h', 'e', 'l', 'l', 'o')[2:4];
at test_files/array.slt:859

Error: Execution("1 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test sqllogictests`

Caused by:
  process didn't exit successfully: `/Users/andrewlamb/Software/datafusion/target/debug/deps/sqllogictests-b3a0a4f302be541c array` (exit status: 1)

@@ -2795,3 +2795,10 @@ SELECT '2000-12-01 04:04:12' AT TIME ZONE 'America/New York';
# abbreviated timezone is not supported
statement error
SELECT '2023-03-12 02:00:00' AT TIME ZONE 'EDT';


# Test current_time without parentheses
Copy link
Contributor

Choose a reason for hiding this comment

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

While updating the code I realized I almost broke this, so I added a new test (also propose adding it to main here: #10509)

Signed-off-by: tison <[email protected]>
@tisonkun
Copy link
Member Author

tisonkun commented Jun 1, 2024

Since we're on the sqlparser-rs main branch now, I'd consider this patch as ready to merge.

But of course it's better to have a new release to sqlparser-rs and we move to that version. Hopefully it contains what it has now without new breaking changes :P

@tisonkun
Copy link
Member Author

tisonkun commented Jun 1, 2024

Window specific test failed. I don't have a windows env to debug ...

test cli_quick_test::case_4_set_batch_size ... FAILED

failures:

---- cli_quick_test::case_4_set_batch_size stdout ----
thread 'cli_quick_test::case_4_set_batch_size' panicked at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250:5:
Unexpected stdout, failed var == "[{\"name\":\"datafusion.execution.batch_size\",\"value\":\"1\"}]\n"
├── var: ""
└── var as str: 

command=`"D:\\a\\datafusion\\datafusion\\datafusion-cli\\target\\debug\\datafusion-cli.exe" "--command" "show datafusion.execution.batch_size" "--format" "json" "-q" "-b" "1"`
code=-1073741571
stdout=""
stderr=```

thread \'main\' has overflowed its stack

@alamb
Copy link
Contributor

alamb commented Jun 1, 2024

Since we're on the sqlparser-rs main branch now, I'd consider this patch as ready to merge.

But of course it's better to have a new release to sqlparser-rs and we move to that version. Hopefully it contains what it has now without new breaking changes :P

Thank you so much @tisonkun -- I agree

I will go make a sqlparser release now without any new changes

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.

I just released version 0.47.0 of sqlparser to crates.io: sqlparser-rs/sqlparser-rs#1251 / https://crates.io/crates/sqlparser/0.47.0

@alamb alamb changed the title build(deps): upgrade sqlparser to 0.46.0 build(deps): upgrade sqlparser to 0.47.0 Jun 1, 2024
}
}
/// RETURN or AS function body
pub function_body: Option<Expr>,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI @milenkovicm -- sqlparser changed how the body was represented so now this changes as well to a generic Expr

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for letting me know, @alamb

I just wonder if this change will diverge sqlparser from Postgres?

I guess function like this

CREATE FUNCTION strlen(name TEXT)
    RETURNS int LANGUAGE plrust AS
$$
    Ok(Some(name.unwrap().len() as i32))
$$;

Would not be possible without wrapping body with string

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we may need to add $$ string parsing support in sqlparser. I'll try and file a ticket later todday

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC we should previously support $$ function body. If it fails to parse now, it's a regression.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I added a test and made this syntax work in this pr in 8446851

@alamb
Copy link
Contributor

alamb commented Jun 1, 2024

Thanks @tisonkun -- I updated this PR to use the newly released 0.47.0 version of sqlparser-rs and updated the description. I suppose now we just need to debug the windows test (I have an idea) and we'll be good to go

@@ -334,6 +334,8 @@ jobs:
run: |
export PATH=$PATH:$HOME/d/protoc/bin
cargo test --lib --tests --bins --features avro,json,backtrace
# 8MB stack size otherwise the cli_integration test fails
Copy link
Contributor

Choose a reason for hiding this comment

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

I added this to workaround the issue @tisonkun reports #10392 (comment)

If it passes CI I will file a ticket to track

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems failure retains :<

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 reverting the change and will try something else

Copy link
Contributor

Choose a reason for hiding this comment

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

I disabled the test and filed #10793 to track

@alamb
Copy link
Contributor

alamb commented Jun 3, 2024

My plan for this PR is to disable the failing test on windows and file a ticket to investigate

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.

Ok, I think this one is now ready !

I'll plan to leave it open for another day in case anyone wants to comment. Otherwise I think we are ready to merge.

Thank you for the epic work @tisonkun and @jmhain -- great team effort 🦾

@tisonkun
Copy link
Member Author

tisonkun commented Jun 4, 2024

@alamb Thanks for your review and follow-up! @jmhain Thanks for your help :D

@alamb
Copy link
Contributor

alamb commented Jun 6, 2024

I did a final merge up from main to make sure we don't have any logical conflicts and then I plan to merge this PR

@alamb alamb merged commit f054586 into apache:main Jun 6, 2024
25 checks passed
@tisonkun tisonkun deleted the upgrade-sqlparser branch June 9, 2024 01:54
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* build(deps): upgrade sqlparser to 0.46.0

Signed-off-by: tison <[email protected]>

* function and cast fixups

* catchup refactors

Signed-off-by: tison <[email protected]>

* try migrate json expr

Signed-off-by: tison <[email protected]>

* Update for changes in sqlparser

* Update dependencies

* handle zero argument form

* fmt

* fixup more

Signed-off-by: tison <[email protected]>

* fixup more

Signed-off-by: tison <[email protected]>

* try use jmhain's branch

Signed-off-by: tison <[email protected]>

* fix compile FunctionArgumentClause exhausted

Signed-off-by: tison <[email protected]>

* fix compile set multi vars

Signed-off-by: tison <[email protected]>

* fix compile new string values

Signed-off-by: tison <[email protected]>

* fix compile set multi vars

Signed-off-by: tison <[email protected]>

* fix compile Subscript

Signed-off-by: tison <[email protected]>

* cargo fmt

Signed-off-by: tison <[email protected]>

* revert workaround on values

Signed-off-by: tison <[email protected]>

* Rework field access

* update lock

* fix doc

* try catchup new sqlparser version

Signed-off-by: tison <[email protected]>

* fixup timezone expr

Signed-off-by: tison <[email protected]>

* fixup params

Signed-off-by: tison <[email protected]>

* lock

Signed-off-by: tison <[email protected]>

* Update to sqlparser 0.47.0

* Update rust stack size on windows

* Revert "Update rust stack size on windows"

This reverts commit b5743d5.

* Add test + support for `$$` function definition

* Disable failing windows CI test

* fmt

* simplify test

* fmt

---------

Signed-off-by: tison <[email protected]>
Co-authored-by: Joey Hain <[email protected]>
Co-authored-by: Andrew Lamb <[email protected]>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants