You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Hen0k (via GitHub)" <gi...@apache.org> on 2025/10/09 08:34:59 UTC
Re: [D] Modify Automatic “IN” Filter to Support “LIKE” Search for Categorical Filters [superset]
GitHub user Hen0k added a comment to the discussion: Modify Automatic “IN” Filter to Support “LIKE” Search for Categorical Filters
@chrisdukeLlama
I had a similar requirement a while back and found a workaround that I have been using.
This will require you to enable template processing using the feature flag.
'ENABLE_TEMPLATE_PROCESSING': True,
Another thing to note is that the solution only works on Virtual Datasets. You can easily satisfy this one.
Then you use jinja to replace the filtering login applied on that dataset like this.
```sql
SELECT * FROM your_table
{% if filter_values("your_column_name") %}
WHERE
{# Initialize a variable to store the conditions #}
{%- set or_clauses = [] -%}
{# Loop through each filter in the 'your_column_name' filter #}
{%- for filter in get_filters('your_column_name', remove_filter=True) -%}
{%- if filter.get('op') == 'IN' -%}
{# Loop through all values in the filter #}
{%- for val in filter.get("val") -%}
{# Append each condition to the list #}
{%- set _ = or_clauses.append("your_column_name ILIKE '%%" ~ val ~ "%%'") -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{# Join the list of conditions with 'OR' to form the final clause #}
{{ or_clauses | join(' OR ') }}
{% endif %}
```
GitHub link: https://github.com/apache/superset/discussions/33625#discussioncomment-14634247
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org