Skip to main content
AlexDriver
Silver ⭐️⭐️⭐️
May 13, 2025
Question

Hive ODBC Driver issue

Dear Community,
I've faced with an issue when i try to send the following query to Apache Hive using ODBC driver:

"-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f

SELECT *
FROM (-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f

select version()) AS Subquery__9
LIMIT 1"

then i get an empty response.
However, if i remove the commented out fragments with Request Id and its uuid then it starts working as expected by returning the version.

What am i missing here or is it an ODBC driver bug?
PS: it's not reproducible when i do the same using JDBC.

12 replies

VidyaSargur
Community Manager
Community Manager
May 14, 2025

@AlexDriver,Welcome to our community! To help you get the best possible answer, I have tagged in our Hive experts @asish @smruti who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.

Translate
Regards, Vidya Sargur, Community Manager Was your question answered? Make sure to mark the answer as the accepted solution. If you find a reply useful, say thanks by clicking on the thumbs up button.
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 14, 2025

@AlexDriver So our query is essentially this:

 

SELECT *
FROM (
SELECT version()
) AS Subquery__9
LIMIT 1;

 

I think the driver connector is unable to parse the comment.
You may enable Native Query by setting UseNativeQuery=1, this way driver does not try to transform the query, and it runs directly in Hive. Try this and see if it works.

Driver user guide - https://downloads.cloudera.com/connectors/Cloudera_Hive_ODBC_2.8.2.1002/Cloudera-ODBC-Driver-for-Apache-Hive-Install-Guide.pdf

Translate
AlexDriver
Silver ⭐️⭐️⭐️
May 14, 2025

unfortunately  UseNativeQuery=1
hasn't helped.
the issue is still reproducible.

Translate
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 15, 2025

@AlexDriver is it possible to enable trace logging in the driver and share the logs, and also see how the query shows up in the hiveserver2 logs?

Translate
AlexDriver
Silver ⭐️⭐️⭐️
May 15, 2025

here's what i can see in the driver log:
01:09:15.229 INFO 1431732928 Simba::DSI::SharedSingletonManager::LogVersionsAndLocation: SDK Version: 10.02.03.1020
01:09:15.229 INFO 1431732928 Simba::DSI::SharedSingletonManager::LogVersionsAndLocation: DSII Version: 2.7.0.1002
01:09:15.229 INFO 1431732928 Simba::DSI::SharedSingletonManager::LogVersionsAndLocation: Executing binary located at /opt/cloudera/hiveodbc/lib/64/libclouderahiveodbc64.so
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Default Database CHAR Encoding: UTF-8
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Default Database WCHAR Encoding: UTF-8
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Driver ANSI CHAR Encoding: UTF-8
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Driver Manager WCHAR Encoding: UTF-16LE
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Detected Driver Manager: unixODBC, 2.2.14 or 2.3.x branch
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Locale name: en_US
01:09:15.229 INFO 1431732928 Simba::ODBC::Driver::Initialize: Bitness: 64-bit
01:09:15.229 INFO 1431732928 ::CInterface::SQLAllocHandle: Allocating environment handle.
01:09:15.230 INFO 1431732928 Simba::ODBC::Environment::SQLSetEnvAttr: Attribute: SQL_ATTR_ODBC_VERSION (200)
01:09:15.230 INFO 1431732928 Simba::ODBC::EnvironmentAttributes::SetAttribute: Setting ODBC version to: 3
01:09:15.230 INFO 1431732928 Simba::ODBC::Environment::SQLGetEnvAttr: Attribute: SQL_ATTR_ODBC_VERSION (200)
01:09:15.230 INFO 1431732928 ::CInterface::SQLAllocHandle: Allocating connection handle.
01:09:15.439 INFO 1431732928 ::CInterface::SQLAllocHandle: Allocating statement handle.
01:09:15.787 INFO 1431732928 ::CInterface::SQLFreeHandle: Freeing statement handle.
01:09:15.801 INFO 1431732928 ::CInterface::SQLFreeHandle: Freeing connection handle.
01:09:15.801 INFO 1431732928 ::CInterface::SQLFreeHandle: Freeing environment handle.

Does it explain anything?

PS: later on i'll try to get to the hive server logs.

Translate
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 15, 2025

Could you test with multiline comment, just to see if it works?

SELECT *
FROM (/* Request ID: ... */ SELECT version()) AS Subquery__9
LIMIT 1;

What's the ODBC driver version that you are using? Is it from Cloudera?

Translate
AlexDriver
Silver ⭐️⭐️⭐️
May 15, 2025

when a comment line is in a middle of the query or at the end - it works fine.

the only issue is when the commend is in the first line.

Translate
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 16, 2025

 

Could you please share both versions and mark this thread resolved?

Translate
AlexDriver
Silver ⭐️⭐️⭐️
May 16, 2025

like i said in the beginning - this one doesn't work:

"-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f

SELECT *
FROM (-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f

select version()) AS Subquery__9
LIMIT 1"

however, this one works fine:

"SELECT *
FROM (-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f

select version()) AS Subquery__9
LIMIT 1

-- Request ID: 4b9a2e0a-e250-45b7-b9cc-0915f20f848f"

Though our team found a workaround, but I'm afraid this thread can't set this as resolved as the original issue still exists, i.e. any valid multi-line query starting with a comment line - returns empty response. And like i also said - this is not the case when the query is sent through JDBC.

Translate
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 16, 2025

@AlexDriver could you share the ODBC driver version you are using, so that we can test this?

Translate
AlexDriver
Silver ⭐️⭐️⭐️
May 19, 2025

2.7.0

Translate
smruti
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
May 17, 2025

@AlexDriver I tried this with latest ODBC driver 2.8.2. Used it with pyodbc, and I can reproduce the issue.
The error I get is :

Traceback (most recent call last):
File "/hive/pyodbc_test.py", line 13, in <module>
for row in cursor.fetchall():
^^^^^^^^^^^^^^^^^
pyodbc.ProgrammingError: No results. Previous SQL was not a query.

I have raised an enhancement request with the driver team. 

Translate