spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shivaram <...@git.apache.org>
Subject [GitHub] spark pull request #13786: [SPARK-15294][R] Add `pivot` to SparkR
Date Mon, 20 Jun 2016 21:34:46 GMT
Github user shivaram commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13786#discussion_r67771049
  
    --- Diff: R/pkg/inst/tests/testthat/test_sparkSQL.R ---
    @@ -1397,6 +1397,26 @@ test_that("group by, agg functions", {
       unlink(jsonPath3)
     })
     
    +test_that("pivot GroupedData column", {
    +  df <- createDataFrame(data.frame(
    +    earnings = c(10000, 10000, 11000, 15000, 12000, 20000, 21000, 22000),
    +    course = c("R", "Python", "R", "Python", "R", "Python", "R", "Python"),
    +    year = c(2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016)
    +  ))
    +  sum1 <- collect(sum(pivot(groupBy(df, "year"), "course"), "earnings"))
    +  sum2 <- collect(sum(pivot(groupBy(df, "year"), "course", c("Python", "R")), "earnings"))
    +  sum3 <- collect(sum(pivot(groupBy(df, "year"), "course", list("Python", "R")), "earnings"))
    +
    +  correct_answer <- data.frame(
    +    year = c(2013, 2014, 2015, 2016),
    +    Python = c(10000, 15000, 20000, 22000),
    +    R = c(10000, 11000, 12000, 21000)
    +  )
    +  expect_equal(sum1, correct_answer)
    +  expect_equal(sum2, correct_answer)
    +  expect_equal(sum3, correct_answer)
    --- End diff --
    
    Minor: Can we add a test case that fails on the unique check that we have ? We can use
`expect_error` for this


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message