ficapal18 opened a new issue, #20653:
URL: https://github.com/apache/superset/issues/20653

   We are building an AI cognitive tool for personalized medicine in cancer, 
and we would like to have an analytics dashboard in it.
   
   For this reason, we embedded a Superset dashboard in the tool. So far, we 
are very satisfied with the outcomes and how the dashboard fits in the tool. We 
are close to make it work, but we require the help from a Superset expert that 
can help us with the following problem:
   
   We have an SQL query that creates a virtual dataset, that queries a 
materialized view, with the 5-year survival probability of the currently 
analyzed pool of patients. In our analysis, the resulting pool of patients or 
segment is the outcome after applying the filters of the other charts in the 
dashboard (e.g: We could filter through a filter box chart, the column 
diagnosis_year = 2020 to take into account only those patients that were 
diagnosed with cancer on 2020). 
   
   Our problem is that the virtual dataset table doesn't have this column 
(diagnosis_year), but to make the survival curves fit the specific filter 
selection, the whole SQL query should run every time a filter is set, to 
refresh the survival virtual dataset. 
   
   For that, we make the virtual dataset trigger its execution by adding the 
"diagnosis_year" column in one of the first SELECT statements of the query, 
which seems to trigger the virtual dataset query when, for instance, 
diagnosis_year is set to 2016 in the filter box chart.
   
   Now, the problem is that when we set a value for the filter, such as 2016, 
we get an error in the chart of the survival virtual dataset. The error is the 
following: "sequence item 0: expected str instance, int found". You will find 
attached two screenshots of the error, from the dashboard and the server logs.
   
   This is how we select the diagnosis_year, which is a variable of "DOUBLE 
PRECISION" type.
   
   ```
   
       SELECT
           *
       FROM
           (
           -- Death not null
           SELECT
               date_of_death AS event_at,
               'exitus' AS event_type,
               patient_id,
               diagnosis_year 
           FROM
               warehouse.feature_table_mat
           WHERE
               date_of_death IS NOT NULL
           ) 
   
   [Compute the survival curves ]
   ![Screenshot 2022-07-08 at 15 44 
42](https://user-images.githubusercontent.com/8928435/178007170-2589ccbf-0538-46fa-858c-b5234e0a4a15.png)
   ![Screenshot 2022-07-08 at 15 45 
09](https://user-images.githubusercontent.com/8928435/178007180-9781be03-0c66-458c-a6d2-fd87acb43fea.png)
   
   [...]
   ```
   
   
   We have also tried using jinja templates without succeeding, like that:
   
   ```
   {%- if (filter_values('diagnosis_year') is defined) and 
filter_values('diagnosis_year') -%}
       WHERE diagnosis_year IN ({{ "'" + 
"','".join(filter_values('diagnosis_year')) + "'" }})
   {%- endif -%}
   ```
   
   Any ideas about what is happening and a possible solution? 
   
   
   ### Environment
   
   - superset version: apache/superset:1.5.1
   - any feature flags active:  
   "EMBEDDED_SUPERSET":True,
   "DASHBOARD_CROSS_FILTER":True,
   "DASHBOARD_CROSS_FILTERS":True,
   "DASHBOARD_NATIVE_FILTERS_SET":True,
   "DASHBOARD_RBAC":True,
   "DASHBOARD_FILTERS_EXPERIMENTAL" :True,
   "ENABLE_TEMPLATE_PROCESSING": True
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to