python-pinot-dbapi / pinot-dbapi

Python DB-API and SQLAlchemy dialect for Pinot
MIT License
19 stars 33 forks source link

Allow pinot table aliases #97

Closed abloom closed 4 months ago

abloom commented 4 months ago

My team has been using this pinot driver with the SQL Alchemy ORM and ran into a bit of an issue with missing table names in JOIN clauses during execution.

When printing the generated query things look good:

SELECT table1.a, table1.b, table2.c
FROM table1
JOIN table2 ON table1.a = table2.a

but when executing the query the table names are dropped from all the columns:

SELECT a, b, c
FROM table1
JOIN table2 ON a = a

and we end up with a query that won't run because the ON a = a portion of the JOIN clause is ambiguous.

I checked the commit history for the lines I deleted and didn't learn much about their origin. Is it possible Pinot has advanced in the years since they were originally written? We've moved our code over to our fork of the driver and haven't noticed any side effects yet.

If this solution is unacceptable please let me know what I need to change.


After making the first change we noticed some queries that used to work started failing. The Pinot query planner started returning errors about CAST calls using invalid types. I've switched STRING to VARCHAR and LONG to NUMERIC and have updated the tests to reflect that.