sqlalchemy-teradata icon indicating copy to clipboard operation
sqlalchemy-teradata copied to clipboard

visit_select: limit clause fails

Open sandan opened this issue 9 years ago • 0 comments

When trying to implement the windowed range query for limit and offset type queries in Teradata, I get an error for more complicated joins and subqueries.

Snippet of testing error when trying to do a word cloud in Caravel:

Error: Column count not found in sqlalc_user.accidents.

SELECT anon_1.harm_ev, anon_1."count" FROM (SELECT TOP 50000 harm_ev AS harm_ev, COUNT() AS "count", ROW_NUMBER() OVER (ORDER BY COUNT() DESC) AS rownum FROM sqlalc_user.accidents JOIN (SELECT anon_3.harm_ev__ AS harm_ev__ FROM (SELECT TOP 50 harm_ev AS harm_ev__, ROW_NUMBER() OVER (ORDER BY "count" DESC) AS rownum FROM sqlalc_user.accidents WHERE harm_ev <> 'None' AND datetimestamp >= '2013-09-30 14:43:19.000000' AND datetimestamp <= '2016-09-30 14:43:19.000000' GROUP BY harm_ev) AS anon_3 WHERE rownum <= 50) AS anon_2 ON harm_ev = harm_ev__ WHERE datetimestamp >= '2013-09-30 14:43:19.000000' AND datetimestamp <= '2016-09-30 14:43:19.000000' AND harm_ev <> 'None' GROUP BY harm_ev) AS anon_1 WHERE rownum <= 50000'

sandan avatar Sep 30 '16 21:09 sandan