I have a table with a column with one row with where clause.
from pyspark.sql.types import *
where_clause_df=spark.createDataFrame([('A > 1',)],schema=StructType([StructField("a_where", StringType(), nullable=True)]))
where_clause_df.createOrReplaceTempView("where_clause").show()
spark.sql("select * from where_clause").show()
+-------+
|a_where|
+-------+
| A > 1|
+-------+
With another table,
sample_df=spark.createDataFrame([(1,)],schema=StructType([StructField("A", IntegerType(), nullable=True)]))
sample_df.createOrReplaceTempView("sample")
spark.sql("select * from sample").show()
I want to use this a_where to apply with the table sample. Something like:
spark.sql("""
select * from sample where (select a_where from where_clause)
""").show()
Is it possible with Spark SQL ?