-
Notifications
You must be signed in to change notification settings - Fork 190
Fix POSIXt precision and tzone #665
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
Open
r2evans
wants to merge
6
commits into
r-dbi:main
Choose a base branch
from
r2evans:fix/660-posixt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1a8baef
fix #660, POSIXt precision and tzone
r2evans a7ba758
upd test to not skip even if UTC
r2evans 607a9d0
remove digits.secs, default to microseconds always
r2evans ab4a049
tweak tests
r2evans 083a9c1
load tibble
r2evans e471821
make test more specific
r2evans 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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| test_that("'POSIXt' preserves microsecond precision", { | ||
| tbl <- data.frame(psx = trunc.Date(Sys.time(), units = "secs") + 0.123456) | ||
| attr(tbl$psx, "tzone") <- "UTC" | ||
|
|
||
| ds <- bq_table(bq_test_project(), "basedata", "datatypes") | ||
| defer(try(bq_table_delete(ds), silent = TRUE)) | ||
|
|
||
| bq_table_upload(ds, tbl) | ||
| tbl2 <- bq_table_download(ds) | ||
|
|
||
| expect_equal(tbl$psx, tbl2$psx) | ||
| }) | ||
|
|
||
| test_that("'tzone' unset and different values handled correctly", { | ||
| # the bug only produced problems when the system TZ has a non-zero | ||
| # offset (i.e., not UTC) | ||
| withr::local_envvar(TZ = "America/New_York") | ||
|
|
||
| ds <- bq_table(bq_test_project(), "basedata", "datatypes") | ||
| defer(try(bq_table_delete(ds), silent = TRUE)) | ||
|
|
||
| tbl1in <- tibble(psx = trunc.Date(Sys.time(), units = "secs") + 0.123456) | ||
| attr(tbl1in$psx, "tzone") <- NULL | ||
| bq_table_upload(ds, tbl1in) | ||
| tbl1out <- bq_table_download(ds) | ||
| bq_table_delete(ds) | ||
| attr(tbl1out$psx, "tzone") <- NULL | ||
| expect_equal(tbl1in$psx, tbl1out$psx) | ||
| expect_true(abs(as.numeric(tbl5$psx - tbl$psx, units = "hours")) < 1) | ||
r2evans marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| tbl2in <- tibble(psx = trunc.Date(Sys.time(), units = "secs") + 0.123456) | ||
| attr(tbl2in$psx, "tzone") <- "UTC" | ||
| bq_table_upload(ds, tbl2in) | ||
| tbl2out <- bq_table_download(ds) | ||
| bq_table_delete(ds) | ||
| expect_equal(tbl2in$psx, tbl2out$psx) | ||
|
|
||
| tbl3in <- tibble(psx = trunc.Date(Sys.time(), units = "secs") + 0.123456) | ||
| attr(tbl3in$psx, "tzone") <- "America/New_York" | ||
| bq_table_upload(ds, tbl3in) | ||
| tbl3out <- bq_table_download(ds) | ||
| bq_table_delete(ds) | ||
| attr(tbl3out$psx, "tzone") <- attr(tbl3in$psx, "tzone") | ||
| expect_equal(tbl3in$psx, tbl3out$psx) | ||
| }) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.