-
Notifications
You must be signed in to change notification settings - Fork 4.2k
ARROW-6649: [R] print methods for Array, ChunkedArray, Table, RecordBatch #5492
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
Changes from 1 commit
2d4e744
6be0328
5750100
02afb89
c092d30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ test_that("RecordBatch", { | |
| schema( | ||
| int = int32(), dbl = float64(), | ||
| lgl = boolean(), chr = utf8(), | ||
| fct = dictionary(int32(), Array$create(letters[1:10])) | ||
| fct = dictionary() | ||
| ) | ||
| ) | ||
| expect_equal(batch$num_columns, 5L) | ||
|
|
@@ -69,12 +69,12 @@ test_that("RecordBatch", { | |
| col_fct <- batch$column(4) | ||
| expect_true(inherits(col_fct, 'Array')) | ||
| expect_equal(col_fct$as_vector(), tbl$fct) | ||
| expect_equal(col_fct$type, dictionary(int32(), Array$create(letters[1:10]))) | ||
| expect_equal(col_fct$type, dictionary()) | ||
|
|
||
| batch2 <- batch$RemoveColumn(0) | ||
| expect_equal( | ||
| batch2$schema, | ||
| schema(dbl = float64(), lgl = boolean(), chr = utf8(), fct = dictionary(int32(), Array$create(letters[1:10]))) | ||
| schema(dbl = float64(), lgl = boolean(), chr = utf8(), fct = dictionary()) | ||
| ) | ||
| expect_equal(batch2$column(0), batch$column(1)) | ||
| expect_identical(as.data.frame(batch2), tbl[,-1]) | ||
|
|
@@ -120,6 +120,23 @@ test_that("head and tail on RecordBatch", { | |
| expect_identical(as.data.frame(tail(batch, -4)), tail(tbl, -4)) | ||
| }) | ||
|
|
||
| test_that("RecordBatch print method", { | ||
| expect_output( | ||
| print(batch), | ||
| paste( | ||
| "RecordBatch", | ||
| "10 rows x 5 columns", | ||
| "$int <int32>", | ||
| "$dbl <double>", | ||
| "$lgl <bool>", | ||
| "$chr <string>", | ||
| "$fct <dictionary<values=string, indices=int8, ordered=0>>", | ||
|
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. Just for the record, R doesn't have boolean values? ("ordered=0")
Member
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. It does, but this is coming straight from the C++
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. I suppose it's fine then.
Member
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. I added some munging in 02afb89#diff-63df045aa8aff63fdd460b816987ba0dR65-R69 |
||
| sep = "\n" | ||
| ), | ||
| fixed = TRUE | ||
| ) | ||
| }) | ||
|
|
||
| test_that("RecordBatch with 0 rows are supported", { | ||
| tbl <- tibble::tibble( | ||
| int = integer(), | ||
|
|
@@ -139,7 +156,7 @@ test_that("RecordBatch with 0 rows are supported", { | |
| dbl = float64(), | ||
| lgl = boolean(), | ||
| chr = utf8(), | ||
| fct = dictionary(int32(), Array$create(c("a", "b"))) | ||
| fct = dictionary() | ||
| ) | ||
| ) | ||
| }) | ||
|
|
||
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.
Looks weird to have default values for the type parameters.
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.
Maybe so, but this is what an R
factortype gets translated to, so it seemed reasonable.