<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Hive odbc with prepared statements: ParseException in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Hive-odbc-with-prepared-statements-ParseException/m-p/242932#M204731</link>
    <description>&lt;P&gt;Context: Hive3, HDP 3.1. Tests done with Python/odbc (official HDP driver) under Windows and Linux.&lt;/P&gt;&lt;P&gt;I ran the following queries:&lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;"select ? as lic, ? as cpg"&lt;/LI&gt;&lt;LI&gt;"select * from (select ? as lic, ? as cpg) as t"&lt;/LI&gt;&lt;LI&gt;"with init as (select ? as lic, ? as cpg) select * from init",&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;1) and 2) work fine, and give me the expected result. 3 gives me a ParseException :&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error while compiling statement: FAILED: ParseException line 1:21 cannot recognize input near '?' 'as' 'lic' in select clause (80) (SQLPrepare)")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Is there something I can do to have ODBC working as expected? Alternatively, where can I find the limits of the ODBC driver?&lt;/P&gt;&lt;P&gt;For full context, the full test code is as follow:&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Jan 2019 15:07:26 GMT</pubDate>
    <dc:creator>guillaume_roger</dc:creator>
    <dc:date>2019-01-28T15:07:26Z</dc:date>
    <item>
      <title>Hive odbc with prepared statements: ParseException</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-odbc-with-prepared-statements-ParseException/m-p/242932#M204731</link>
      <description>&lt;P&gt;Context: Hive3, HDP 3.1. Tests done with Python/odbc (official HDP driver) under Windows and Linux.&lt;/P&gt;&lt;P&gt;I ran the following queries:&lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;"select ? as lic, ? as cpg"&lt;/LI&gt;&lt;LI&gt;"select * from (select ? as lic, ? as cpg) as t"&lt;/LI&gt;&lt;LI&gt;"with init as (select ? as lic, ? as cpg) select * from init",&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;1) and 2) work fine, and give me the expected result. 3 gives me a ParseException :&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error while compiling statement: FAILED: ParseException line 1:21 cannot recognize input near '?' 'as' 'lic' in select clause (80) (SQLPrepare)")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Is there something I can do to have ODBC working as expected? Alternatively, where can I find the limits of the ODBC driver?&lt;/P&gt;&lt;P&gt;For full context, the full test code is as follow:&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Jan 2019 15:07:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-odbc-with-prepared-statements-ParseException/m-p/242932#M204731</guid>
      <dc:creator>guillaume_roger</dc:creator>
      <dc:date>2019-01-28T15:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hive odbc with prepared statements: ParseException</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-odbc-with-prepared-statements-ParseException/m-p/242933#M204732</link>
      <description>&lt;P&gt;The ODBC driver does not support all syntax niceties (no CTE) and if there is a syntax error, it will output a completely irrelevant message, which adds a lot to the confusion. To actually see the actual error, you need to add ODBC logging and look at the log files.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:50:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-odbc-with-prepared-statements-ParseException/m-p/242933#M204732</guid>
      <dc:creator>guillaume_roger</dc:creator>
      <dc:date>2019-02-15T19:50:24Z</dc:date>
    </item>
  </channel>
</rss>

