You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "goldmedal (via GitHub)" <gi...@apache.org> on 2024/05/28 13:19:22 UTC

[PR] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

goldmedal opened a new pull request, #10696:
URL: https://github.com/apache/datafusion/pull/10696

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #10695 .
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   Fix `median`, `first_value` and `last_value`
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   Yes
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   No
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#discussion_r1617756810


##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -72,7 +72,7 @@ impl Default for FirstValue {
 impl FirstValue {
     pub fn new() -> Self {
         Self {
-            aliases: vec![String::from("first_value")],
+            aliases: vec![],

Review Comment:
   A minor comment is we can probably remove the `aliases` field entirely and just return an empty slice
   
   ```rust
       fn aliases(&self) -> &[String] {
           &[]
       }
   ```



-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#discussion_r1618065968


##########
datafusion/functions-aggregate/src/lib.rs:
##########
@@ -109,13 +109,13 @@ mod tests {
         let mut names = HashSet::new();
         for func in all_default_aggregate_functions() {
             assert!(
-                names.insert(func.name().to_string()),
+                names.insert(func.name().to_string().to_lowercase()),

Review Comment:
   Oh, it is the test, then it is fine 



-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#discussion_r1618012266


##########
datafusion/functions-aggregate/src/lib.rs:
##########
@@ -109,13 +109,13 @@ mod tests {
         let mut names = HashSet::new();
         for func in all_default_aggregate_functions() {
             assert!(
-                names.insert(func.name().to_string()),
+                names.insert(func.name().to_string().to_lowercase()),

Review Comment:
   Can we not convert to lowercase here? If someone changes the name to uppercase again, the function in the function map is not the same as the function name, and it is easy to introduce a bug.



-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#discussion_r1618012266


##########
datafusion/functions-aggregate/src/lib.rs:
##########
@@ -109,13 +109,13 @@ mod tests {
         let mut names = HashSet::new();
         for func in all_default_aggregate_functions() {
             assert!(
-                names.insert(func.name().to_string()),
+                names.insert(func.name().to_string().to_lowercase()),

Review Comment:
   Can we not convert to lowercase here? If someone changes the name to uppercase again, the function in the function map (lowercase) is not the same as the function name (uppercase), and it is easy to introduce a bug.



-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on code in PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#discussion_r1618064435


##########
datafusion/functions-aggregate/src/lib.rs:
##########
@@ -109,13 +109,13 @@ mod tests {
         let mut names = HashSet::new();
         for func in all_default_aggregate_functions() {
             assert!(
-                names.insert(func.name().to_string()),
+                names.insert(func.name().to_string().to_lowercase()),

Review Comment:
   Thanks @jayzhan211 
   I think `to_lowercase` is used to ensure that the function name and its alias won't be duplicates when case-insensitive (e.g., unquoted identifier). If someone changes the function name to uppercase, the test will pass. However, they may find that they can't query this function in lowercase. They might try to add a lowercase alias or change the function name back to lowercase. I think this is the purpose of this test.



-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "goldmedal (via GitHub)" <gi...@apache.org>.
goldmedal commented on PR #10696:
URL: https://github.com/apache/datafusion/pull/10696#issuecomment-2136669381

   Thanks again @alamb @jayzhan211 


-- 
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] Remove redundant upper case aliases for `median`, `first_value` and `last_value` [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 merged PR #10696:
URL: https://github.com/apache/datafusion/pull/10696


-- 
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