I'm looking to reconcile dates between two tables. In other words, I'm looking for where the date column is NULL from the right table.
The first query generates a table with sequence of dates between 2017-2022:
    select -1 + row_number() over(order by 0) i, start_date + i generated_date 
from (select '2017-01-01'::date start_date, '2022-12-31'::date end_date)
join table(generator(rowcount => 10000 )) x
qualify i < 1 + end_date - start_date
Sample of the table below:
| I | Generate_Date | 
|---|---|
| 0 | 2021-01-01 | 
| 1 | 2017-01-02 | 
The second query generates a tables generates with a date along with other items.
select distinct date
from table 
where i.id = id
Sample of the table below:
| ID | Date | 
|---|---|
| ID1 | 2021-01-01 | 
| ID2 | 2017-01-02 | 
I join both queries:
WITH calendar_table as (
select -1 + row_number() over(order by 0) i, start_date + i generated_date 
from (select '2017-01-01'::date start_date, '2022-12-31'::date end_date)
join table(generator(rowcount => 10000 )) x
qualify i < 1 + end_date - start_date)
select distinct t.generated_date, i.date
from calendar_table t 
left join table i on t.date = i.date
where i.id = 'id'
order by t.generated_date desc
I would expect the result to show this:
| Generated_date | Date | 
|---|---|
| 2021-05-02 | 2021-05-02 | 
| 2021-05-03 | NULL | 
However, this is what appears. I thought a left join is supposed to bring back everything from the FROM clause. I know that 2021-05-03 exist in the left table. Can I please get suggestions on how to fix this?
| Generated_date | Date | 
|---|---|
| 2021-05-01 | 2021-05-01 | 
| 2021-05-02 | 2021-05-02 | 
| 2021-05-04 | 2021-05-04 | 
| 2021-05-05 | 2021-05-05 | 
 
    