Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-41279 Feature parity: DataFrame API in Spark Connect
  3. SPARK-41831

DataFrame.transform: Only Column or String can be used for projections

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • Connect
    • None

    Description

      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))'>]'.

      Attachments

        Activity

          People

            podongfeng Ruifeng Zheng
            techaddict Sandeep Singh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: