Support Questions

Find answers, ask questions, and share your expertise

Hive ODBC Driver issue

avatar
Explorer

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 12

avatar
Community Manager

@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.



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.
Learn more about the Cloudera Community:

avatar
Master Collaborator

@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-Apa...

avatar
Explorer

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

avatar
Master Collaborator

@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?

avatar
Explorer

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.

avatar
Master Collaborator

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?

avatar
Explorer

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.

avatar
Master Collaborator

 

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

avatar
Explorer

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.