Support Questions

Find answers, ask questions, and share your expertise

Impala JDBC driver does not parse table aliases with space correctly in some situations

avatar
Explorer

If the query contains a subquery in the FROM clause and the alias to the subquery contains space, 

 

select `alias with space`.code from (select * from sample_07) `alias with space`

 

the JDBC driver throws exception

 

Exception in thread "main" java.sql.SQLException: [Simba][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:AnalysisException: Syntax error in line 1:

...lt`.`sample_07`) AS alias with space

                             ^

Encountered: WITH

Expected: CROSS, FROM, FULL, GROUP, HAVING, INNER, JOIN, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, UNION, USING, WHERE, COMMA

 

CAUSED BY: Exception: Syntax error

), Query: SELECT `alias with space`.`code` FROM (SELECT `sample_07`.`code`, `sample_07`.`description`, `sample_07`.`total_emp`, `sample_07`.`salary` FROM `default`.`sample_07`) AS alias with space.

at com.cloudera.impala.hivecommon.api.HS2Client.executeStatementInternal(Unknown Source)

at com.cloudera.impala.hivecommon.api.HS2Client.executeStatement(Unknown Source)

at com.cloudera.impala.hivecommon.dataengine.HiveJDBCNativeQueryExecutor.executeQuery(Unknown Source)

at com.cloudera.impala.hivecommon.dataengine.HiveJDBCDSIExtQueryExecutor.execute(Unknown Source)

at com.cloudera.impala.jdbc.common.SStatement.executeNoParams(Unknown Source)

at com.cloudera.impala.jdbc.common.SStatement.executeQuery(Unknown Source)

Caused by: com.cloudera.impala.support.exceptions.GeneralException: [Simba][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:AnalysisException: Syntax error in line 1:

...lt`.`sample_07`) AS alias with space

                             ^

Encountered: WITH

Expected: CROSS, FROM, FULL, GROUP, HAVING, INNER, JOIN, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, UNION, USING, WHERE, COMMA

 

CAUSED BY: Exception: Syntax error

), Query: SELECT `alias with space`.`code` FROM (SELECT `sample_07`.`code`, `sample_07`.`description`, `sample_07`.`total_emp`, `sample_07`.`salary` FROM `default`.`sample_07`) AS alias with space.

... 6 more

 

Is this a known issue?

 

/Saravana

1 ACCEPTED SOLUTION

avatar
Explorer

useNativeQuery option is an workaround for this problem. Filed this as a bug in Jira IMPALA-2609.

View solution in original post

2 REPLIES 2

avatar

Hi Saravana,

 

thanks for your report! Looks like a new isue. Would you mind filing a JIRA for it so we can assign and track it?

 

As a possible workaround, could you try running the query with "use native query" enabled in the JDBC driver?

The driver will send the query to Impala verbatim (sometimes the driver may make some changes to the SQL).

 

http://www.cloudera.com/content/cloudera/en/documentation/connectors/latest/PDF/Cloudera-JDBC-Driver...

 

Alex

 

avatar
Explorer

useNativeQuery option is an workaround for this problem. Filed this as a bug in Jira IMPALA-2609.