[ https://issues.apache.org/jira/browse/SPARK-38839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519798#comment-17519798 ]
Daniel deCordoba edited comment on SPARK-38839 at 4/8/22 9:04 PM: ------------------------------------------------------------------ The style got messed up, hopefully it is easy to understand this is the command that fails: {code:java} df = spark.createDataFrame([{"MyStruct":{"MyInt": 10, "MyFloat": 10.1}, "MyFloat": 10.1}]) {code} was (Author: JIRAUSER287808): The style got messed up, hopefully it is easy to understand this is the command that fails: df = spark.createDataFrame([\{"MyStruct": {"MyInt": 10, "MyFloat": 10.1} , "MyFloat": 10.1}]) > Creating a struct with a float inside > -------------------------------------- > > Key: SPARK-38839 > URL: https://issues.apache.org/jira/browse/SPARK-38839 > Project: Spark > Issue Type: Bug > Components: PySpark > Affects Versions: 3.2.1 > Reporter: Daniel deCordoba > Priority: Minor > > When creating a dataframe using createDataFrame that contains a float inside > a struct, the float is set to null. This only happens if using a list of > dictionaries as data type, if I use a list of Rows it works fine: > ```python > data = [\{"MyStruct": {"MyInt": 10, "MyFloat": 10.1} , "MyFloat": 10.1}] > spark.createDataFrame(data).show() > # > |MyFloat|MyStruct | > # > |10.1|{MyInt -> 10, MyFloat -> null}| > data = [Row(MyStruct=Row(MyInt=10, MyFloat=10.1), MyFloat=10.1)] > spark.createDataFrame(data).show() > # > |MyFloat|MyStruct | > # > |10.1 |{MyInt -> 10, MyFloat -> 10.1}| > ``` > Note MyFloat inside MyStruct is set to null in the first example. > Interestingly enough, when I do the same with Row, or if I specify the > schema, then this does not happen (second example). -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org