You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jonathanc-n (via GitHub)" <gi...@apache.org> on 2025/06/13 07:56:32 UTC

[PR] fix: Fixed error handling for `generate_series/range` [datafusion]

jonathanc-n opened a new pull request, #16391:
URL: https://github.com/apache/datafusion/pull/16391

   ## 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 #.
   
   ## Rationale for this change
   I was reviewing #16388 and noticed that the linked issue had an incorrect error message. 
   <!--
    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?
   Correct the argument that was being returned and made the message more verbose. Also did a driveby clean on some nits for other error messages
   <!--
   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
   


-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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


-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,17 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_indice, expr) in exprs.iter().enumerate() {

Review Comment:
   I think `index` is a more standard singular form of `indices`
   
   so like
   
   ```suggestion
           for (expr_index, expr) in exprs.iter().enumerate() {
   ```



##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,17 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_indice, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {:?}",

Review Comment:
   I don' have any good suggestions
   
   I do think the `{:?}` might be hard to read for complex expressions. Maybe you could change this to have the display name instead. Something like
   
   ```suggestion
                           "Argument #{} must be an integer literal or null value, got {} ({:?})", expr_index, other, other,
   ```



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",
+                        expr_index + 1,
+                        other,

Review Comment:
   do we need to output `other` twice?



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",

Review Comment:
   ```suggestion
                           "Argument #{} must be an INTEGER or NULL, got {} ({:?})",
   ```



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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

   Fixed @alamb! Should be good now


-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

Posted by "jonathanc-n (via GitHub)" <gi...@apache.org>.
jonathanc-n commented on code in PR #16391:
URL: https://github.com/apache/datafusion/pull/16391#discussion_r2147445833


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",
+                        expr_index + 1,
+                        other,

Review Comment:
   I think @alamb's intention here was to have one less verbose and one with more information in case the user wants. 



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

Posted by "jonathanc-n (via GitHub)" <gi...@apache.org>.
jonathanc-n commented on code in PR #16391:
URL: https://github.com/apache/datafusion/pull/16391#discussion_r2147447123


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",
+                        expr_index + 1,
+                        other,

Review Comment:
   Yeah I think it would be, let me change that



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

Posted by "jonathanc-n (via GitHub)" <gi...@apache.org>.
jonathanc-n commented on code in PR #16391:
URL: https://github.com/apache/datafusion/pull/16391#discussion_r2144430651


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,17 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_indice, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {:?}",

Review Comment:
   Is there a better way to word this, `Argument #...` seems awkward 🤷 



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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

   Thanks again @jonathanc-n 


-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

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


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",
+                        expr_index + 1,
+                        other,

Review Comment:
   yeah, I'm checking the message in the slt test
   ```
   got Utf8\("foo"\) \(Literal\(Utf8\("foo"\), None\)\)
   ```
   would be that self explanatory to keep the last one only? 



-- 
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] fix: Fixed error handling for `generate_series/range` [datafusion]

Posted by "jonathanc-n (via GitHub)" <gi...@apache.org>.
jonathanc-n commented on code in PR #16391:
URL: https://github.com/apache/datafusion/pull/16391#discussion_r2147461767


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -197,11 +197,18 @@ impl TableFunctionImpl for GenerateSeriesFuncImpl {
         }
 
         let mut normalize_args = Vec::new();
-        for expr in exprs {
+        for (expr_index, expr) in exprs.iter().enumerate() {
             match expr {
                 Expr::Literal(ScalarValue::Null, _) => {}
                 Expr::Literal(ScalarValue::Int64(Some(n)), _) => normalize_args.push(*n),
-                _ => return plan_err!("First argument must be an integer literal"),
+                other => {
+                    return plan_err!(
+                        "Argument #{} must be an integer literal or null value, got {} ({:?})",
+                        expr_index + 1,
+                        other,

Review Comment:
   fixed!



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