Bug: DataFrame.transform: Only Column or String can be used for projections
Status: Resolved | Priority: Major | Resolution: Fixed
Created: 02/Jan/23 17:44
Affects Version/s: 3.4.0

{code:java}
File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 1168, in pyspark.sql.connect.dataframe.DataFrame.transform
Failed example:
    df.transform(cast_all_to_int).transform(sort_columns_asc).show()
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/doctest.py", line 1350, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest pyspark.sql.connect.dataframe.DataFrame.transform[4]>", line 1, in <module>
        df.transform(cast_all_to_int).transform(sort_columns_asc).show()
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 1102, in transform
        result = func(self, *args, **kwargs)
      File "<doctest pyspark.sql.connect.dataframe.DataFrame.transform[2]>", line 2, in cast_all_to_int
        return input_df.select([col(col_name).cast("int") for col_name in input_df.columns])
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 86, in select
        return DataFrame.withPlan(plan.Project(self._plan, *cols), session=self._session)
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/plan.py", line 344, in __init__
        self._verify_expressions()
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/plan.py", line 350, in _verify_expressions
        raise InputValidationError(
    pyspark.sql.connect.plan.InputValidationError: Only Column or String can be used for projections: '[Column<'(ColumnReference(int) (int))'>, Column<'(ColumnReference(float) (int))'>]'.
**********************************************************************
File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 1179, in pyspark.sql.connect.dataframe.DataFrame.transform
Failed example:
    df.transform(add_n, 1).transform(add_n, n=10).show()
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/doctest.py", line 1350, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest pyspark.sql.connect.dataframe.DataFrame.transform[6]>", line 1, in <module>
        df.transform(add_n, 1).transform(add_n, n=10).show()
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 1102, in transform
        result = func(self, *args, **kwargs)
      File "<doctest pyspark.sql.connect.dataframe.DataFrame.transform[5]>", line 2, in add_n
        return input_df.select([(col(col_name) + n).alias(col_name)
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/dataframe.py", line 86, in select
        return DataFrame.withPlan(plan.Project(self._plan, *cols), session=self._session)
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/plan.py", line 344, in __init__
        self._verify_expressions()
      File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/plan.py", line 350, in _verify_expressions
        raise InputValidationError(
    pyspark.sql.connect.plan.InputValidationError: Only Column or String can be used for projections: '[Column<'Alias(+(ColumnReference(int), Literal(1)), (int))'>, Column<'Alias(+(ColumnReference(float), Literal(1)), (float))'>]'.{code}