BeishaoCao-db opened a new pull request, #41396: URL: https://github.com/apache/spark/pull/41396
### What changes were proposed in this pull request? Add a _ipython_key_completions_() method on Python DataFrame class to return column names. Main benefit of this is that IPython autocomplete engine(or any other using IPython e.g. IPython kernel, Databricks Notebooks) to get autocomplete suggestions for [] will suggest column names on the completion df[|]. ### Why are the changes needed? For those who use IPython as autocomplete engine can get column name as suggested for df[|]. Increases productivity for anyone who uses an autocomplete engine on pyspark code. Example: https://github.com/apache/spark/assets/109033553/dd575144-bb87-47a9-8387-de2e51f1c8e2 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? New doctest <img width="1030" alt="Screenshot 2023-05-30 at 5 11 23 PM" src="https://github.com/apache/spark/assets/109033553/4b3a89c0-edf4-4ad2-80bf-2bba3824456f"> Test in databricks notebook: ``` class DataFrameWithColAttrs(DataFrame): def __init__(self, df): super().__init__(df._jdf, df._sql_ctx if df._sql_ctx else df._session) def _ipython_key_completions_(self): return self.columns ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
