In a dialect I am trying to write for Apache Drill, I when a join comes
through (with no visit_join function) however it's being created (excuse my
"newness") it lands in Apache Drill like this


SELECT field1 AS field1, COUNT(*) AS cnt
FROM table JOIN (SELECT field1 AS __field1
FROM table GROUP BY field1 ORDER BY COUNT(*) DESC
LIMIT 50) AS anon_1 ON field1 = __field1 GROUP BY field1 ORDER BY cnt DESC
LIMIT 5000


This is fine except Drill requires that the on clause be more clear than it
currently is... it sees field1=__field1 as too ambiguous.

Thus what I need to do is simply:


SELECT field1 AS field1, COUNT(*) AS cnt
FROM table JOIN (SELECT field1 AS __field1
FROM table GROUP BY field1 ORDER BY COUNT(*) DESC
LIMIT 50) AS anon_1 ON field1 = anon_1.__field1 GROUP BY field1 ORDER BY
cnt DESC
LIMIT 5000

Note, it wouldn't hurt things if table was aliased (anon_2) and it was used
here either, but basically I am trying to determine if I need to write a
complicated/involved visit_join in my dialect, or if there a simpler way (a
setting in the dialect to always include aliases at this point)  I really
don't want to do extra work if it's not needed, but I am not afraid doing
said work... I just want to ensue its the right approach for this sort of
thing, and my newness to SqlAlchemy is keeping me from understanding which
approach is the right approach.

Thanks in advance,

John

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to