In MySQL, I can have a query like this:
select
cast(from_unixtime(t.time, '%Y-%m-%d %H:00') as datetime) as timeHour
, ...
from
some_table t
group by
timeHour, ...
order by
timeHour, ...
where timeHour in the GROUP BY is the result of a select expression.
But I just tried a query similar to that in Sqark SQL, and I got an error of
Error: org.apache.spark.sql.AnalysisException:
cannot resolve '`timeHour`' given input columns: ...
My query for Spark SQL was this:
select
cast(t.unixTime as timestamp) as timeHour
, ...
from
another_table as t
group by
timeHour, ...
order by
timeHour, ...
Is this construct possible in Spark SQL?