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

DataFrame.createDataFrame datatype conversion error

    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/functions.py", line 1594, in pyspark.sql.connect.functions.to_json
      Failed example:
          df = spark.createDataFrame(data, ("key", "value"))
      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.functions.to_json[3]>", line 1, in <module>
              df = spark.createDataFrame(data, ("key", "value"))
            File "/Users/s.singh/personal/spark-oss/python/pyspark/sql/connect/session.py", line 252, in createDataFrame
              table = pa.Table.from_pandas(pdf)
            File "pyarrow/table.pxi", line 3475, in pyarrow.lib.Table.from_pandas
            File "/usr/local/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 611, in dataframe_to_arrays
              arrays = [convert_column(c, f)
            File "/usr/local/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 611, in <listcomp>
              arrays = [convert_column(c, f)
            File "/usr/local/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 598, in convert_column
              raise e
            File "/usr/local/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 592, in convert_column
              result = pa.array(col, type=type_, from_pandas=True, safe=safe)
            File "pyarrow/array.pxi", line 316, in pyarrow.lib.array
            File "pyarrow/array.pxi", line 83, in pyarrow.lib._ndarray_to_array
            File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
          pyarrow.lib.ArrowInvalid: ("Could not convert 'Alice' with type str: tried to convert to int64", 'Conversion failed for column 1 with type object')

      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: