Inconsistent and sometimes incomplete list of columns
Ciao, I’m playing with the library to get the list of all fields accessed by a given query, but I’m getting inconsistent results based on the complexity of the SQL query.
Let’s start with a simple example like this one:
SELECT p.ID AS test, p.*
FROM MYSCHEMA.MYTABLE.PERSON AS p
WHERE 1
Result: ['MYSCHEMA.MYTABLE.PERSON.ID', 'MYSCHEMA.MYTABLE.PERSON.*']
Everything works as expected, but if I run a more straightforward SQL query like:
SELECT *
FROM MYSCHEMA.MYTABLE.PERSON
WHERE 1
I get a completely different response: ['*']; I was expecting [‘MYSCHEMA.MYTABLE.PERSON.*’] instead.
By testing a more complex query like this one, I get a completely unusable result:
SELECT
CASE
WHEN (
SELECT min("ID")
FROM MYSCHEMA.MYTABLE1
) > (
SELECT max(ID)
FROM MYSCHEMA.MYTABLE2
) THEN TRUE
WHEN (
SELECT max(ID)
FROM MYSCHEMA.MYTABLE1
) < (
SELECT min(ID)
from MYSCHEMA.MYTABLE2
) THEN TRUE
ELSE FALSE
END AS NO_COMMON_DATA
The result is now a generic [‘ID’] event if it should be: [‘MYSCHEMA.MYTABLE1.ID’, ‘MYSCHEMA.MYTABLE2.ID’]
Finally, if I test this last query:
SELECT COUNT(*) FROM HUBSPOT.DEAL_PIPELINE
I get an empty array [] instead of [‘HUBSPOT.DEAL_PIPELINE.*’]
Who can help me? Thanks again
Currently, we don't infer the table if you do not provide it (or alias of it) in a query as this would work only for the selects from a single table.
@collerek - yay, you're back! 🙂