Skip to content
Merged
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
1 change: 1 addition & 0 deletions R/aaa-meta.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Overwritten in meta.R
meta_ext_register <- function(...) {}
meta_rel_register <- function(...) {}
meta_rel_register_df <- function(...) {}
meta_rel_register_file <- function(...) {}
Expand Down
1 change: 0 additions & 1 deletion R/relational-duckdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ duckplyr_macros <- c(
# "as.Date" = '(x) AS strptime(x, \'%Y-%m-%d\')',

"grepl" = "(pattern, x) AS (CASE WHEN x IS NULL THEN FALSE ELSE regexp_matches(x, pattern) END)",
"as.integer" = "(x) AS CAST(x AS int32)",
"if_else" = "(test, yes, no) AS (CASE WHEN test THEN yes ELSE no END)",
"|" = "(x, y) AS (x OR y)",
"&" = "(x, y) AS (x AND y)",
Expand Down
7 changes: 6 additions & 1 deletion R/relational.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ rel_translate <- function(
"/" = "___divide",
"log10" = "___log10",
"log" = "___log",
"as.integer" = "r_base::as.integer",
NULL
)

Expand Down Expand Up @@ -263,6 +264,9 @@ rel_translate <- function(

if (name %in% names(aliases)) {
name <- aliases[[name]]
if (grepl("^r_base::", name)) {
meta_ext_register()
}
}
# name <- aliases[name] %|% name

Expand Down Expand Up @@ -309,7 +313,8 @@ rel_translate <- function(
)

if (name == "row_number") {
fun <- relexpr_function("as.integer", list(fun))
fun <- relexpr_function("r_base::as.integer", list(fun))
meta_ext_register()
}
}
fun
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_07.R
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ tpch_raw_07 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_08.R
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ tpch_raw_08 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_09.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ tpch_raw_09 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_oo_07.R
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ tpch_raw_oo_07 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_oo_08.R
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ tpch_raw_oo_08 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
2 changes: 1 addition & 1 deletion R/tpch_raw_oo_09.R
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ tpch_raw_oo_09 <- function(con, experimental) {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-rel_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -8990,7 +8990,7 @@ test_that("relational mutate(d = row_number()) order-preserving", {
drv <- duckdb::duckdb()
con <- DBI::dbConnect(drv)
experimental <- FALSE
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
df1 <- data.frame(a = seq(1, 6, by = 1), b = rep(2, 6L), g = c(1L, 2L, 2L, 3L, 3L, 3L))

rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand All @@ -9014,7 +9014,7 @@ test_that("relational mutate(d = row_number()) order-preserving", {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
)
Expand All @@ -9039,7 +9039,7 @@ test_that("relational mutate(d = row_number(), .by = g) order-preserving", {
drv <- duckdb::duckdb()
con <- DBI::dbConnect(drv)
experimental <- FALSE
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
df1 <- data.frame(a = seq(1, 6, by = 1), b = rep(2, 6L), g = c(1L, 2L, 2L, 3L, 3L, 3L))

rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand Down Expand Up @@ -9093,7 +9093,7 @@ test_that("relational mutate(d = row_number(), .by = g) order-preserving", {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_window(duckdb$expr_function("row_number", list()), list(duckdb$expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
)
Expand Down Expand Up @@ -12941,7 +12941,7 @@ test_that("relational mutate(d = row_number()) order-enforcing", {
drv <- duckdb::duckdb()
con <- DBI::dbConnect(drv)
experimental <- FALSE
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
df1 <- data.frame(a = seq(1, 6, by = 1), b = rep(2, 6L), g = c(1L, 2L, 2L, 3L, 3L, 3L))

rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand All @@ -12965,7 +12965,7 @@ test_that("relational mutate(d = row_number()) order-enforcing", {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
)
Expand Down Expand Up @@ -12994,7 +12994,7 @@ test_that("relational mutate(d = row_number(), .by = g) order-enforcing", {
drv <- duckdb::duckdb()
con <- DBI::dbConnect(drv)
experimental <- FALSE
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
df1 <- data.frame(a = seq(1, 6, by = 1), b = rep(2, 6L), g = c(1L, 2L, 2L, 3L, 3L, 3L))

rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand All @@ -13018,7 +13018,7 @@ test_that("relational mutate(d = row_number(), .by = g) order-enforcing", {
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_window(duckdb$expr_function("row_number", list()), list(duckdb$expr_reference("g")), list(), offset_expr = NULL, default_expr = NULL)
)
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw-oo/07.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y
invisible(DBI::dbExecute(con, 'CREATE MACRO ">="(x, y) AS "r_base::>="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "<="(x, y) AS "r_base::<="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "&"(x, y) AS (x AND y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
df1 <- supplier
rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
rel2 <- duckdb$rel_project(
Expand Down Expand Up @@ -1161,7 +1160,7 @@ rel70 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw-oo/08.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ invisible(DBI::dbExecute(con, 'CREATE MACRO "=="(x, y) AS "r_base::=="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO ">="(x, y) AS "r_base::>="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "<="(x, y) AS "r_base::<="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(
DBI::dbExecute(
con,
Expand Down Expand Up @@ -1168,7 +1167,7 @@ rel87 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw-oo/09.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ invisible(
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
invisible(DBI::dbExecute(con, 'CREATE MACRO "=="(x, y) AS "r_base::=="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "desc"(x) AS (-x)'))
df1 <- part
rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand Down Expand Up @@ -880,7 +879,7 @@ rel57 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw/07.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y
invisible(DBI::dbExecute(con, 'CREATE MACRO ">="(x, y) AS "r_base::>="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "<="(x, y) AS "r_base::<="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "&"(x, y) AS (x AND y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
df1 <- supplier
rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
rel2 <- duckdb$rel_project(
Expand Down Expand Up @@ -697,7 +696,7 @@ rel43 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw/08.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ invisible(DBI::dbExecute(con, 'CREATE MACRO "=="(x, y) AS "r_base::=="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO ">="(x, y) AS "r_base::>="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "<="(x, y) AS "r_base::<="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(
DBI::dbExecute(
con,
Expand Down Expand Up @@ -707,7 +706,7 @@ rel57 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down
3 changes: 1 addition & 2 deletions tools/tpch-raw/09.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ invisible(
invisible(duckdb$rapi_load_rfuns(drv@database_ref))
invisible(DBI::dbExecute(con, 'CREATE MACRO "=="(x, y) AS "r_base::=="(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "___coalesce"(x, y) AS COALESCE(x, y)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "as.integer"(x) AS CAST(x AS int32)'))
invisible(DBI::dbExecute(con, 'CREATE MACRO "desc"(x) AS (-x)'))
df1 <- part
rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
Expand Down Expand Up @@ -569,7 +568,7 @@ rel39 <- duckdb$rel_project(
},
{
tmp_expr <- duckdb$expr_function(
"as.integer",
"r_base::as.integer",
list(
duckdb$expr_function(
"strftime",
Expand Down