sqlglot icon indicating copy to clipboard operation
sqlglot copied to clipboard

Qualify bare * and add table alias in Exasol Sqlglot

Open nnamdi16 opened this issue 1 month ago • 4 comments

What motivated this PR? Exasol doesn't support a bare * alongside other select items.

How is the existing logic in main incorrect? For example, when transpiling SELECT *, 1 FROM TEST to Exasol, the query returned (SELECT *, 1 FROM TEST) would fail because Exasol requires that the bare * is scoped with an alias.

How does the PR address the aforementioned issues? The PR preprocesses SELECT by transforming unscoped star to .* and attaching TableAlias. Fix: SELECT *, 1 FROM TEST -> SELECT T.*, 1 FROM TEST AS T

Provide documentation for the SQL functions involved in the implementation & explain whether semantics change / are preserved The issue is not specifically stated in the documentation, but I can provide a screenshot if required

nnamdi16 avatar Nov 28 '25 14:11 nnamdi16

@nnamdi16 it seems like this PR does not handle SELECT * queries with multiple sources, e.g.:

> with t1 as (select 1 as c1), t2 as (select 2 as c2) select *, 3 from t1, t2; -- this is in DuckDB
┌───────┬───────┬───────┐
│  c1   │  c2   │   3   │
│ int32 │ int32 │ int32 │
├───────┼───────┼───────┤
│   1   │   2   │   3   │
└───────┴───────┴───────┘

I think we would need to add t1.*, t2.*, etc., in order for this conversion to be complete.

georgesittas avatar Dec 01 '25 14:12 georgesittas

@nnamdi16 it seems like this PR does not handle SELECT * queries with multiple sources, e.g.:

> with t1 as (select 1 as c1), t2 as (select 2 as c2) select *, 3 from t1, t2; -- this is in DuckDB
┌───────┬───────┬───────┐
│  c1   │  c2   │   3   │
│ int32 │ int32 │ int32 │
├───────┼───────┼───────┤
│   1   │   2   │   3   │
└───────┴───────┴───────┘

I think we would need to add t1.*, t2.*, etc., in order for this conversion to be complete.

Its a very good idea @georgesittas. I would look into it

nnamdi16 avatar Dec 01 '25 14:12 nnamdi16

Hey @nnamdi16, any plans to take this to the finish line?

georgesittas avatar Dec 04 '25 13:12 georgesittas

SELECT T.*, 1 FROM TEST AS T

Hey @nnamdi16, any plans to take this to the finish line?

Yes @georgesittas I would fix the concerns.

nnamdi16 avatar Dec 04 '25 13:12 nnamdi16