Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive ODBC Parameterized query

Highlighted

Hive ODBC Parameterized query

Contributor

Wanting to run a query in a C# application against hive.

OdbcCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM user WHERE id = ?";
cmd.Parameters.Add("?id", OdbcType.Int).Value = 4;

OdbcDataReader reader = cmd.ExecuteReader();

But end up getting an error from the ODBC driver

ERROR [HY000] [Hortonworks][HiveODBC] (80) Syntax or semantic analysis error thrown in server while execurint query. Error message from server: Error while compiling statement: FAILED: ParseException line 1:42 cannot recognize input near '?' '<EOF>' in expression specification

8 REPLIES 8
Highlighted

Re: Hive ODBC Parameterized query

instead of

cmd.CommandText="SELECT * FROM user WHERE id = ?";

can you try

  1. cmd.CommandText="SELECT * FROM user WHERE id = ? ;";
Highlighted

Re: Hive ODBC Parameterized query

Contributor

Unfortunately, that does not work.

Highlighted

Re: Hive ODBC Parameterized query

Expert Contributor
@Kevin Vasko

The issue seems to be with the cmd.Parameters.Add("?id",OdbcType.Int).Value=4; you may want to try this one instead and see if this helps

cmd.Parameters.Add("@id", OdbcType.Int).Value = 4;

I'm no c# expert but seems like this could be the issue.

Highlighted

Re: Hive ODBC Parameterized query

Contributor
@mbalakrishnan

Thanks but we tried it both ways and it still does not work.

Highlighted

Re: Hive ODBC Parameterized query

Expert Contributor
Highlighted

Re: Hive ODBC Parameterized query

Contributor

@mbalakrishnan I'll try that but that does look to be just a different method of adding parameters to the OdbcCommand object. At this point I am thinking this is an issue with the Hive ODBC driver itself. I cannot find any documentation related to this subject for the Hive ODBC and the things I found people are having the same issue.

Highlighted

Re: Hive ODBC Parameterized query

New Contributor
I also have the same problem but from SSRS

 

Highlighted

Re: Hive ODBC Parameterized query

Community Manager

@Giovanny As this question is old, I would suggest starting a new thread for your issue. This would allow you to also provide further details about your unique environment.



Cy Jervis, 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:
Community Guidelines
How to use the forum
Don't have an account?
Coming from Hortonworks? Activate your account here