Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7280#discussion_r34226374
  
    --- Diff: R/pkg/inst/tests/test_sparkSQL.R ---
    @@ -108,6 +108,14 @@ test_that("create DataFrame from RDD", {
       expect_equal(count(df), 10)
       expect_equal(columns(df), c("a", "b"))
       expect_equal(dtypes(df), list(c("a", "int"), c("b", "string")))
    +
    +  localDF <- data.frame(name=c("John", "Smith", "Sarah"), age=c(19, 23, 
18), height=c(164.10, 181.4, 173.7))
    +  schema <- structType(structField("name", "string"), structField("age", 
"integer"), structField("height", "float"))
    +  df <- createDataFrame(sqlContext, localDF, schema)
    --- End diff --
    
    I checked this. The column is still `double` due to another problem I just 
submitted in #7311. That is, in `createDataFrame`, the given `schema` will be 
overwritten.
    
    Although I solved that in #7311, I just found that with user defined 
schema, it is possible to cause problem when collecting data from dataframe.
    
    That is because we serialize `double` in R to `Double` in Java. If we 
define a column as `float` in R and create a dataframe based on this schema. 
The serialized and deserialized `Double` will be stored at the `float` column. 
Then when we collect the data from it, it will throw error.
    
    @shivaram How do you think? Do we need to fix #7311? Or you think it is up 
to users to define correct schema?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to