HyukjinKwon commented on a change in pull request #32771:
URL: https://github.com/apache/spark/pull/32771#discussion_r645224064
##########
File path: python/pyspark/sql/functions.py
##########
@@ -101,19 +101,19 @@ def lit(col):
@since(1.3)
-def col(col):
+def col(col_like):
"""
Returns a :class:`~pyspark.sql.Column` based on the given column name.'
"""
- return _invoke_function("col", col)
+ return _invoke_function("col", col_like)
@since(1.3)
-def column(col):
Review comment:
can we just change to direct assignment?
```
column = col
```
Also, it would be worth adding a small test in docstring.
##########
File path: python/pyspark/sql/functions.py
##########
@@ -101,19 +101,19 @@ def lit(col):
@since(1.3)
-def col(col):
+def col(col_like):
"""
Returns a :class:`~pyspark.sql.Column` based on the given column name.'
+ Examples
+ --------
+ >>> df = spark.range(1, 10).toDF('x').withColumn('mod3', col('x') % 3)
+ >>> col('x')
+ >>> column('mod3')
"""
- return _invoke_function("col", col)
+ return _invoke_function("col", col_like)
Review comment:
```suggestion
return _invoke_function("col", col)
```
##########
File path: python/pyspark/sql/functions.py
##########
@@ -101,19 +101,19 @@ def lit(col):
@since(1.3)
-def col(col):
+def col(col_like):
Review comment:
```suggestion
def col(col):
```
##########
File path: python/pyspark/sql/functions.py
##########
@@ -101,19 +101,19 @@ def lit(col):
@since(1.3)
-def col(col):
+def col(col_like):
"""
Returns a :class:`~pyspark.sql.Column` based on the given column name.'
+ Examples
+ --------
+ >>> df = spark.range(1, 10).toDF('x').withColumn('mod3', col('x') % 3)
+ >>> col('x')
+ >>> column('mod3')
Review comment:
I think it will fail because the output doesn't match.
```suggestion
>>> col('x')
Column<'x'>
>>> column('mod3')
Column<'x'>
```
##########
File path: python/pyspark/sql/functions.py
##########
@@ -104,16 +104,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('mod3')
Review comment:
```suggestion
>>> column('x')
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]