Query Parameters as a Number


#1

Dear All,

I’m trying to run a CQL query as follows;

SELECT count(data) FROM table WHERE data > ’ {{Value}}’

I defined query parameter “Value” to make queries more dynamic without the need to change source code. However I have a problem, when I enter 1000 to Value box at Redash and run query, I get the following error;

Error running query: Error from server: code=2200 [Invalid query] message=“Invalid STRING constant ( 1000) for “data” of type float”

I choose parameter type as ‘Value’ from Redash but it seems, in query, it is acting like a string.

How can I solve this problem?

Thank you in advance.


#2

I think you just need to take your single quotes out of your query. This just worked for me -

select count(*) from finance.bv_projects where project_id < {{ project_id }}

But with the single quotes, it errors (different error on my end - likely the case of DB platforms).


#3

@ToniFielder is correct, you need to remove the quotes. The parameter is inserted as-is into the query, and in your case it becomes a string.


#4

Thank you! Now it is working after removing the quotes.