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

refactor(binder): refactor BoundSelect #2220

Merged
merged 5 commits into from
Apr 29, 2022
Merged

Conversation

st1page
Copy link
Contributor

@st1page st1page commented Apr 29, 2022

What's changed and what's your intention?

  • add schma method for BoundQuery BoundSetExpr BoundSelect BoundValues
  • remove the names data_types and other method for the above struct
  • add construct function for BoundSelect, and ban constructing it with values directly, for its schema and select_items should be consistent

Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests

Refer to a related PR or issue link (optional)

#1958

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #2220 (c94aa04) into main (bc05efd) will increase coverage by 0.02%.
The diff coverage is 84.44%.

@@            Coverage Diff             @@
##             main    #2220      +/-   ##
==========================================
+ Coverage   71.00%   71.03%   +0.02%     
==========================================
  Files         654      654              
  Lines       82894    82892       -2     
==========================================
+ Hits        58862    58879      +17     
+ Misses      24032    24013      -19     
Flag Coverage Δ
rust 71.03% <84.44%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
src/common/src/catalog/schema.rs 82.83% <0.00%> (-1.90%) ⬇️
src/frontend/src/binder/values.rs 93.10% <0.00%> (-5.08%) ⬇️
src/frontend/src/binder/set_expr.rs 82.35% <66.66%> (+26.10%) ⬆️
src/frontend/src/binder/query.rs 98.30% <100.00%> (+9.59%) ⬆️
src/frontend/src/binder/relation/subquery.rs 96.15% <100.00%> (+0.15%) ⬆️
src/frontend/src/binder/select.rs 95.45% <100.00%> (+6.02%) ⬆️
src/common/src/types/ordered_float.rs 24.30% <0.00%> (+0.19%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

Thanks for the refactor! We definitely should not have these duplications.

/// The names returned by this [`BoundSelect`].
pub fn names(&self) -> Vec<String> {
self.aliases
pub fn create(
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels unnecessary to have a separate pub create. The only place to create BoundXxx is always bind_xxx.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Comment on lines 41 to 44
/// The types returned by this [`BoundQuery`].
pub fn data_types(&self) -> Vec<DataType> {
self.body.data_types()
self.schema().data_types()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we remove this to be consistent with others?

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 it might be ok, because the BoundQuery is the top of the Bound tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal. But someone may still add names on BoundQuery or data_types+names on BoundSetExpr/... later for the same reason: .data_types() is shorter than .schema().data_types(). Anyways we still achieve the goal on making select.schema consistent with select_exprs and aliases.

Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

lgtm

@st1page st1page enabled auto-merge (squash) April 29, 2022 04:49
@st1page st1page merged commit df29b13 into main Apr 29, 2022
@st1page st1page deleted the sts/refactor_bind_select branch April 29, 2022 05:01
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