-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-12034][SPARKR] Eliminate warnings in SparkR test cases. #10030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,38 +133,45 @@ test_that("create DataFrame from RDD", { | |
| expect_equal(columns(df), c("a", "b")) | ||
| expect_equal(dtypes(df), list(c("a", "int"), c("b", "string"))) | ||
|
|
||
| df <- jsonFile(sqlContext, jsonPathNa) | ||
| hiveCtx <- tryCatch({ | ||
| newJObject("org.apache.spark.sql.hive.test.TestHiveContext", ssc) | ||
| }, | ||
| error = function(err) { | ||
| skip("Hive is not build with SparkSQL, skipped") | ||
| }) | ||
| sql(hiveCtx, "CREATE TABLE people (name string, age double, height float)") | ||
| insertInto(df, "people") | ||
| expect_equal(sql(hiveCtx, "SELECT age from people WHERE name = 'Bob'"), c(16)) | ||
| expect_equal(sql(hiveCtx, "SELECT height from people WHERE name ='Bob'"), c(176.5)) | ||
|
|
||
| schema <- structType(structField("name", "string"), structField("age", "integer"), | ||
| structField("height", "float")) | ||
| df2 <- createDataFrame(sqlContext, df.toRDD, schema) | ||
| df2AsDF <- as.DataFrame(sqlContext, df.toRDD, schema) | ||
| df <- read.df(sqlContext, jsonPathNa, "json", schema) | ||
| df2 <- createDataFrame(sqlContext, toRDD(df), schema) | ||
| df2AsDF <- as.DataFrame(sqlContext, toRDD(df), schema) | ||
| expect_equal(columns(df2), c("name", "age", "height")) | ||
| expect_equal(columns(df2AsDF), c("name", "age", "height")) | ||
| expect_equal(dtypes(df2), list(c("name", "string"), c("age", "int"), c("height", "float"))) | ||
| expect_equal(dtypes(df2AsDF), list(c("name", "string"), c("age", "int"), c("height", "float"))) | ||
| expect_equal(collect(where(df2, df2$name == "Bob")), c("Bob", 16, 176.5)) | ||
| expect_equal(collect(where(df2AsDF, df2$name == "Bob")), c("Bob", 16, 176.5)) | ||
| expect_equal(as.list(collect(where(df2, df2$name == "Bob"))), | ||
| list(name = "Bob", age = 16, height = 176.5)) | ||
| expect_equal(as.list(collect(where(df2AsDF, df2AsDF$name == "Bob"))), | ||
| list(name = "Bob", age = 16, height = 176.5)) | ||
|
|
||
| localDF <- data.frame(name=c("John", "Smith", "Sarah"), | ||
| age=c(19, 23, 18), | ||
| height=c(164.10, 181.4, 173.7)) | ||
| age=c(19L, 23L, 18L), | ||
| height=c(176.5, 181.4, 173.7)) | ||
| df <- createDataFrame(sqlContext, localDF, schema) | ||
| expect_is(df, "DataFrame") | ||
| expect_equal(count(df), 3) | ||
| expect_equal(columns(df), c("name", "age", "height")) | ||
| expect_equal(dtypes(df), list(c("name", "string"), c("age", "int"), c("height", "float"))) | ||
| expect_equal(collect(where(df, df$name == "John")), c("John", 19, 164.10)) | ||
| expect_equal(as.list(collect(where(df, df$name == "John"))), | ||
| list(name = "John", age = 19L, height = 176.5)) | ||
|
|
||
| ssc <- callJMethod(sc, "sc") | ||
| hiveCtx <- tryCatch({ | ||
| newJObject("org.apache.spark.sql.hive.test.TestHiveContext", ssc) | ||
| }, | ||
| error = function(err) { | ||
| skip("Hive is not build with SparkSQL, skipped") | ||
| }) | ||
| sql(hiveCtx, "CREATE TABLE people (name string, age double, height float)") | ||
| df <- read.df(hiveCtx, jsonPathNa, "json", schema) | ||
| invisible(insertInto(df, "people")) | ||
| expect_equal(collect(sql(hiveCtx, "SELECT age from people WHERE name = 'Bob'"))$age, | ||
| c(16)) | ||
| expect_equal(collect(sql(hiveCtx, "SELECT height from people WHERE name ='Bob'"))$height, | ||
| c(176.5)) | ||
| }) | ||
|
|
||
| test_that("convert NAs to null type in DataFrames", { | ||
|
|
@@ -250,7 +257,7 @@ test_that("create DataFrame from list or data.frame", { | |
| ldf2 <- collect(df) | ||
| expect_equal(ldf$a, ldf2$a) | ||
|
|
||
| irisdf <- createDataFrame(sqlContext, iris) | ||
| irisdf <- suppressWarnings(createDataFrame(sqlContext, iris)) | ||
| iris_collected <- collect(irisdf) | ||
| expect_equivalent(iris_collected[,-5], iris[,-5]) | ||
| expect_equal(iris_collected$Species, as.character(iris$Species)) | ||
|
|
@@ -463,7 +470,7 @@ test_that("union on two RDDs created from DataFrames returns an RRDD", { | |
| RDD2 <- toRDD(df) | ||
| unioned <- unionRDD(RDD1, RDD2) | ||
| expect_is(unioned, "RDD") | ||
| expect_equal(SparkR:::getSerializedMode(unioned), "byte") | ||
| expect_equal(getSerializedMode(unioned), "byte") | ||
| expect_equal(collect(unioned)[[2]]$name, "Andy") | ||
| }) | ||
|
|
||
|
|
@@ -485,13 +492,13 @@ test_that("union on mixed serialization types correctly returns a byte RRDD", { | |
|
|
||
| unionByte <- unionRDD(rdd, dfRDD) | ||
| expect_is(unionByte, "RDD") | ||
| expect_equal(SparkR:::getSerializedMode(unionByte), "byte") | ||
| expect_equal(getSerializedMode(unionByte), "byte") | ||
| expect_equal(collect(unionByte)[[1]], 1) | ||
| expect_equal(collect(unionByte)[[12]]$name, "Andy") | ||
|
|
||
| unionString <- unionRDD(textRDD, dfRDD) | ||
| expect_is(unionString, "RDD") | ||
| expect_equal(SparkR:::getSerializedMode(unionString), "byte") | ||
| expect_equal(getSerializedMode(unionString), "byte") | ||
| expect_equal(collect(unionString)[[1]], "Michael") | ||
| expect_equal(collect(unionString)[[5]]$name, "Andy") | ||
| }) | ||
|
|
@@ -504,7 +511,7 @@ test_that("objectFile() works with row serialization", { | |
| objectIn <- objectFile(sc, objectPath) | ||
|
|
||
| expect_is(objectIn, "RDD") | ||
| expect_equal(SparkR:::getSerializedMode(objectIn), "byte") | ||
| expect_equal(getSerializedMode(objectIn), "byte") | ||
| expect_equal(collect(objectIn)[[2]]$age, 30) | ||
| }) | ||
|
|
||
|
|
@@ -849,6 +856,7 @@ test_that("write.df() as parquet file", { | |
| }) | ||
|
|
||
| test_that("test HiveContext", { | ||
| ssc <- callJMethod(sc, "sc") | ||
| hiveCtx <- tryCatch({ | ||
| newJObject("org.apache.spark.sql.hive.test.TestHiveContext", ssc) | ||
| }, | ||
|
|
@@ -863,10 +871,10 @@ test_that("test HiveContext", { | |
| expect_equal(count(df2), 3) | ||
|
|
||
| jsonPath2 <- tempfile(pattern="sparkr-test", fileext=".tmp") | ||
| saveAsTable(df, "json", "json", "append", path = jsonPath2) | ||
| df3 <- sql(hiveCtx, "select * from json") | ||
| invisible(saveAsTable(df, "json2", "json", "append", path = jsonPath2)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is invisible necessary here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to avoid printing NULL in the console. Maybe not necessary within |
||
| df3 <- sql(hiveCtx, "select * from json2") | ||
| expect_is(df3, "DataFrame") | ||
| expect_equal(count(df3), 6) | ||
| expect_equal(count(df3), 3) | ||
| }) | ||
|
|
||
| test_that("column operators", { | ||
|
|
@@ -1311,7 +1319,7 @@ test_that("toJSON() returns an RDD of the correct values", { | |
| df <- jsonFile(sqlContext, jsonPath) | ||
| testRDD <- toJSON(df) | ||
| expect_is(testRDD, "RDD") | ||
| expect_equal(SparkR:::getSerializedMode(testRDD), "string") | ||
| expect_equal(getSerializedMode(testRDD), "string") | ||
| expect_equal(collect(testRDD)[[1]], mockLines[1]) | ||
| }) | ||
|
|
||
|
|
@@ -1641,7 +1649,7 @@ test_that("SQL error message is returned from JVM", { | |
| expect_equal(grepl("Table not found: blah", retError), TRUE) | ||
| }) | ||
|
|
||
| irisDF <- createDataFrame(sqlContext, iris) | ||
| irisDF <- suppressWarnings(createDataFrame(sqlContext, iris)) | ||
|
|
||
| test_that("Method as.data.frame as a synonym for collect()", { | ||
| expect_equal(as.data.frame(irisDF), collect(irisDF)) | ||
|
|
@@ -1670,7 +1678,7 @@ test_that("attach() on a DataFrame", { | |
| }) | ||
|
|
||
| test_that("with() on a DataFrame", { | ||
| df <- createDataFrame(sqlContext, iris) | ||
| df <- suppressWarnings(createDataFrame(sqlContext, iris)) | ||
| expect_error(Sepal_Length) | ||
| sum1 <- with(df, list(summary(Sepal_Length), summary(Sepal_Width))) | ||
| expect_equal(collect(sum1[[1]])[1, "Sepal_Length"], "150") | ||
|
|
||
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,4 +18,7 @@ | |
| library(testthat) | ||
| library(SparkR) | ||
|
|
||
| # Turn all warnings into errors | ||
| options("warn" = 2) | ||
|
|
||
| test_package("SparkR") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a note in JIRA SPARK-11976 that once that is fixed we should remove
suppressWarningsaround DF from iris?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are a number of suppressWarnings in this PR. Instead of adding notes for them in this PR, I'd like to add a note in SPARK-11976 that cleaning these warnings is part of the job. Is it OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, that's what I mean, add a note in SPARK-11976 to remove these.
alternatively, we could open another JIRA to change all these tests to use a different data frame that doesn't have column names with
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added note in SPARK-11976