I have a query that looks like this:
select hour, count(*)
from table
group by hour
I want the return to look like:
hour count
8 1
9 0
10 3
But instead it looks like:
hour count
8 1
10 3
This is because there were no entries in table for 9. The only solution I can think of is using an insert into statement wrapped around the query. So, something like:
insert into (
select hour, count(*)
from table
group by hour)
values (9, 0)
However this isn't proper syntax in Spark SQL.
Is it possible to insert into a table that's being generated as a result of a query without saving that table to a database? Is there an alternative way to accomplish what I want to accomplish?
org.apache.spark.sql.AnalysisException: missing EOF at 'select' near 'union'; line 28 pos 0