Need advise on apache calcite. We have some SQL queries running on Teradata. Now we want to run these sql queries (as it is) on Hadoop/Spark perhaps using Apache calcite.
We tried these SQL queries (as it is) in Spark SQL (2.6.3) and also in Apache calcite - but few queries dont run. The problem is if we define a derived variable (AS) and try to use it in the same query at same level, it does not WORK in SparkSQL and calcite but WORKS in Teradata. Example query:
select EMPNO, sum(deptno) as sum_dept,
case when sum_dept > 10 then 1 else 0 end as tmp
from emps
group by EMPNO; => WORKS in Teradata
But the same does not work in SparkSQL and Calcite. Throws following error:
Error while executing SQL "select EMPNO, sum(deptno) as sum_dept, case when sum_dept > 10 then 1 else 0 end as tmp from emps group by EMPNO": From line 1, column 50 to line 1, column 57: Column 'SUM_DEPT' not found in any table (state=,code=0)
Does anybody (SparkSQL/Calcite expert) know if there is a way to make it work in sparkSQL or calcite?