You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "samuelcolvin (via GitHub)" <gi...@apache.org> on 2024/07/06 14:33:19 UTC
[I] "Filter predicates should not be aliased." seems to strict [datafusion]
samuelcolvin opened a new issue, #11306:
URL: https://github.com/apache/datafusion/issues/11306
### Describe the bug
Aliases are not allowed as filter predicates.
As per https://github.com/datafusion-contrib/datafusion-functions-json/pull/26#discussion_r1664566127 @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 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.")
```
This is caused by
https://github.com/apache/datafusion/blob/08c5345e932f1c5c948751e0d06b1fd99e174efa/datafusion/expr/src/logical_plan/plan.rs#L2133-L2140
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 https://github.com/datafusion-contrib/datafusion-functions-json/pull/26
```
#[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_
--
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.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: [I] "Filter predicates should not be aliased." seems too strict [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #11306: "Filter predicates should not be aliased." seems too strict
URL: https://github.com/apache/datafusion/issues/11306
--
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: [I] "Filter predicates should not be aliased." seems too strict [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #11306: "Filter predicates should not be aliased." seems too strict
URL: https://github.com/apache/datafusion/issues/11306
--
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