Support Questions

Find answers, ask questions, and share your expertise

Getting improper "Unexpected character" using Cloudera ODBC for Impala

avatar
New Contributor

Are there shortcomings with the ODBC driver around parameters?  Can you help me fix a big problem I'm having?  I'm passing a simple string, like "A123456", into a query with a single parameter.

I've simplified my query as much as possible to avoid confusion.  I get the "unexpected character" error on this query over ODBC using Cloudera ODBC driver 64-bit 2.05.41.1029 for Windows.  (My actual query I want to run is much larger but the same in its essence.)

 

with nextMatchId as (
    select min(match_id) as match_id
    from userTable
    where user_id = ?)
select c.*
from candidateTable c
join nextMatchId on nextMatchId.match_id=c.match_id

 

Supplying a Varchar parameter like "A123456" and running it gives me:
ERROR [HY000] [Cloudera][ImpalaODBC] (110) Error while executing a query in Impala: [HY000] : AnalysisException: Syntax error in line 5:
    where user_id = ?
                    ^
Encountered: Unexpected character
Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE, IDENTIFIER

 

(I get the same error when I use a subquery instead of WITH.)

 

I was able to run this well using Hue and supplying the literal value instead of the "?".

1 ACCEPTED SOLUTION

avatar
Master Collaborator

HI @Locarno,

Please, what kind of params do you want to pass to ther query via ODBC? Where do you do this? and what is the use cas?
take a look to this link:
https://stackoverflow.com/questions/34093083/query-parameters-with-impala-odbc-driver

View solution in original post

3 REPLIES 3

avatar
New Contributor

I've discovered many other variations tha thave the same issue--for example, moving the parameter "?" placeholder outside the subquery still causes the same "Unexpected character" on the question mark, as though the parameter is not being substituted by the ODBC driver:

 

 

with
    nextMatchGroup as (
        select user_id, min(match_id)
	from userTable
        group by user_id
    ) 
select *
from candidateTable
join nextMatchGroup on nextMatchGroup.match_id=c.match_id
where nextMatchGroup.user_id = ?

...gives me the same error. Any ideas how to overcome this apparent failure to substitute?

 

avatar
Master Collaborator

HI @Locarno,

Please, what kind of params do you want to pass to ther query via ODBC? Where do you do this? and what is the use cas?
take a look to this link:
https://stackoverflow.com/questions/34093083/query-parameters-with-impala-odbc-driver

avatar
New Contributor
The question mark is a parameter placeholder in ODBC.