Skip to content

Using Expr::field panics  #10565

@alamb

Description

@alamb

Describe the bug

After #10375 merged Expr::field now panics if you use it (as we did in influxdb) DataFusion panics when you try to execute it

To Reproduce

Try to evaluate an expression like col("props").field("a")

Here is a full reproducer in the sql_integration test:

(venv) andrewlamb@Andrews-MacBook-Pro:~/Software/datafusion$ git diff
diff --git a/datafusion/core/tests/expr_api/mod.rs b/datafusion/core/tests/expr_api/mod.rs
index d7e839824..d4141a836 100644
--- a/datafusion/core/tests/expr_api/mod.rs
+++ b/datafusion/core/tests/expr_api/mod.rs
@@ -58,6 +58,25 @@ fn test_eq_with_coercion() {
     );
 }

+
+#[test]
+fn test_expr_field() {
+    // currently panics with
+    // Internal("NamedStructField should be rewritten in OperatorToFunction")
+    evaluate_expr_test(
+        col("props").field("a"),
+        vec![
+            "+------------+",
+            "| expr       |",
+            "+------------+",
+            "| 2021-02-01 |",
+            "| 2021-02-02 |",
+            "| 2021-02-03 |",
+            "+------------+",
+        ],
+    );
+}
+

Expected behavior

Ideally the test should pass Expr::field would continue to work

We could also potentially remove Expr::field but I think that would be less user friendly

Additional context

I am pretty sure I Expr::field is widely used so I think we should continue to support it if possible

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions