2

I have to compare a DF with another one that is the same schema readed from a specific path, but maybe in that path there are not files so I've thought that I have to compare it with a null DF with the same columns as the original.

So I am trying to create a DF with the schema from another DF that contains a lot of columns but I can't find a solution for this. I have been reading the following posts but no one helps me:

How to create an empty DataFrame with a specified schema?

How to create an empty DataFrame? Why "ValueError: RDD is empty"?

How to create an empty dataFrame in Spark

How can I do it in scala? Or is better take other option?

1 Answer 1

8

originalDF.limit(0) will return an empty dataframe with the same schema.

Sign up to request clarification or add additional context in comments.

Comments

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.