HyukjinKwon opened a new pull request #34774: URL: https://github.com/apache/spark/pull/34774
### What changes were proposed in this pull request? This PR proposes to use [Python's standard string formatter](https://docs.python.org/3/library/string.html#custom-string-formatting) in `SparkSesiion.sql`, see also https://github.com/apache/spark/pull/34677. ### Why are the changes needed? To improve usability in PySpark. It works together with Python standard string formatter. ### Does this PR introduce _any_ user-facing change? By default, there is no user-facing change. If `kwargs` is specified, yes. 1. Attribute supports from frame (standard Python support): ```python mydf = ps.range(10) ps.sql("SELECT {tbl.id}, {tbl[id]} FROM {tbl}", tbl=mydf) ``` 2. Understanding `DataFrame`: ```python mydf = ps.range(10) ps.sql("SELECT * FROM {tbl}", tbl=mydf) ``` 3. Understanding `Column`: ```python mydf = ps.range(10) ps.sql("SELECT {c} FROM {tbl}", c=col("id") tbl=mydf) ``` 4. Leveraging other Python string format: ```python mydf = spark.range(10) spark.sql( "SELECT {col} FROM {mydf} WHERE id IN {x}", col=mydf.id, mydf=mydf, x=tuple(range(4))) ``` ### How was this patch tested? Doctests were added. -- 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]
