zhengruifeng opened a new pull request, #41980:
URL: https://github.com/apache/spark/pull/41980

   ### What changes were proposed in this pull request?
   Implement SparkSession.sql's string formatter
   
   
   ### Why are the changes needed?
   for parity
   
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes
   
   
   before:
   ```
   In [1]: spark.createDataFrame([("Alice", 6), ("Bob", 7), ("John", 10)], 
['name', 'age']).createOrReplaceTempView("person")
   
   In [2]: spark.sql("""SELECT * FROM person WHERE age < {age}""", age = 
9).show()
   ---------------------------------------------------------------------------
   TypeError                                 Traceback (most recent call last)
   Cell In[2], line 1
   ----> 1 spark.sql("""SELECT * FROM person WHERE age < {age}""", age = 
9).show()
   
   TypeError: sql() got an unexpected keyword argument 'age'
   ```
   
   
   after:
   ```
   In [1]: spark.createDataFrame([("Alice", 6), ("Bob", 7), ("John", 10)], 
['name', 'age']).createOrReplaceTempView("person")
   
   In [2]: spark.sql("""SELECT * FROM person WHERE age < {age}""", age = 
9).show()
   +-----+---+
   | name|age|
   +-----+---+
   |Alice|  6|
   |  Bob|  7|
   +-----+---+
   ```
   
   
   
   ### How was this patch tested?
   enabled doc test
   


-- 
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]

Reply via email to