Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/7419#discussion_r34908453
--- Diff: R/pkg/R/deserialize.R ---
@@ -174,11 +174,46 @@ readRow <- function(inputCon) {
}
# Take a single column as Array[Byte] and deserialize it into an atomic
vector
-readCol <- function(inputCon, numRows) {
- # sapply can not work with POSIXlt
- do.call(c, lapply(1:numRows, function(x) {
- value <- readObject(inputCon)
- # Replace NULL with NA so we can coerce to vectors
- if (is.null(value)) NA else value
- }))
+readCol <- function(inputCon, numRows, colType) {
+ if (numRows > 0) {
+ # sapply can not work with POSIXlt
+ do.call(c, lapply(1:numRows, function(x) {
+ value <- readObject(inputCon)
+ # Replace NULL with NA so we can coerce to vectors
+ if (is.null(value)) NA else value
+ }))
+ } else {
+ vector(mode = colType)
--- End diff --
So fundamentally it looks like this we want to create a vector with `mode =
colType` if the column is empty. But does it matter if we get the `colType`
wrong ? i.e. what happens if we just use the default mode (which I think is
`logical`)
---
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]