nealrichardson commented on a change in pull request #7514: URL: https://github.com/apache/arrow/pull/7514#discussion_r443733083
########## File path: r/src/array_from_vector.cpp ########## @@ -1067,12 +1110,22 @@ std::shared_ptr<arrow::DataType> InferArrowTypeFromVector<VECSXP>(SEXP x) { if (Rf_inherits(x, "data.frame")) { return InferArrowTypeFromDataFrame(x); } else { - if (XLENGTH(x) == 0) { - Rcpp::stop( - "Requires at least one element to infer the values' type of a list vector"); - } + SEXP ptype = Rf_getAttrib(x, symbols::ptype); + if (ptype == R_NilValue) { Review comment: is this the same as `Rf_isNull()` (which I think we use more generally)? ########## File path: r/src/array_from_vector.cpp ########## @@ -1067,12 +1110,22 @@ std::shared_ptr<arrow::DataType> InferArrowTypeFromVector<VECSXP>(SEXP x) { if (Rf_inherits(x, "data.frame")) { return InferArrowTypeFromDataFrame(x); } else { - if (XLENGTH(x) == 0) { - Rcpp::stop( - "Requires at least one element to infer the values' type of a list vector"); - } + SEXP ptype = Rf_getAttrib(x, symbols::ptype); + if (ptype == R_NilValue) { + if (XLENGTH(x) == 0) { + Rcpp::stop( + "Requires at least one element to infer the values' type of a list vector"); + } - return arrow::list(InferArrowType(VECTOR_ELT(x, 0))); + return arrow::list(InferArrowType(VECTOR_ELT(x, 0))); + } else { + // special case list(raw()) -> BinaryArray + if (TYPEOF(ptype) == RAWSXP) { + return arrow::binary(); + } + + return arrow::list(InferArrowType(ptype)); Review comment: If I read this correctly, you're introducing general support for `vctrs::list_of ptype` here? IIUC then it would make sense for the ListArray to R vector conversion to set that class and attribute too then, right? (If so, feel free to add that here or defer to a followup) ########## File path: r/src/array_to_vector.cpp ########## @@ -693,6 +741,9 @@ std::shared_ptr<Converter> Converter::Make(const std::shared_ptr<DataType>& type case Type::BOOL: return std::make_shared<arrow::r::Converter_Boolean>(std::move(arrays)); + case Type::BINARY: Review comment: See also https://jira.apache.org/jira/browse/ARROW-6543 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org