You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/04/14 16:24:36 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5998: fix: Do not panic on invalid placeholders

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


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -2330,4 +2335,22 @@ mod tests {
         assert_eq!(1, schemas.len());
         assert_eq!(0, schemas[0].fields().len());
     }
+
+    #[test]
+    fn test_replace_invalid_placeholder_empty() {
+        let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
+
+        let plan = table_scan(TableReference::none(), &schema, None)
+            .unwrap()
+            .filter(col("id").eq(Expr::Placeholder {
+                id: "".into(),

Review Comment:
   https://github.com/apache/arrow-datafusion/issues/5856 also reports an issue if `"$0"` is provided in addition to `""`. Can you please add a test for that as well?



##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -605,6 +605,11 @@ impl LogicalPlan {
         expr.transform(&|expr| {
             match &expr {
                 Expr::Placeholder { id, data_type } => {
+                    if id.is_empty() {
+                        return Err(DataFusionError::Internal(

Review Comment:
   What do you think about making this a `DataFusion::Plan` error rather than `Internal` -- it seems to me this isn't a bug in datafusion (which is what `Internal` represents) but rather a bug in the code that called DataFusion.
   



-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org