Context: Hive3, HDP 3.1. Tests done with Python/odbc (official HDP driver) under Windows and Linux.
I ran the following queries:
- "select ? as lic, ? as cpg"
- "select * from (select ? as lic, ? as cpg) as t"
- "with init as (select ? as lic, ? as cpg) select * from init",
1) and 2) work fine, and give me the expected result. 3 gives me a ParseException :
Error while compiling statement: FAILED: ParseException line 1:21 cannot recognize input near '?' 'as' 'lic' in select clause (80) (SQLPrepare)")
The exact same statements ran with java/jdbc work fine. Note that 2) looks like is a workaround for 3) but it works for this tiny example, not for bigger queries.
Is there something I can do to have ODBC working as expected? Alternatively, where can I find the limits of the ODBC driver?
For full context, the full test code is as follow:
cnxnstr = 'DSN=HiveProd'
cnxn = pyodbc.connect(cnxnstr, autocommit=True)
cursor = cnxn.cursor()
queries = [
"with init as (select ? as lic, ? as cpg) select * from init",
"select 2 * ? as lic, ? as cpg",
"select * from (select ? as lic, ? as cpg) as t",
]
for q in queries:
print("\nExecuting " + q)
try:
cursor.execute(q, '1', '2')
except pyodbc.ProgrammingError as e:
print(e)
continue