Incubator-superset: Question on How to use Fetch Values Predicate ?

Created on 23 Oct 2018  路  6Comments  路  Source: apache/incubator-superset

Hi everyone,

Thanks a lot for this dashboarding tool.
I am using the SQL option to create Superset view to get dynamique view, from some filter value. And it works wells, however I noticed the "Enable Filter Select"/"Fetch Values Predicate" option and I was wondering, how these two option works. I did not find documentation about those, if any can point me to one it would be awesome.
Does this allow us to get dynamic table according to a particular values ?
Thanks for your time.

Most helpful comment

It's for lowering the cost of fetching the value by using a predicate typically on an indexed or partitioned field. For instance if your table is partitioned by a field name ds, you can add Fetch Values Predicate that looks something like ds >= DATE_ADD(NOW(), DAYS, 7) or something of that nature. That way Superset, when populating the autocomplete values, will add this predicate to the SELECT DISTINCT {column_to_be_filtered_on} FORM {table} WHERE {fetch_values_predicate}.

All 6 comments

It's for lowering the cost of fetching the value by using a predicate typically on an indexed or partitioned field. For instance if your table is partitioned by a field name ds, you can add Fetch Values Predicate that looks something like ds >= DATE_ADD(NOW(), DAYS, 7) or something of that nature. That way Superset, when populating the autocomplete values, will add this predicate to the SELECT DISTINCT {column_to_be_filtered_on} FORM {table} WHERE {fetch_values_predicate}.

Great!
I think that the usage of 'fetch_values_predicate' should be added to the documents.

@vnnw
Have you managed to get this working?
I tried many cases but I never saw the WHERE condition appearing in my queries :(
I am using Superset 0.28.1

@lilila
No. the WHERE condition won't appear in the running queries as you get it by clicking on the upper right button "View Query", if I understand you right.

The 'fetch_values_predicate', as its name suggests, controls how you will get the available values for the filters in the lower left section 'Filters', so you must use it with 'Enable Filter Select' checked, as the snapshot bellow .

image

When you add a column into a filter, Superset will fetch the available unique values of this column for you to select from. Then 'fetch_values_predicate' puts the WHERE condition on the query fetching values, so you won't see it and it is also unnecessary.

Thanks for your time and your answer. I get how this features works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoralf-gutierrez picture thoralf-gutierrez  路  3Comments

eliab picture eliab  路  3Comments

gbrian picture gbrian  路  3Comments

ghost picture ghost  路  3Comments

kalimuthu123 picture kalimuthu123  路  3Comments