apache / datafusion

Apache DataFusion SQL Query Engine
https://datafusion.apache.org/
Apache License 2.0
6.3k stars 1.19k forks source link

TableReference From<&str> creates invalid table references #4081

Open andygrove opened 2 years ago

andygrove commented 2 years ago

Describe the bug

The logic in impl<'a> From<&'a str> for TableReference<'a> simply splits a string on . and is creating invalid table references in some cases, such as:

Partial { schema: "COUNT(DISTINCT partsupp", table: "ps_suppkey)" }

To Reproduce We should write some unit tests for complex expressions

Expected behavior We should add logic to determine if the string represents a column reference or a complex expression (we could use the SQL parser to parse an identifier)

Additional context None

andygrove commented 2 years ago

I am now wondering if this is only happening in https://github.com/apache/arrow-datafusion/pull/4050 and not in general usage so this may not be a high priority

andygrove commented 2 years ago

It would be nice to change it to TryFrom though and catch cases where the string is not a column reference