This error looks familiar and might be because of the Python library wrapping a 
select * around the original query.

Using the JDBC driver directly doesn’t seem to show this problem. Drill 1.13.0 
is out now. Could you give a try with that and confirm if the behavior is the 
same?

-----Original Message-----
From: Charles Givre <cgi...@gmail.com> 
Sent: Sunday, March 18, 2018 9:10 PM
To: user@drill.apache.org
Subject: Re: QSQL via jdbc (python3 and JayDeBeApi) wraps with SELECT ... LIMIT 0

Hi Francis, 


The code below worked for me.  Also, I don’t know if it matters, but did you 
mean to create two cursors?
— C

import jaydebeapi
import pandas as pd

#Create the connection object
conn = jaydebeapi.connect("org.apache.drill.jdbc.Driver", 
                        "jdbc:drill:drillbit=localhost:31010",
                          ["admin", "password"],
                          
"/usr/local/share/drill/jars/jdbc-driver/drill-jdbc-all-1.12.0.jar",)

#Create the Cursor Object
curs = conn.cursor()

#Execute the query
curs.execute("SELECT * FROM cp.`employee.json` LIMIT 20")

#Get the results
curs.fetchall()

#Read query results into a Pandas DataFrame df = pd.read_sql("SELECT * FROM 
cp.`employee.json` LIMIT 20", conn)





> On Mar 18, 2018, at 23:41, Francis McGregor-Macdonald <fran...@mc-mac.com> 
> wrote:
> 
> Hi all,
> 
> I am attempting to send a query from python3 via JayDeBeApi and am 
> encountering the issue that the SQL is enclosed in a SELECT * FROM 
> $myquery LIMIT 0
> 
> With:
> conn = jaydebeapi.connect("org.apache.drill.jdbc.Driver",
>                          "jdbc:drill:drillbit=$mycluster:$myport",
>                          ["$username", "$password"],
> "/tmp/drill-jdbc-all-1.12.0.jar")
> curs = conn.cursor()
> curs = conn.cursor()
> curs.execute('SHOW DATABASES')
> 
> ... the query hits Drill as:
> SELECT * FROM (SHOW DATABASES) LIMIT 0
> 
> A select * from mytable limit 100 also has the same issue.
> 
> Drill is version 1.12
> 
> This also occurs with other queries. I found 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__issues.apache.org
> _jira_browse_DRILL-2D5136&d=DwIFaQ&c=cskdkSMqhcnjZxdQVpwTXg&r=-cT6otg6
> lpT_XkmYy7yg3A&m=P8xoBFS297Ln7VimEBQXJDYYFIdoiHRELssI6Cnf4IM&s=6S6F2Zp
> p92kNVbtDDuGR29X21JjbNNnn6FZWibbd-gk&e= which looks similar and lists 
> "Client - ODBC" (not JDBC)
> 
> Has anyone else encountered this?

Reply via email to