Invalid queries generated when using CTEs in Spark

Hi Looker community!

I am having a very frustrating experience with CTEs and Spark 2.0:
We’re currently migrating our data visualization tool. One of our queries has a very complex structure, in the format:

WITH a AS (
	SELECT example
	FROM example
),
b AS (
	SELECT example2
	FROM a
),
...
SELECT columns
FROM z

When we insert this code on derived_table.sql parameter in LookML, select some fields in the recently-created Explore, the query Looker sends to Spark is:

SELECT dimensions, measures
FROM (
	WITH a AS (...)... -- derived table SQL
)

This structure (WITH inside FROM) doesn’t work on Spark 2. I think it’s an important blocker when Looker generates a query which is not runnable.
If we change the model connection to Presto, LookML/Explore combination generates a query in format:

WITH derived_table AS (/*derived_table code*/)
SELECT dimensions, measures
FROM derived_table

Which would run in Spark.
Besides, the proposed solution of splitting the CTEs in separated views is not convenient for us, because we have several subqueries, with parameters and templated filters, and this would require a lot of re-work to us.
Do you have an idea about when such problem could be fixed (the way LookML generates query to Spark when there’s CTEs in derived_table)? This is blocking the adoption of Looker as the new DataViz tool.

1 0 53
0 REPLIES 0
Top Labels in this Space
Top Solution Authors