YiouZuo commented on issue #19507:
URL: https://github.com/apache/superset/issues/19507#issuecomment-1218298902

   I figured out a workaround, we can write our own SQL script and fill the 
nulls in SQL LAB and then save it as a dataset. Below is my script.
   ```
   with dates as (
   select distinct DATE_TRUNC('DAY', date) as my_date
   from public.test_null_timeseries_v2
   ),
   accounts as (
   select DISTINCT account_name
   from public.test_null_timeseries_v2
   ),
   full_list AS (
   select my_date, account_name
   from dates
   cross join accounts
   ),
   test AS (
   SELECT DATE_TRUNC('DAY', date) AS my_date,
         account_name AS account_name,
         sum(value) AS sum_value
   FROM public.test_null_timeseries_v2
   group by my_date, account_name)
   select f.my_date, f.account_name,
   CASE 
     when t.sum_value is null then 0
     else t.sum_value
     end as sum_value_filled
   from full_list as f 
   left join test as t 
   on f.my_date = t.my_date and f.account_name = t.account_name
   order by f.my_date, f.account_name
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to