Skip to content

Conversation

@amaliujia
Copy link
Contributor

What changes were proposed in this pull request?

Current columns is implemented based on limit which runs a job to fetch data and get schema from the data collection. However a more efficient way is to call schema API which only need to analyze the plan without collect data. This approach should be more efficient in most of the cases.

Why are the changes needed?

Efficiency

Does this PR introduce any user-facing change?

NO

How was this patch tested?

UT

@amaliujia
Copy link
Contributor Author

R: @zhengruifeng @HyukjinKwon

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't need to cache columns, just return self.schema.names?

Copy link
Contributor Author

@amaliujia amaliujia Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to not depend on the underly API when doing caching...

E.g. what if someday the cache on the schema is gone but this API is not aware of it, etc.

Basically do not make assumptions :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm .. why do we need _cache? I think we can just remove.

Copy link
Contributor Author

@amaliujia amaliujia Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm if users call this API multiple times, we only need one gRPC. This should be useful right?

something like:

df.columns()

xxxx
xxx
df.columns()
xxxx
xxxx
df.columns()

Copy link
Contributor Author

@amaliujia amaliujia Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you think this is a bit over-engineering I can remove.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that case, we should probably have a proper cache layer instead of doing this alone in names.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do that for all cases for metadata-ish cases. e.g., schema or even collected results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this caching stuff in this PR. After we pretty much support enough API, we can go back to build a cache layer for all metadata like API to save RPC calls.

@amaliujia amaliujia force-pushed the improve_python_columns branch from be1216f to c6ae61b Compare November 10, 2022 18:25
@zhengruifeng
Copy link
Contributor

merged into master

SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
…o avoid data fetching

### What changes were proposed in this pull request?

Current `columns` is implemented based on `limit` which runs a job to fetch data and get schema from the data collection. However a more efficient way is to call `schema` API which only need to analyze the plan without collect data. This approach should be more efficient in most of the cases.

### Why are the changes needed?

Efficiency

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

UT

Closes apache#38546 from amaliujia/improve_python_columns.

Authored-by: Rui Wang <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants