Skip to content
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

fst_table returns a zero-row table when using ft[0, ] syntax #237

Open
MarcusKlik opened this issue Apr 3, 2020 · 0 comments
Open

fst_table returns a zero-row table when using ft[0, ] syntax #237

MarcusKlik opened this issue Apr 3, 2020 · 0 comments
Assignees
Labels
Milestone

Comments

@MarcusKlik
Copy link
Collaborator

A fst_table object is expected to mimic the behavior of a data.frame. Therefore, df[0, ] syntax should return a zero-row table without an error or warning:

tmp_file <- tempfile(".fst")

# write some data
x <- data.frame(X = 1:1000, Y = sample(1:10, 1000, replace = TRUE)) %>%
  fst::write_fst(tmp_file)


# get reference to file
fst_table <- fst::fst(tmp_file)

# identical
x[1, ]
#>   X Y
#> 1 1 1
fst_table[1, ]
#>   X Y
#> 1 1 1

# should be identical
x[0, ]
#> [1] X Y
#> <0 rows> (or 0-length row.names)
fst_table[0, ]
#> Error in read_fst(meta_info$path, from = min_row, to = max_row): Parameter 'from' should have a numerical value equal or larger than 1.

# tibble's also allow zero row syntax
as_tibble(x)[0, ]
#> # A tibble: 0 x 2
#> # ... with 2 variables: X <int>, Y <int>

# as do data.table's
data.table::as.data.table(x)[0. ]
#> Empty data.table (0 rows and 2 cols): X,Y

thanks @hope-data-science for reporting!

@MarcusKlik MarcusKlik added the bug label Apr 3, 2020
@MarcusKlik MarcusKlik added this to the Candidate milestone Apr 3, 2020
@MarcusKlik MarcusKlik self-assigned this Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant