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

Using a named vector for dbplyr::compute.tbl_sql() fails #623

Closed
nlneas1 opened this issue Mar 24, 2021 · 2 comments · Fixed by #793
Closed

Using a named vector for dbplyr::compute.tbl_sql() fails #623

nlneas1 opened this issue Mar 24, 2021 · 2 comments · Fixed by #793

Comments

@nlneas1
Copy link

nlneas1 commented Mar 24, 2021

As a reproducible example:

sc <- sparklyr::spark_connect(master = "local")
mtcars_spark <- dplyr::copy_to(dest = sc, df = mtcars)

name <- c(name = "test")

qry <- dplyr::sql("select mpg from mtcars")

res <- sparklyr::sdf_sql(sc = sc, sql = qry)

out <- dplyr::compute(x = res, name = name)
# Error: org.apache.spark.sql.catalyst.parser.ParseException: 
# mismatched input '`name`' expecting {'(', 'SELECT', 'FROM', 'WITH', 'VALUES', 'TABLE', 'INSERT', 'MAP', 'REDUCE'}(line 2, pos 10)
# 
# == SQL ==
# CREATE TEMPORARY VIEW 
# `test` AS `name` AS SELECT `mpg`
# ----------^^^
# FROM `sparklyr_tmp_5c748cbd_9398_4dff_8c4e_f46939c88eb8`

FWIW, this seems to have become an issue after we upgraded from dbplyr 1.4.2 to 2.1.0.

@hadley
Copy link
Member

hadley commented Apr 1, 2021

Minimal reprex:

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

db <- memdb_frame(x = 1:10)
compute(db, c("foo" = "bar"))
#> Error: near "`foo`": syntax error

Created on 2021-04-01 by the reprex package (v1.0.0)

But could you just not supply a named vector?

@nathaneastwood
Copy link

Sure, in theory. But our particular use case uses named vectors. For now, we are just using dplyr::compute(x = res, name = unname(name))

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 a pull request may close this issue.

3 participants