Skip to content

Timezone is ignored when writing pins as a "parquet" #870

@atsyplenkov

Description

@atsyplenkov

Due to an upstream bug in nanoparquet (see r-lib/nanoparquet#140), the timezone argument of a POSIXct data type is ignored when using type = parquet in pins::write_pin. See a reprex below:

library(dplyr)
library(lubridate)
library(pins)

set.seed(123)
df <-
  storms |>
  dplyr::slice_sample(n = 1000) |>
  dplyr::mutate(
    name,
    datetime = lubridate::make_datetime(year,month,day,hour,tz = "UTC"),
    datetime_tz = lubridate::with_tz(datetime, "America/New_York"),
    .keep = "none"
  )

# Compare timezones
waldo::compare(
  lubridate::tz(df$datetime),
  lubridate::tz(df$datetime_tz)
)
#> `old`: "UTC"             
#> `new`: "America/New_York"

# Save as a parquet pin
board <- pins::board_temp()
pins::pin_write(board, df, name = "test", type = "parquet")
#> Creating new version '20250619T004531Z-fb1d7'
#> Writing to pin 'test'

df_read <- pins::pin_read(board, "test")

# Should be "America/New_York"
lubridate::tz(df_read$datetime_tz)
#> [1] "UTC"

# Compare timezones
waldo::compare(
  lubridate::tz(df_read$datetime),
  lubridate::tz(df_read$datetime_tz)
)
#> ✔ No differences

Created on 2025-06-19 with reprex v2.1.1

I am using nanoparquet_0.4.2 and pins_1.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions