library(R8.io)
dir <- file.path(tempdir(), "files")
dir.create(dir, showWarnings = FALSE)17 Parquet and time zones
A Parquet file stores the type of each column, and R8.io reads it with the same functions and arguments as a CSV file, by the extension .parquet or format = "parquet". A date-time without an offset, in either format, is the reading of a clock in time_zone.
17.1 Stored types
Without a type, a column has the type that the file stores:
| Parquet | R8 |
|---|---|
| BOOLEAN | logical |
| INT32, INT64, and the other integers | integer where every value is one of R8’s integers, double where every value is within 2^53, and text otherwise |
| FLOAT, DOUBLE | double |
| STRING, ENUM, JSON, UUID | text |
| DATE | date |
| TIMESTAMP | date-time; one not adjusted to UTC is the clock reading of time_zone |
| DECIMAL | integer at scale 0, and double otherwise |
A string is text, whatever it holds. A raw BYTE_ARRAY, INT96, TIME, and a nested or repeated column are an error that names the column.
doses <- file.path(dir, "doses.parquet")
nanoparquet::write_parquet(
data.frame(id = c(1, 2.5, 3), mg = c("40", "80", "x")),
doses
)
r8read_table(doses)<raven table> 3 rows ⨉ 2 columns id mg double character 1 1.0 40 2 2.5 80 3 3.0 x
17.2 With a type
A stored value is read where it is of the declared type exactly: a whole double as an integer, an integer within 2^53 as a double, a date-time at midnight as a date, and any value as text. A string reads as a text of a CSV cell does, so a column of strings is read as the numbers it holds where the type declares numbers. Another value does not read, and is reported by its text as a CSV file holds it:
Doses <- new_table_type("Doses", columns = list(
id = type_integer(),
mg = option(type_integer())
))
r8read_table(doses, Doses)Error:
! `doses.parquet` does not read as `demo::Doses`: 2 cells of 3 rows
id "2.5" 1 cell, first in row 2
mg "x" 1 cell, first in row 3
`recode_in` gives what each text reads as, and `na_strings_in` those that are missing:
recode_in = list(id = c("2.5" = ), mg = c("x" = ))
r8check_file(doses, Doses) gives a report.
recode_in and na_strings_in name those texts, as for a CSV file (Texts that do not read):
r8read_table(
doses,
Doses,
recode_in = list(id = c("2.5" = 2L)),
na_strings_in = list(mg = "x")
)<demo::Doses table> 3 rows ⨉ 2 columns id mg integer integer 1 NA 1 1 40 2 2 80 3 3 NA
17.3 Time zones
A date-time without an offset, a CSV text such as 2026-03-10 08:15:00 or a Parquet TIMESTAMP that is not adjusted to UTC, is the instant at which a clock in time_zone shows it. time_zone is an IANA name, "UTC" by default, from the database of zones that the package holds, the same on every platform:
visits <- file.path(dir, "visits.csv")
writeLines(c(
"id,seen",
"1,2026-03-07 23:30:00",
"2,2026-03-08T07:30:00Z"
), visits)
r8read_table(visits, time_zone = "America/New_York")$seen[1] "2026-03-08 04:30:00 UTC" "2026-03-08 07:30:00 UTC"
The first reading is 23:30 in New York, 04:30 the next day in UTC; the second has its offset, and time_zone does not apply to it. A clock reading that the zone skips or shows twice, at a change of daylight saving time, does not read. In New York, the clocks of 2026-03-08 move from 02:00 to 03:00, so 02:30 is no instant there. Without a type, its column is text:
skipped <- file.path(dir, "skipped.csv")
writeLines(c("id,seen", "1,2026-03-08 01:30:00", "2,2026-03-08 02:30:00"), skipped)
r8read_table(skipped, time_zone = "America/New_York")<raven table> 2 rows ⨉ 2 columns id seen integer character 1 1 2026-03-08 01:30:00 2 2 2026-03-08 02:30:00
With a type, it is a text that does not read, which a decision names:
Visits <- new_table_type("Visits", columns = list(
id = type_integer(),
seen = type_posixct()
))
r8read_table(skipped, Visits, time_zone = "America/New_York")Error:
! `skipped.csv` does not read as `demo::Visits`: 1 cell of 2 rows
seen "2026-03-08 02:30:00" 1 cell, first in row 2
`recode_in` gives what each text reads as, and `na_strings_in` those that are missing:
recode_in = list(seen = c("2026-03-08 02:30:00" = ))
r8check_file(skipped, Visits) gives a report.