You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ueshin (via GitHub)" <gi...@apache.org> on 2023/04/21 00:08:06 UTC

[GitHub] [spark] ueshin opened a new pull request, #40888: [SPARK-43055][CONNECT][PYTHON][FOLLOWUP] Fix deduplicate field names and refactor

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

   ### What changes were proposed in this pull request?
   
   Fixes deduplicate field names, and refactor to use the same renaming rule between `ArrowTableToRowsConversion.convert` and `LocalDataToArrowConversion.convert`.
   
   ### Why are the changes needed?
   
   If there is a duplicated field name in a separate position, it fails to deduplicate and returns a wrong result.
   
   ```py
   >>> from pyspark.sql.types import *
   >>> data = [
   ...     Row(Row("a", 1), Row(2, 3, "b", 4, "c", "d")),
   ...     Row(Row("w", 6), Row(7, 8, "x", 9, "y", "z")),
   ... ]
   >>> schema = (
   ...     StructType()
   ...     .add("struct", StructType().add("x", StringType()).add("x", IntegerType()))
   ...     .add(
   ...         "struct",
   ...         StructType()
   ...         .add("a", IntegerType())
   ...         .add("x", IntegerType())
   ...         .add("x", StringType())
   ...         .add("y", IntegerType())
   ...         .add("y", StringType())
   ...         .add("x", StringType()),
   ...     )
   ... )
   >>> df = spark.createDataFrame(data, schema=schema)
   >>>
   >>> df.collect()
   [Row(struct=Row(x='a', x=1), struct=Row(a=2, x=None, x=None, y=4, y='c', x=None)), Row(struct=Row(x='w', x=6), struct=Row(a=7, x=None, x=None, y=9, y='y', x=None))]
   ```
   
   It should be:
   
   ```py
   >>> df.collect()
   [Row(struct=Row(x='a', x=1), struct=Row(a=2, x=3, x='b', y=4, y='c', x='d')), Row(struct=Row(x='w', x=6), struct=Row(a=7, x=8, x='x', y=9, y='y', x='z'))]
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Updated the related test.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #40888: [SPARK-43055][CONNECT][PYTHON][FOLLOWUP] Fix deduplicate field names and refactor

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #40888:
URL: https://github.com/apache/spark/pull/40888#issuecomment-1517301080

   Merged to master.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon closed pull request #40888: [SPARK-43055][CONNECT][PYTHON][FOLLOWUP] Fix deduplicate field names and refactor

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #40888: [SPARK-43055][CONNECT][PYTHON][FOLLOWUP] Fix deduplicate field names and refactor
URL: https://github.com/apache/spark/pull/40888


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org