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(parser): support to parse param in parser #8113

Merged
merged 3 commits into from Feb 26, 2023
Merged

Conversation

ZENOTME
Copy link
Contributor

@ZENOTME ZENOTME commented Feb 22, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

To complete #8112, we need to support to parse param syntax like ('$1','$1::int') in parser first.

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #8113 (4a21032) into main (500cdf4) will decrease coverage by 0.01%.
The diff coverage is 95.00%.

@@            Coverage Diff             @@
##             main    #8113      +/-   ##
==========================================
- Coverage   71.78%   71.78%   -0.01%     
==========================================
  Files        1130     1130              
  Lines      181489   181508      +19     
==========================================
+ Hits       130277   130290      +13     
- Misses      51212    51218       +6     
Flag Coverage Δ
rust 71.78% <95.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sqlparser/src/parser.rs 91.38% <85.71%> (-0.02%) ⬇️
src/sqlparser/src/ast/mod.rs 87.55% <100.00%> (+0.01%) ⬆️
src/sqlparser/src/tokenizer.rs 93.86% <100.00%> (+0.07%) ⬆️
src/source/src/row_id.rs 90.90% <0.00%> (-1.14%) ⬇️
...torage/src/hummock/local_version/pinned_version.rs 88.75% <0.00%> (-0.63%) ⬇️
src/meta/src/hummock/mock_hummock_meta_client.rs 65.46% <0.00%> (-0.52%) ⬇️
...frontend/src/scheduler/hummock_snapshot_manager.rs 60.00% <0.00%> (-0.48%) ⬇️
src/stream/src/executor/aggregation/minput.rs 96.25% <0.00%> (-0.11%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ZENOTME ZENOTME requested review from BugenZhao and st1page and removed request for BugenZhao February 22, 2023 06:24
Comment on lines +594 to +622
'$' => {
if let Some(parameter) = self.tokenize_parameter(chars) {
Ok(Some(parameter))
} else {
Ok(Some(Token::Char('$')))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI in PostgreSQL $ can also start a dollar-quoted string constant (upstream sqlparser-rs/sqlparser-rs#772).

But extending the support later would not break common use cases.

Comment on lines 587 to 592
let data_type = if let Token::DoubleColon = self.peek_token() {
self.next_token();
Some(self.parse_data_type()?)
} else {
None
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we include the cast as part of parameter? Is it possible to be CAST($1 AS int) rather than $1::int?

One idea is to just parse the outer part as a normal cast, which includes both CAST(AS) and ::. Then during binder type inference, just treat $1 as unknown (same as null and '12', or typed like null::date, '12'::interval, interval '12').

^ This can also be a refactor after we have build the whole code path of this paramater-with-type first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the right way.🤣 Let's do it now.

@xxchan
Copy link
Member

xxchan commented Feb 26, 2023

I updated this PR because I was playing with buildkite & merge queue. Sorry if that bothered. 🤪🙏

@xxchan xxchan disabled auto-merge February 26, 2023 11:59
@xxchan xxchan added this pull request to the merge queue Feb 26, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 26, 2023
@xxchan xxchan added this pull request to the merge queue Feb 26, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 26, 2023
@xxchan xxchan added this pull request to the merge queue Feb 26, 2023
Merged via the queue into main with commit 3aa56b0 Feb 26, 2023
@xxchan xxchan deleted the zj/support_param_in_parse branch February 26, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants