Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFrame schema metadata lost in Python Notebook #55

Closed
metasim opened this issue Apr 27, 2018 · 0 comments
Closed

DataFrame schema metadata lost in Python Notebook #55

metasim opened this issue Apr 27, 2018 · 0 comments

Comments

@metasim
Copy link
Contributor

metasim commented Apr 27, 2018

When using Spark ML and other libraries like RasterFrames it is now common to attach metadata to the dataframe schema via StructField. In kernel_init.py#move_to_local_sqlContext, the schema is completely thrown out:

return sqlContext.createDataFrame(df.rdd)

This not only loses any metadata attached to the schema, it further causes a Spark "action" to be invoked (e.g. SparkContext.runJob) in order to grab a sample line and infer the schema from its contents, creating unnecessary and potentially undesirable computation before the user demands it.

While I don't fully understand the purpose of this method, my guess would that it needs to be changed to something like the following. But without knowing how to test it, I'm not comfortable submitting a PR.

def move_to_local_sqlContext(df):
    return sqlContext.createDataFrame(df.rdd, df.schema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants