We get errors like this,
Recursive view `x` detected (cycle: `x` -> `x`)
.. in our long-term working code, that has worked just fine in Spark 2.4.5 (Runtime 6.4), when we run it on a Spark 3.2 cluster (Runtime 10.0).
It happens whenever we have,
<x is a Dataframe>
x.createOrReplaceTempView('x')
... in order to use Spark SQL such as,
y = spark.sql("""
select ...
from x
...
""")
-------
It seems that the ('x') name of the
x.createOrReplaceTempView('x')
... needs to be globally unique and cannot be overwritten (even if the function "createOrReplaceTempView" has the word "replace" in it).
Is there a fix for this issue in general without setting the global "spark.<something>.legacy" option? (We prefer to avoid that)
If there is no fix, our current cumbersome re-write would be to rewrite every
x.createOrReplaceTempView('x')
to
z = f'x_{timestamp_as_text_with_underscores}'
x.createOrReplaceTempView(z)
... and then ofc use it as,
y = spark.sql("""
select ...
from z
...
""")
... such, but we would prefer a more elegant solution, if there is one?