alamb commented on code in PR #5017:
URL: https://github.com/apache/arrow-datafusion/pull/5017#discussion_r1083438508


##########
datafusion/sql/src/expr/value.rs:
##########
@@ -96,13 +96,20 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         param_data_types: &[DataType],
     ) -> Result<Expr> {
         // Parse the placeholder as a number because it is the only support 
from sqlparser and postgres
+        // __timeTo is not supported and should return a Plan Error #5005
         let index = param[1..].parse::<usize>();
         let idx = match index {
             Ok(index) => index - 1,
             Err(_) => {
-                return Err(DataFusionError::Internal(format!(
-                    "Invalid placeholder, not a number: {param}"
-                )));
+                if &param[1..] == "__timeTo" {
+                    return Err(DataFusionError::Plan(format!(
+                        "Placeholder not supported: {param}"
+                    )));
+                } else {
+                    return Err(DataFusionError::Internal(format!(
+                        "Invalid placeholder, not a number: {param}"
+                    )));
+                }

Review Comment:
   I think in general, parameters like `$__foo` are not valid and should cause 
an error. I don't think there is anything special about `$__timeTo` other than 
it happened to be the example I had. 
   
   What would you think about
   
   ```suggestion
                   return Err(DataFusionError::Plan(format!(
                       "Invalid placeholder, not a number: {param}"
                   )));
   ```



##########
datafusion/sql/tests/integration_test.rs:
##########
@@ -3112,6 +3112,15 @@ fn test_prepare_statement_to_plan_panic_param_format() {
     logical_plan(sql).unwrap();

Review Comment:
   We could probably update this previous test to change Internal / Plan rather 
than adding a new 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to