Skip to content

Conversation

@hadley
Copy link
Member

@hadley hadley commented Dec 8, 2025

  • NULL doesn't do anything
  • * errors with "cannot translate a primitive function to SQL"
  • pi mismatches to columns in select(), and in mutate() it's already inlined

Fixes #1531

Before:

library(dbplyr)
library(dplyr, warn.conflicts = FALSE)

lf <- lazy_frame(x = 1, y = 2, pi = 2)
# Incorrect uses function
lf |> select(pi) |> show_query()
#> <SQL>
#> SELECT PI() AS `pi`
#> FROM `df`
# Already inlines pi
lf |> select(x) |> mutate(y = pi) |> show_query()
#> <SQL>
#> SELECT `x`, 3.14159265358979 AS `y`
#> FROM `df`
# Errors
lf |> mutate(y = count(`*`)) |> show_query()
#> Error:
#> ! Cannot translate a primitive function to SQL.
#> ℹ Do you want to force evaluation in R with (e.g.) `!!x` or `local(x)`?
# Already works
lf |> mutate(y = f(1, NULL)) |> show_query()
#> <SQL>
#> SELECT `x`, f(1.0, NULL) AS `y`, PI() AS `pi`
#> FROM `df`

Created on 2025-12-08 with reprex v2.1.1

After

library(dbplyr)
library(dplyr, warn.conflicts = FALSE)

lf <- lazy_frame(x = 1, y = 2, pi = 2)
# Incorrect uses function
lf |> select(pi) |> show_query()
#> <SQL>
#> SELECT `pi`
#> FROM `df`
# Already inlines pi
lf |> select(x) |> mutate(y = pi) |> show_query()
#> <SQL>
#> SELECT `x`, 3.14159265358979 AS `y`
#> FROM `df`
# Errors
lf |> mutate(y = count(`*`)) |> show_query()
#> Error:
#> ! Cannot translate a primitive function to SQL.
#> ℹ Do you want to force evaluation in R with (e.g.) `!!x` or `local(x)`?
# Already works
lf |> mutate(y = f(1, NULL)) |> show_query()
#> <SQL>
#> SELECT `x`, f(1.0, NULL) AS `y`, `pi`
#> FROM `df`

Created on 2025-12-08 with reprex v2.1.1

* `NULL` doesn't do anything
* `*` errors with "cannot translate a primitive function to SQL"
* `pi` mismatches to columns in `select()`, and in `mutate()` it's already inlined

Fixes #1531
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.

Translate column name pi into PI()

2 participants