Problems / Calendar Zero-Fill / Editorial
LEFT JOIN
calendar
orders
o.order_date = c.day
COUNT(o.order_id)
COUNT(*)
c.day
Zero-filling is a *join direction* problem, not an aggregation problem. GROUP BY can only produce groups for rows that exist, so missing days can never appear from orders alone — the spine table must supply them. The companion trap is COUNT(*) vs COUNT(column): after a LEFT JOIN, COUNT(*) counts the unmatched row too, while COUNT(o.order_id) counts only real orders. In PySpark the same pair applies: F.count(orders["order_id"]) skips NULLs exactly like SQL.
GROUP BY
COUNT(column)
F.count(orders["order_id"])
Solve Calendar Zero-Fill yourself →