Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions r/R/arrowExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions r/R/parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ ParquetArrowReaderProperties <- R6Class("ParquetArrowReaderProperties",
},
set_read_dictionary = function(column_index, read_dict) {
parquet___arrow___ArrowReaderProperties__set_read_dictionary(self, column_index, read_dict)
},
coerce_int96_timestamp_unit = function() {
parquet___arrow___ArrowReaderProperties__get_coerce_int96_timestamp_unit(self)
},
set_coerce_int96_timestamp_unit = function(unit) {
parquet___arrow___ArrowReaderProperties__set_coerce_int96_timestamp_unit(self, unit)
}
),
active = list(
Expand Down
34 changes: 34 additions & 0 deletions r/src/arrowExports.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions r/src/parquet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ void parquet___arrow___ArrowReaderProperties__set_read_dictionary(
properties->set_read_dictionary(column_index, read_dict);
}

// [[parquet::export]]
void parquet___arrow___ArrowReaderProperties__set_coerce_int96_timestamp_unit(
const std::shared_ptr<parquet::ArrowReaderProperties>& properties,
arrow::TimeUnit::type unit) {
properties->set_coerce_int96_timestamp_unit(unit);
}

// [[parquet::export]]
arrow::TimeUnit::type
parquet___arrow___ArrowReaderProperties__get_coerce_int96_timestamp_unit(
const std::shared_ptr<parquet::ArrowReaderProperties>& properties) {
return properties->coerce_int96_timestamp_unit();
}

// [[parquet::export]]
std::shared_ptr<parquet::arrow::FileReader> parquet___arrow___FileReader__OpenFile(
const std::shared_ptr<arrow::io::RandomAccessFile>& file,
Expand Down
28 changes: 28 additions & 0 deletions r/tests/testthat/test-parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,31 @@ test_that("ParquetFileWrite chunk_size calculation doesn't have integer overflow
# but our max_chunks is respected
expect_equal(calculate_chunk_size(101, 1, 25, 2), 51)
})

test_that("deprecated int96 timestamp unit can be specified when reading Parquet files", {
tf <- tempfile()
on.exit(unlink(tf))

table <- Table$create(
some_datetime = as.POSIXct("2001-01-01 12:34:56.789")
)

write_parquet(
table,
tf,
use_deprecated_int96_timestamps = TRUE
)

props <- ParquetArrowReaderProperties$create()
props$set_coerce_int96_timestamp_unit(TimeUnit$MILLI)
expect_identical(props$coerce_int96_timestamp_unit(), TimeUnit$MILLI)

result <- read_parquet(
tf,
as_data_frame = FALSE,
props = props
)

expect_identical(result$some_datetime$type$unit(), TimeUnit$MILLI)
expect_true(result$some_datetime == table$some_datetime)
})