You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2024/11/30 12:52:22 UTC
[PR] Minor: Simplify IdentTaker [datafusion]
alamb opened a new pull request, #13609:
URL: https://github.com/apache/datafusion/pull/13609
## Which issue does this PR close?
Follow on to https://github.com/apache/datafusion/pull/13605
## Rationale for this change
As suggested by @jonahgao on https://github.com/apache/datafusion/pull/13605/files#r1863695929
> Not related to the current PR, maybe we can move IdentNormalizer into IdentTaker to simplify take() and avoid creating normalizer every time.
## What changes are included in this PR?
1. Move IdentNormalizer into IdentTaker
## Are these changes tested?
Yes, by CI
## Are there any user-facing changes?
No, these are all internal apis
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Minor: Simplify `IdentTaker` [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #13609:
URL: https://github.com/apache/datafusion/pull/13609#discussion_r1864256038
##########
datafusion/sql/src/planner.rs:
##########
@@ -622,21 +622,37 @@ pub fn object_name_to_table_reference(
idents_to_table_reference(idents, enable_normalization)
}
-struct IdentTaker(Vec<Ident>);
+struct IdentTaker {
+ normalizer: IdentNormalizer,
+ idents: Vec<Ident>,
+}
+
/// Take the next identifier from the back of idents, panic'ing if
/// there are none left
impl IdentTaker {
- fn take(&mut self, enable_normalization: bool) -> String {
- let ident = self.0.pop().expect("no more identifiers");
- IdentNormalizer::new(enable_normalization).normalize(ident)
+ fn new(idents: Vec<Ident>, enable_normalization: bool) -> Self {
+ Self {
+ normalizer: IdentNormalizer::new(enable_normalization),
+ idents,
+ }
+ }
+
+ fn take(&mut self) -> String {
+ let ident = self.idents.pop().expect("no more identifiers");
+ self.normalizer.normalize(ident)
+ }
+
+ /// Returns the number of remaining identifiers
+ fn len(&self) -> usize {
Review Comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Minor: Simplify IdentTaker [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #13609:
URL: https://github.com/apache/datafusion/pull/13609#discussion_r1864245500
##########
datafusion/sql/src/planner.rs:
##########
@@ -622,21 +622,37 @@ pub fn object_name_to_table_reference(
idents_to_table_reference(idents, enable_normalization)
}
-struct IdentTaker(Vec<Ident>);
+struct IdentTaker {
+ normalizer: IdentNormalizer,
Review Comment:
the point of the PR is to move normalizer into `IdentTaker` so it isn't created again on each row
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Minor: Simplify `IdentTaker` [datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on PR #13609:
URL: https://github.com/apache/datafusion/pull/13609#issuecomment-2509734384
Thanks @jonahgao for reviewing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Minor: Simplify `IdentTaker` [datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H merged PR #13609:
URL: https://github.com/apache/datafusion/pull/13609
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org