I am using Spark SQL to create grouping sets with total columns to reduce the size of a file which I have previously cubed.
My code is as follows
final_sum = sqlContext.sql('''
SELECT case when GROUPING(x_flag)=1 then 'total' else x_flag END AS x_flag,
...
from trans,
group by x_flag,...,
GROUPING SETS(
(x_flag,y_name)
...
)
''')
My column x_flag is indexed 0,1 (as integers) and I am trying to get grouping sets based on that column mainly.
I currently get the following:
mismatched input x_flag expecting {, ';'}(line 14, pos 11)
Is there a method to fix this without having to reflag the column as y and n or is there some error which I am missing with using integer in case when?