Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking null string parameter in where clause #312

Open
fjgraciani opened this issue May 16, 2024 · 1 comment · May be fixed by #315
Open

Error checking null string parameter in where clause #312

fjgraciani opened this issue May 16, 2024 · 1 comment · May be fixed by #315
Labels
bug Something isn't working

Comments

@fjgraciani
Copy link

What happened?

When I add a condition to the WHERE of a query in which I pass a string parameter with a null value as follows:

@parameter IS NULL OR @parameter = 'target text'

Throws the following error:
failed to analyze: INVALID_ARGUMENT: Undeclared parameter 'parameter' is used assuming different types (STRING vs INT64)

What did you expect to happen?

The clause must be satisfied since the parameter is null and meets the condition @parameter IS NULL and query must return results without throwing any error.

How can we reproduce it (as minimally and precisely as possible)?

Instantiate a bigquery client, add the parameter and run the query:

final String query= "SELECT * FROM `my-table` WHERE @parameter IS NULL OR 'target text' = @parameter";

QueryJobConfiguration.Builder queryConfigBuilder = QueryJobConfiguration.newBuilder(query);
QueryJobConfiguration queryConfig = queryConfigBuilder.build();
...
QueryParameterValue parameter = QueryParameterValue.of(null, StandardSQLTypeName.STRING);
queryConfigBuilder.addNamedParameter("parameter", parameter);
...
bigQuery.query(queryConfig);

Anything else we need to know?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants