useNativeQuery didn't help.
This is my code.
public static void main(String[] args) throws IOException, SQLException {
connectionUrl =
"jdbc:impala://
hadoop102.qa1.sac.int.company.com:21050/dwh;AuthMech=3;UID=ldaptest;PWD=test;useNativeQuery=1
";
jdbcDriverName = "com.cloudera.impala.jdbc41.Driver";
System.out.println("\n=============================================");
System.out.println("Cloudera Impala JDBC Example");
System.out.println("Using Connection URL: " + connectionUrl);
// System.out.println("Running Query: " + sqlStatement);
Connection con = null;
try {
Class.forName(jdbcDriverName);
con = DriverManager.getConnection(connectionUrl);
String query="select count( distinct yyyymmdd) from
dwh.event_detail limit 1/*abcdefg1*/";
System.out.println("\n== Begin Query Results
======================");
System.out.println("\n== Running query=== " + query);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
QueryTask.printResultSet(rs);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
con.close();
}
}
Same query when executed from HUE shows comments. Look at the screenshot
from CM.
Sunil Parmar
On Wed, Dec 13, 2017 at 11:30 PM, Mostafa Mokhtar <[email protected]>
wrote:
> +1 on what Alex recommends.
> Highly recommend using useNativeQuery=1 all the time.
>
> Thanks
> Mostafa
>
> On Dec 13, 2017, at 9:42 PM, Alexander Behm <[email protected]>
> wrote:
>
> Not sure if this will work, but you could try enabling useNativeQuery in
> the driver. Theoretically that should send the query string including
> comments verbatim to Impala.
>
> On Wed, Dec 13, 2017 at 7:57 PM, Philip Zeyliger <[email protected]>
> wrote:
>
>> I’m a little surprised comments are being stripped, but adding (1=1 or
>> “”=“your comment”) to a where clause would work similarly. Impala will
>> simplify that away during query compilation.
>>
>> P
>>
>> On Wed, Dec 13, 2017 at 7:22 PM Sunil Parmar <[email protected]>
>> wrote:
>>
>>> Server version: impalad version 2.9.0-cdh5.12.1 RELEASE (build
>>> 5131a031f4aa38c1e50c430373c55ca53e0517b9)
>>>
>>> One of the primary use of of Impala is it acts as a backend to a web
>>> application exposed to lot of users. We are trying to build monitoring
>>> metrics per web page, logged in user and other things that are not
>>> typically supplied in the query string. We were thinking to use query
>>> comments to pass such information along with query. It worked fine when
>>> query is executed using impala-shell; I can see the comments in the impala
>>> monitoring page i.e. on port #25000 but when comments are sent over JDBC ;
>>> they're not visible to Impalad.
>>>
>>> 1. Is there an configuration in Impala driver ? We're using
>>> <dependency>
>>> <groupId>com.cloudera.impala</groupId>
>>> <artifactId>impala-jdbc</artifactId>
>>> <version>2.5.30</version>
>>> <scope>compile</scope>
>>> </dependency>
>>>
>>> 2. Is there any other way to send such hints along with query ?
>>>
>>>
>>> Thanks,
>>> Sunil
>>>
>>>
>