-
Notifications
You must be signed in to change notification settings - Fork 23
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
expr_constant(, typed_logical_null = )
#161
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ test_that("rel_filter() handles LIST logical type", { | |
df2 <- rel_to_altrep(rel2) | ||
expect_equal(df1$a, df2$a) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,13 @@ test_that("we can create various expressions and don't crash", { | |
expect_true(TRUE) | ||
}) | ||
|
||
test_that("we can create a constant NA with LOGICAL type", { | ||
rel1 <- rel_from_df(con, data.frame(x = 42)) | ||
exprs <- list( | ||
y = expr_constant(NA, TRUE) | ||
) | ||
expect_equal(rel_to_altrep(rel_project(rel1, exprs))[, ], NA) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a more straightforward way to convert a constant to a SEXP rather that having to round trip through a data frame ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For our use case, this is best. You could add a wrapper function in this package? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A function that turns a constant into an R value ? |
||
}) | ||
|
||
# TODO should maybe be a different file, test_enum_strings.R | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should instead not have the
typed_logical_null
argument, handleval == R_NilValue
upfront, and useRApiTypes::SexpToValue(val, 0, true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so? I just changed this to
typed_logical_null := false
to support a special case in duckdb. I need to better understand the original motivation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
expr_constant(NA)
should make a constant that is a NULL LOGICAL, not a NULL SQL, the same wayexpr_constant(NA_integer_)
makes a NULL INTEGER constant.And then we could tweak
expr_constant()
so thatexpr_constant(NULL)
would return aSQLNULL
With this PR, if we wanted to construct a
LOGICAL NULL
we need toexpr_constant(NA, TRUE)
.I perhaps miss background about the special case that warranted for using
typed_logical_null := false