paleolimbot commented on pull request #11690:
URL: https://github.com/apache/arrow/pull/11690#issuecomment-977160148
Ok...this has improved semantics for data.frame and better errors for tibble
with respect to duplicate/missing names for columns.
``` r
library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
df <- data.frame(a = 1)
# "normal"
df %>% mutate(df_col = tibble(a2 = a)) %>% collect()
#> Warning in format.data.frame(if (omit) x[seq_len(n0), , drop = FALSE]
else x, :
#> corrupt data frame: columns will be truncated or padded with NAs
#> a df_col
#> 1 1 # A tibble: 1 × 1
df %>% mutate(df_col = data.frame(a2 = a)) %>% collect()
#> a a2
#> 1 1 1
# duplicated cols
df %>% mutate(df_col = tibble(a, a)) %>% collect()
#> Error: Problem with `mutate()` column `df_col`.
#> ℹ `df_col = tibble(a, a)`.
#> x Column name `a` must not be duplicated.
#> Use .name_repair to specify repair.
df %>% mutate(df_col = data.frame(a, a)) %>% collect()
#> a df_col.a df_col.a.1
#> 1 1 1 1
df %>% mutate(df_col = data.frame(a, a, check.names = FALSE)) %>% collect()
#> a df_col.a df_col.a
#> 1 1 1 1
# empty names
df %>%
mutate(df_col = data.frame(a, check.names = TRUE, fix.empty.names = TRUE))
%>%
collect()
#> a a
#> 1 1 1
df %>%
mutate(df_col = data.frame(a, check.names = TRUE, fix.empty.names =
FALSE)) %>%
collect()
#> a
#> 1 1 1
df %>%
mutate(df_col = data.frame(a, check.names = FALSE, fix.empty.names =
TRUE)) %>%
collect()
#> a a
#> 1 1 1
df %>%
mutate(df_col = data.frame(a, check.names = FALSE, fix.empty.names =
FALSE)) %>%
collect()
#> a
#> 1 1 1
# ignored
df %>% mutate(df_col = data.frame(a, check.rows = TRUE)) %>% collect()
#> a a
#> 1 1 1
df %>% mutate(df_col = data.frame(a, row.names = TRUE)) %>% collect()
#> a a
#> 1 1 1
```
<sup>Created on 2021-11-23 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]