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

Bind NULL to NA (logical) #156

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Bind NULL to NA (logical) #156

wants to merge 1 commit into from

Conversation

krlmlr
Copy link
Collaborator

@krlmlr krlmlr commented May 4, 2024

Closes #155.

We'd need to either upstream this, or patch here. Unclear about the consequences.

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(0x138dfe8e8)
#> 
#> ---------------------
#> -- Result Columns  --
#> ---------------------
#> - a (DOUBLE)
#> - b (BOOLEAN)
dput(duckdb$rel_to_altrep(rel2))
#> structure(list(a = 1, b = NA), row.names = c(NA, -1L), class = "data.frame")

DBI::dbDisconnect(con)

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

@krlmlr krlmlr changed the title Bind NULL to logical Merge branch 'cran-0.10.2' May 4, 2024
@krlmlr krlmlr changed the title Merge branch 'cran-0.10.2' Bind NULL to NA (logical) May 4, 2024
@krlmlr krlmlr marked this pull request as draft May 4, 2024 18:21
@krlmlr krlmlr requested a review from hannes May 4, 2024 18:22
krlmlr added a commit to duckdblabs/duckplyr that referenced this pull request May 5, 2024
krlmlr added a commit to duckdblabs/duckplyr that referenced this pull request May 5, 2024
krlmlr added a commit to duckdblabs/duckplyr that referenced this pull request May 5, 2024
krlmlr added a commit to duckdblabs/duckplyr that referenced this pull request May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NULL mapped to NA_integer_
1 participant