ueshin opened a new pull request, #40760:
URL: https://github.com/apache/spark/pull/40760

   ### What changes were proposed in this pull request?
   
   Fixes `createDataFrame` to respect the given schema ddl.
   
   ### Why are the changes needed?
   
   Currently even if the schema is provided as a DDL string, it's not taken 
into account and causes the schema mismatch in the server side.
   
   For example:
   
   ```py
   >>> import pandas as pd
   >>> map_data = [{"a": 1}, {"b": 2, "c": 3}, {}, None, {"d": None}]
   >>> pdf = pd.DataFrame({"id": [0, 1, 2, 3, 4], "m": map_data})
   >>> schema = "id long, m map<string, long>"
   >>>
   >>> spark.createDataFrame(pdf, schema=schema)
   Traceback (most recent call last):
   ...
   pyspark.errors.exceptions.connect.AnalysisException: 
[INVALID_COLUMN_OR_FIELD_DATA_TYPE] Column or field `col_1` is of type 
"STRUCT<col_0: BIGINT, col_1: BIGINT, col_2: BIGINT, col_3: VOID>" while it's 
required to be "MAP<STRING, BIGINT>".
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   The schema DDL string will be taken into account.
   
   ### How was this patch tested?
   
   Enabled/modified the related tests.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to