Analyzer::extractTableNamesFromStatement cannot resolve alias for TVFs
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
Analyzer::extractTableNamesFromStatement provides a convenient way to get dependent table names for a given SQL statement. Although it doesn't resolve aliases correctly if there is a table-valued function applied to dependent table:
For example:
```
SELECT
(SELECT inner_foo FROM t.struct_field) AS inner_foo
FROM
foo_table t
```
This returns `foo_table` as expected.
But if we introduce a TVF named `MY_TVF` and test with following query:
```
SELECT
(SELECT inner_foo FROM t.struct_field) AS inner_foo
FROM
MY_TVF(TABLE foo_table) t
```
This returns `foo_table` and `t.struct_field` as table names. So it loses alias information that `t.struct_field` is not a separate table.
Contributor guide
Assessment
This issue has not been assessed yet.