<?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 Failed to run hive query from java application in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Failed-to-run-hive-query-from-java-application/m-p/310091#M224020</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Currently we are building a Java application to connect hive database to perform data transfer. We are encountering issue while issuing the below query through java application&lt;/P&gt;&lt;P&gt;"select count(*) from tablename where partition_key='xxxxx'".&lt;/P&gt;&lt;P&gt;The above table is partitioned by partition_key column. below is the complete error log from Java&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;### Error querying database. Cause: java.sql.SQLException: [Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: [Cloudera][JSQLEngine](12010) The table "dbname"."tablename" could not be found., SQL state: HY000, Query: select count(*) from dbname.tablename where partition_key='201912310002' .&lt;BR /&gt;### The error may exist in com/hds/datatransfer/mapper/hive/HiveRepository.java (best guess)&lt;BR /&gt;### The error may involve com.hds.datatransfer.mapper.hive.HiveRepository.test1&lt;BR /&gt;### The error occurred while executing a query&lt;BR /&gt;### SQL: select count(*) from dbname.tablename where partition_key='201912310002'&amp;nbsp;&lt;BR /&gt;### Cause: java.sql.SQLException: [Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: [Cloudera][JSQLEngine](12010) The table "dbname"."tablename " could not be found., SQL state: HY000, Query: select count(*) from dbname.tablename where partition_key='201912310002' .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This table is stored as ORC file format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: same query if I run it in any editor, it is working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also we observed that if Java application perform count operation on non partition table, it is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are unsure about this strange behavior, can you please help me on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2021 10:12:35 GMT</pubDate>
    <dc:creator>Zara</dc:creator>
    <dc:date>2021-01-20T10:12:35Z</dc:date>
    <item>
      <title>Failed to run hive query from java application</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Failed-to-run-hive-query-from-java-application/m-p/310091#M224020</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Currently we are building a Java application to connect hive database to perform data transfer. We are encountering issue while issuing the below query through java application&lt;/P&gt;&lt;P&gt;"select count(*) from tablename where partition_key='xxxxx'".&lt;/P&gt;&lt;P&gt;The above table is partitioned by partition_key column. below is the complete error log from Java&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;### Error querying database. Cause: java.sql.SQLException: [Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: [Cloudera][JSQLEngine](12010) The table "dbname"."tablename" could not be found., SQL state: HY000, Query: select count(*) from dbname.tablename where partition_key='201912310002' .&lt;BR /&gt;### The error may exist in com/hds/datatransfer/mapper/hive/HiveRepository.java (best guess)&lt;BR /&gt;### The error may involve com.hds.datatransfer.mapper.hive.HiveRepository.test1&lt;BR /&gt;### The error occurred while executing a query&lt;BR /&gt;### SQL: select count(*) from dbname.tablename where partition_key='201912310002'&amp;nbsp;&lt;BR /&gt;### Cause: java.sql.SQLException: [Cloudera][HiveJDBCDriver](500051) ERROR processing query/statement. Error Code: [Cloudera][JSQLEngine](12010) The table "dbname"."tablename " could not be found., SQL state: HY000, Query: select count(*) from dbname.tablename where partition_key='201912310002' .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This table is stored as ORC file format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: same query if I run it in any editor, it is working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also we observed that if Java application perform count operation on non partition table, it is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are unsure about this strange behavior, can you please help me on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 10:12:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Failed-to-run-hive-query-from-java-application/m-p/310091#M224020</guid>
      <dc:creator>Zara</dc:creator>
      <dc:date>2021-01-20T10:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to run hive query from java application</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Failed-to-run-hive-query-from-java-application/m-p/311279#M224570</link>
      <description>&lt;P&gt;Hi Zara,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to check a couple of things - which may give more clues on the why.&lt;/P&gt;&lt;P&gt;1. Are you using the latest Hive JDBC driver? (is it HDP or CDH/CDP?)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check out&amp;nbsp;&lt;A href="https://www.cloudera.com/downloads/connectors/hive/jdbc/2-6-11.html" target="_blank"&gt;https://www.cloudera.com/downloads/connectors/hive/jdbc/2-6-11.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2. Do you get the same error if you use backticks for the database name and/or for the table name?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;select count(*) from `dbname`.`tablename` where partition_key='xxxxx';&lt;/LI-CODE&gt;&lt;P&gt;3. Did you look at the HiveServer2 logs? What do they show you? What was the real query submitted to the HS2 and what was the failure there? What does it look like for a non-partitioned table?&lt;/P&gt;&lt;P&gt;4. The "UseNativeQuery" option of the JDBC driver sometimes can solve such interesting issues - as it is a flag whether the Hive query is already translated to a Hive native format. Check the docs.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.cloudera.com/documentation/other/connectors/hive-jdbc/2-6-11/Cloudera-JDBC-Driver-for-Apache-Hive-Install-Guide.pdf" target="_blank"&gt;https://docs.cloudera.com/documentation/other/connectors/hive-jdbc/2-6-11/Cloudera-JDBC-Driver-for-Apache-Hive-Install-Guide.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;5. Also you can turn on debug level logs at the JDBC driver side, see&amp;nbsp;LogLevel and LogPath JDBC connection string properties.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 09:23:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Failed-to-run-hive-query-from-java-application/m-p/311279#M224570</guid>
      <dc:creator>mszurap</dc:creator>
      <dc:date>2021-02-10T09:23:18Z</dc:date>
    </item>
  </channel>
</rss>

