Skip to content

Commit

Permalink
rapi_get_last_rel_mat()
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Oct 27, 2024
1 parent 19f983a commit 26a4926
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ rapi_rel_from_table_function <- function(con, function_name, positional_paramete
.Call(`_duckdb_rapi_rel_from_table_function`, con, function_name, positional_parameters_sexps, named_parameters_sexps)
}

rapi_get_last_rel_mat <- function() {
.Call(`_duckdb_rapi_get_last_rel_mat`)
}

# allow_materialization = TRUE: compatibility with duckplyr <= 0.4.1
rapi_rel_to_altrep <- function(rel, allow_materialization = TRUE) {
.Call(`_duckdb_rapi_rel_to_altrep`, rel, allow_materialization)
Expand Down
8 changes: 8 additions & 0 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ extern "C" SEXP _duckdb_rapi_rel_from_table_function(SEXP con, SEXP function_nam
END_CPP11
}
// reltoaltrep.cpp
std::string rapi_get_last_rel_mat();
extern "C" SEXP _duckdb_rapi_get_last_rel_mat() {
BEGIN_CPP11
return cpp11::as_sexp(rapi_get_last_rel_mat());
END_CPP11
}
// reltoaltrep.cpp
SEXP rapi_rel_to_altrep(duckdb::rel_extptr_t rel, bool allow_materialization);
extern "C" SEXP _duckdb_rapi_rel_to_altrep(SEXP rel, SEXP allow_materialization) {
BEGIN_CPP11
Expand Down Expand Up @@ -445,6 +452,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_duckdb_rapi_expr_set_alias", (DL_FUNC) &_duckdb_rapi_expr_set_alias, 2},
{"_duckdb_rapi_expr_tostring", (DL_FUNC) &_duckdb_rapi_expr_tostring, 1},
{"_duckdb_rapi_expr_window", (DL_FUNC) &_duckdb_rapi_expr_window, 9},
{"_duckdb_rapi_get_last_rel_mat", (DL_FUNC) &_duckdb_rapi_get_last_rel_mat, 0},
{"_duckdb_rapi_get_null_SEXP_ptr", (DL_FUNC) &_duckdb_rapi_get_null_SEXP_ptr, 0},
{"_duckdb_rapi_get_substrait", (DL_FUNC) &_duckdb_rapi_get_substrait, 3},
{"_duckdb_rapi_get_substrait_json", (DL_FUNC) &_duckdb_rapi_get_substrait_json, 3},
Expand Down
7 changes: 7 additions & 0 deletions src/reltoaltrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ static R_altrep_class_t LogicalTypeToAltrepType(const LogicalType &type) {
}
}

[[cpp11::register]] std::string rapi_get_last_rel_mat() {
if (!AltrepRelationWrapper::last_rel) {
return "";
}
return AltrepRelationWrapper::last_rel->ToString();
}

[[cpp11::register]] SEXP rapi_rel_to_altrep(duckdb::rel_extptr_t rel, bool allow_materialization) {
D_ASSERT(rel && rel->rel);
auto drel = rel->rel;
Expand Down

0 comments on commit 26a4926

Please sign in to comment.