You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/06/22 08:25:45 UTC
[GitHub] [spark] MaxGekk commented on a diff in pull request #41695: [SPARK-44140][SQL][PYTHON] Support positional parameters in Python `sql()`
MaxGekk commented on code in PR #41695:
URL: https://github.com/apache/spark/pull/41695#discussion_r1238182528
##########
python/pyspark/pandas/sql_formatter.py:
##########
@@ -102,7 +102,7 @@ def sql(
e f 3 6
Also note that the index name(s) should be matched to the existing name.
- args : dict
+ args : dict or list
A dictionary of parameter names to Python objects that can be converted to
Review Comment:
Yep, I am changing it now. Thank you.
##########
python/pyspark/sql/session.py:
##########
@@ -1410,28 +1410,35 @@ def prepare(obj: Any) -> Any:
df._schema = struct
return df
- def sql(self, sqlQuery: str, args: Optional[Dict[str, Any]] = None, **kwargs: Any) -> DataFrame:
+ def sql(
+ self, sqlQuery: str, args: Optional[Union[Dict[str, Any], List]] = None, **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. The method binds named parameters to SQL literals from `args`.
+ standard formatter. The method binds named parameters to SQL literals or
+ positional parameters from `args`. It doesn't support named and positional parameters
+ in the same SQL query.
.. versionadded:: 2.0.0
.. versionchanged:: 3.4.0
Supports Spark Connect and parameterized SQL.
+ .. versionchanged:: 3.5.0
+ Supports parameterized SQL with positional parameters.
Review Comment:
ok
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org