I'm not sure if you can do a select * from (CTAS ..)
The output of CTAS really is only a metric of the rows that got written by the various fragments. Are you able to run the query in SQLLine? The parse error does a pretty good job of pointing out where the query appears to have broken the parser's semantics. So it is possible that you need some escape characters to handle the query, without which, Python might be altering the query. Kunal ________________________________ From: Wesley Chow <w...@chartbeat.com> Sent: Monday, April 24, 2017 2:33:14 PM To: user@drill.apache.org Subject: JDBC SQL parse error on CTAS I'm seeing a funny issue where issuing SELECT statements through the JDBC driver is fine, but when I prepend them with CREATE TABLE AS, I start getting parse errors. If I copy+paste the query string into sqlline the CTAS works. When the thing breaks, it gives me an exception with message like: SQL Query SELECT * FROM (CREATE TABLE foo ... ) LIMIT 0 And complains about a parse error at the CREATE TABLE step. Now this is weird to me, because it seems like the driver is automatically wrapping the CTAS with a "SELECT * FROM ... LIMIT 0"? An additional complication is that this isn't straight up JDBC. This is Python calling out to the JDBC driver, so admittedly I might be throwing a wrench in there somewhere. But it doesn't make sense to me that either the Python layer or JDBC would modify the query in that way. I've checked the Python wrapper source and there I couldn't find anything to indicate it might be changing the query. I also briefly sifted through the JDBC code and couldn't find anything as well. Any clues as to what might be going on? Wes