Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NULL mapped to NA_integer_ #155

Open
krlmlr opened this issue May 4, 2024 · 4 comments · May be fixed by #156
Open

NULL mapped to NA_integer_ #155

krlmlr opened this issue May 4, 2024 · 4 comments · May be fixed by #156
Labels
bug an unexpected problem or unintended behavior

Comments

@krlmlr
Copy link
Collaborator

krlmlr commented May 4, 2024

It's more idiomatic to map to logical.

duckdb <- asNamespace("duckdb")
drv <- duckdb::duckdb()
con <- DBI::dbConnect(drv)
experimental <- FALSE
df1 <- tibble::tibble(a = 1)

rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
rel2 <- duckdb$rel_project(
  rel1,
  list(
    {
      tmp_expr <- duckdb$expr_reference("a")
      duckdb$expr_set_alias(tmp_expr, "a")
      tmp_expr
    },
    {
      tmp_expr <- if ("experimental" %in% names(formals(duckdb$expr_constant))) {
        duckdb$expr_constant(NA, experimental = experimental)
      } else {
        duckdb$expr_constant(NA)
      }
      duckdb$expr_set_alias(tmp_expr, "b")
      tmp_expr
    }
  )
)
rel2
#> DuckDB Relation: 
#> ---------------------
#> --- Relation Tree ---
#> ---------------------
#> Projection [a as a, NULL as b]
#>   r_dataframe_scan(0x11e727dd0)
#> 
#> ---------------------
#> -- Result Columns  --
#> ---------------------
#> - a (DOUBLE)
#> - b (INTEGER)
dput(duckdb$rel_to_altrep(rel2))
#> structure(list(a = 1, b = NA_integer_), row.names = c(NA, -1L
#> ), class = "data.frame")

DBI::dbDisconnect(con)

Created on 2024-05-04 with reprex v2.1.0

@krlmlr krlmlr added the bug an unexpected problem or unintended behavior label May 4, 2024
@krlmlr krlmlr linked a pull request May 4, 2024 that will close this issue
@krlmlr
Copy link
Collaborator Author

krlmlr commented May 12, 2024

Upstream: krlmlr/duckdb@40efc4b

@krlmlr
Copy link
Collaborator Author

krlmlr commented May 13, 2024

Next try: krlmlr/duckdb@4e17c71

@krlmlr
Copy link
Collaborator Author

krlmlr commented Jun 2, 2024

@krlmlr
Copy link
Collaborator Author

krlmlr commented Jun 2, 2024

Too many things fail in duckdb when this is changed. Let's revisit what is truly necessary for duckplyr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant