Hi, I am not too familiar with SQL queries but I am trying to setup a SQL redash query where I would like to parse an input query parameter.

For example: I have one query parameter called model_one. This is basically a comma separated input model_name,run_id. Example: abcd,1234

I am trying to run a query as:

SELECT run_id,
      model_name,
      username,
FROM test.table
WHERE (model_name LIKE SUBSTRING_INDEX('{{model_one}}', '/', 1)
      AND (run_id LIKE '%SUBSTRING_INDEX('{{model_one}}', '/', 1)%'))

But this is giving me an error:

Function substring_index not registered

Is it possible to split the text parameter input in query code?

There’s no reason Redash won’t support this. It just depends which database you’re querying. For example, the error you see:

comes from the data source you are querying. It doesn’t have a substring_index function. What data source is this?

That depends on whether your data source supports any kind of substring indexing.


Side note: there appears to be a typo in the final line of your query. I believe it should be:

SELECT run_id,
      model_name,
      username,
FROM test.table
WHERE (model_name LIKE SUBSTRING_INDEX('{{model_one}}', '/', 1)
      AND (run_id LIKE '%' + SUBSTRING_INDEX('{{model_one}}', '/', 1) + '%'))

Thanks for explaining. Data source is presto db. So I was able to resolve it by using split_part.
https://prestodb.io/docs/current/functions/string.html