This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 7becd02  [SPARK-35643][PYTHON] Fix ambiguous reference in functions.py 
column()
7becd02 is described below

commit 7becd026bec79876ddf58bb38b5a079d2ba297e6
Author: Keerthan Vasist <[email protected]>
AuthorDate: Sat Jun 5 12:40:39 2021 +0900

    [SPARK-35643][PYTHON] Fix ambiguous reference in functions.py column()
    
    ### What changes were proposed in this pull request?
    In functions.py, there is a function added `def column(col)`. There is also 
another method in the same file `def col(col)`. This leads to some ambiguity on 
whether the parameter is being referred to or the function. In pyspark 3.1.2, 
this leads to `TypeError: 'str' object is not callable` when the function 
`column(col)` is called - the highest preference is given to the string 
variable in scope as opposed to the function `col `in the file as intended.
    
    This PR fixes that ambiguity by changing the variable name to `col_like`. I 
have filed this as an issue on JIRA here - 
https://issues.apache.org/jira/browse/SPARK-35643.
    
    ### Why are the changes needed?
    In pyspark 3.1.2, we see `TypeError: 'str' object is not callable` when 
`column()` function is called. This Pr fixes that error.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    I don't believe this patch needs additional testing.
    
    Closes #32771 from keerthanvasist/col.
    
    Lead-authored-by: Keerthan Vasist <[email protected]>
    Co-authored-by: keerthanvasist <[email protected]>
    Co-authored-by: Hyukjin Kwon <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
    (cherry picked from commit f2c0a049a699c57a22e7e422eb8914670c10df6c)
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 python/pyspark/sql/functions.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py
index 2f1857d..75a31b7 100644
--- a/python/pyspark/sql/functions.py
+++ b/python/pyspark/sql/functions.py
@@ -102,16 +102,17 @@ def lit(col):
 def col(col):
     """
     Returns a :class:`~pyspark.sql.Column` based on the given column name.'
+    Examples
+    --------
+    >>> col('x')
+    Column<'x'>
+    >>> column('x')
+    Column<'x'>
     """
     return _invoke_function("col", col)
 
 
-@since(1.3)
-def column(col):
-    """
-    Returns a :class:`~pyspark.sql.Column` based on the given column name.'
-    """
-    return col(col)
+column = col
 
 
 @since(1.3)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to