Skip to content

Commit

Permalink
feat: make arrow_binary etc. to blob
Browse files Browse the repository at this point in the history
Signed-off-by: SHIMA Tatsuya <[email protected]>
  • Loading branch information
eitsupi committed Feb 20, 2025
1 parent f6bfa7b commit 4e58234
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Biarch: true
Imports:
assertthat,
bit64 (>= 0.9-7),
blob,
glue,
methods,
purrr,
Expand Down
2 changes: 1 addition & 1 deletion r/R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ remove_attributes <- function(x) {
removed_attributes <- c("row.names", "names")
} else if (inherits(x, "factor")) {
removed_attributes <- c("class", "levels")
} else if (inherits(x, c("integer64", "Date", "arrow_binary", "arrow_large_binary"))) {
} else if (inherits(x, c("integer64", "Date", "blob", "arrow_binary", "arrow_large_binary"))) {
removed_attributes <- c("class")
} else if (inherits(x, "arrow_fixed_size_binary")) {
removed_attributes <- c("class", "byte_width")
Expand Down
3 changes: 2 additions & 1 deletion r/src/arrow_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ static inline bool can_convert_native(SEXP x) {
return Rf_inherits(x, "factor") || Rf_inherits(x, "Date") ||
Rf_inherits(x, "integer64") || Rf_inherits(x, "POSIXct") ||
Rf_inherits(x, "hms") || Rf_inherits(x, "difftime") ||
Rf_inherits(x, "data.frame") || Rf_inherits(x, "arrow_binary") ||
Rf_inherits(x, "data.frame") ||
Rf_inherits(x, "blob") || Rf_inherits(x, "arrow_binary") ||
Rf_inherits(x, "arrow_large_binary") ||
Rf_inherits(x, "arrow_fixed_size_binary") ||
Rf_inherits(x, "vctrs_unspecified") || Rf_inherits(x, "AsIs");
Expand Down
2 changes: 1 addition & 1 deletion r/src/r_to_arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ RVectorType GetVectorType(SEXP x) {
return POSIXLT;
}

if (Rf_inherits(x, "arrow_binary")) {
if (Rf_inherits(x, "arrow_binary") || Rf_inherits(x, "blob")) {
return BINARY;
}

Expand Down
6 changes: 3 additions & 3 deletions r/src/symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ SEXP data::classes_tbl_df =
precious(cpp11::writable::strings({"tbl_df", "tbl", "data.frame"}));

SEXP data::classes_arrow_binary =
precious(cpp11::writable::strings({"arrow_binary", "vctrs_vctr", "list"}));
precious(cpp11::writable::strings({"arrow_binary", "blob", "vctrs_vctr", "list"}));
SEXP data::classes_arrow_large_binary =
precious(cpp11::writable::strings({"arrow_large_binary", "vctrs_vctr", "list"}));
precious(cpp11::writable::strings({"arrow_large_binary", "blob", "vctrs_vctr", "list"}));
SEXP data::classes_arrow_fixed_size_binary =
precious(cpp11::writable::strings({"arrow_fixed_size_binary", "vctrs_vctr", "list"}));
precious(cpp11::writable::strings({"arrow_fixed_size_binary", "blob", "vctrs_vctr", "list"}));
SEXP data::classes_factor = precious(cpp11::writable::strings({"factor"}));
SEXP data::classes_ordered = precious(cpp11::writable::strings({"ordered", "factor"}));

Expand Down
8 changes: 4 additions & 4 deletions r/src/type_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ std::shared_ptr<arrow::DataType> InferArrowTypeFromVector<VECSXP>(SEXP x) {
return arrow::fixed_size_binary(INTEGER(byte_width)[0]);
}

if (Rf_inherits(x, "arrow_binary")) {
return arrow::binary();
}

if (Rf_inherits(x, "arrow_large_binary")) {
return arrow::large_binary();
}

if (Rf_inherits(x, "arrow_binary") || Rf_inherits(x, "blob")) {
return arrow::binary();
}

// Check attr(x, "ptype") for an appropriate R prototype
SEXP ptype = Rf_getAttrib(x, symbols::ptype);
if (!Rf_isNull(ptype)) {
Expand Down

0 comments on commit 4e58234

Please sign in to comment.