1
df_sales = spark.sql(
"SELECT \
s.TRANS_DT, \
s.STORE_KEY, \
s.PROD_KEY, \
s.SALES_QTY
FROM sales s \
JOIN inventory i ON s.cal_dt=i.cal_dt and s.store_key=i.store_key and s.prod_key=i.prod_key;"
)

I created sql query from 2 tempview (inventory and sales). How to convert df_sales sql query to tempview again and I can create a new SQL query.

1 Answer 1

2

Read this and you can write your own code as follows:

spark.sql(
"""
SELECT
    s.TRANS_DT,
    s.STORE_KEY,
    s.PROD_KEY,
    s.SALES_QTY
FROM sales s
JOIN inventory i ON s.cal_dt=i.cal_dt and s.store_key=i.store_key and s.prod_key=i.prod_key;
"""
).createOrReplaceTempView("tmpViewName")
Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.