HyukjinKwon commented on code in PR #39183:
URL: https://github.com/apache/spark/pull/39183#discussion_r1055930680
##########
python/pyspark/sql/session.py:
##########
@@ -1293,20 +1293,25 @@ def prepare(obj: Any) -> Any:
df._schema = struct
return df
- def sql(self, sqlQuery: str, **kwargs: Any) -> DataFrame:
+ def sql(self, sqlQuery: str, args: Dict[str, str] = {}, **kwargs: Any) ->
DataFrame:
"""Returns a :class:`DataFrame` representing the result of the given
query.
When ``kwargs`` is specified, this method formats the given string by
using the Python
- standard formatter.
+ standard formatter. The method binds named parameters to SQL literals
from `args`.
.. versionadded:: 2.0.0
.. versionchanged:: 3.4.0
- Support Spark Connect.
+ Support Spark Connect and parameterized SQL.
Parameters
----------
sqlQuery : str
SQL query string.
+ args : dict
+ A dictionary of named parameters that begin from the `:` marker and
+ their SQL literals for substituting.
+
+ .. versionadded:: 3.4.0
Review Comment:
```suggestion
.. versionadded:: 3.4.0
```
##########
python/pyspark/pandas/sql_formatter.py:
##########
@@ -99,6 +102,11 @@ def sql(
e f 3 6
Also note that the index name(s) should be matched to the existing
name.
+ args : dict
+ A dictionary of named parameters that begin from the `:` marker and
+ their SQL literals for substituting.
+
+ .. versionadded:: 3.4.0
Review Comment:
```suggestion
.. versionadded:: 3.4.0
```
--
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]