You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However when substituting foo ? 'bar' with a function wrapped in an alias, we get an error
Plan("Attempted to create Filter predicate with expression `json_contains(test.json_data, Utf8(\"foo\"))` aliased as 'json_data ? Utf8(\"foo\")'. Filter predicates should not be aliased.")
The problem is that I when replacing the operator, you don't know what part of the query the operator is used in, so you can't decide whether or not to apply the alias AFAIK.
#[tokio::test]
async fn test_question_filter() {
let batches = run_query("select name from test where json_data ? 'foo'")
.await
.unwrap();
let expected = [
"+------------+",
"| name |",
"+------------+",
"| object_foo |",
"+------------+",
];
assert_batches_eq!(expected, &batches);
}
Expected behavior
I think aliases as predicates should be allowed.
Additional context
No response
The text was updated successfully, but these errors were encountered:
samuelcolvin
changed the title
"Filter predicates should not be aliased." seems to strict
"Filter predicates should not be aliased." seems too strict
Jul 6, 2024
samuelcolvin
added a commit
to samuelcolvin/datafusion
that referenced
this issue
Jul 6, 2024
…11307)
* allow alias in predicate, fixapache#11306
* Fix typo.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* unalise predicate
* use unalias_nested
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
xinlifoobar
pushed a commit
to xinlifoobar/datafusion
that referenced
this issue
Jul 18, 2024
…11307)
* allow alias in predicate, fixapache#11306
* Fix typo.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
* unalise predicate
* use unalias_nested
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Describe the bug
Aliases are not allowed as filter predicates.
As per datafusion-contrib/datafusion-functions-json#26 (comment) @alamb suggested we work around change of alias when substituting functions to replace operators by using
Expr::Alias
.However when substituting
foo ? 'bar'
with a function wrapped in an alias, we get an errorThis is caused by
datafusion/datafusion/expr/src/logical_plan/plan.rs
Lines 2133 to 2140 in 08c5345
Ref #3796 & #3795
This seems unnecessarily strict.
The problem is that I when replacing the operator, you don't know what part of the query the operator is used in, so you can't decide whether or not to apply the alias AFAIK.
To Reproduce
Add the following test to datafusion-contrib/datafusion-functions-json#26
Expected behavior
I think aliases as predicates should be allowed.
Additional context
No response
The text was updated successfully, but these errors were encountered: