You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Shawn Weeks (JIRA)" <ji...@apache.org> on 2019/01/28 19:02:00 UTC

[jira] [Commented] (HIVE-21144) ODBC with prepared statement fail inside a CTE

    [ https://issues.apache.org/jira/browse/HIVE-21144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754256#comment-16754256 ] 

Shawn Weeks commented on HIVE-21144:
------------------------------------

Check and make sure that the ODBC Driver your using is using "Native Queries". Several of the Hive ODBC Drivers try and rewrite your queries and may be messing with the CTE. Also if possible check the hiverserver2 logs and see if you can figure out exactly what query Hive received.

> ODBC with prepared statement fail inside a CTE
> ----------------------------------------------
>
>                 Key: HIVE-21144
>                 URL: https://issues.apache.org/jira/browse/HIVE-21144
>             Project: Hive
>          Issue Type: Bug
>          Components: ODBC
>    Affects Versions: 3.1.0
>            Reporter: Guillaume
>            Priority: Major
>
> I am trying to execute a very simple query, using python/pyodbc on Windows (with a working system-wide odbc DSN: HiveProd):
> {code:java}
> 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)
> {code}
> 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
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)