Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
3.1.0
-
None
-
None
Description
I am trying to execute a very simple query, using python/pyodbc on Windows (with a working system-wide odbc DSN: HiveProd):
import pyodbc cnxn = pyodbc.connect('DSN=HiveProd', autocommit=True) cursor = cnxn.cursor() # works q="select ? as lic, ? as cpg" # fails q="with init as (select ? as lic, ? as cpg) select * from init" cursor.execute(q, '1', 'some string') for row in cursor: print(row.lic, row.cpg)
Basically, create an odbc connection, run a query with a prepared statement and print the result.
A basic query works fine. If I put this query inside a CTE, I get:
cursor.execute("with init as (select ? as lic, ? as cpg) select * from init", '1', 'some string') pyodbc.ProgrammingError: ('42000', "[42000] [Hortonworks][Hardy] (80) Syntax or semantic analysis error thrown in server while executing query. Error message from server: Error while compiling statement: FAILED: ParseException line 1:21 can not recognize input near '?' 'as' 'lic' in select clause (80) (SQLPrepare)")
This is not specific to python as I get the same issue with .Net.
Trying the same with JDBC works fine.
Testing on Hive 3.1.0 from Hdp 3.1.0