Skip to content

Use try_cast instead of cast in sql translation #2230

@gschone-data

Description

@gschone-data

Hello,
Would it be possible replace CAST by TRY_CAST for as.numeric, as.date... on duckdb_connection ?


# example 

#prepare connection 
drv <- duckdb::duckdb(config = list(allow_unsigned_extensions = "true"))
conDB <- duckdb::dbConnect(drv)
conDB |>  duckdb::duckdb_register(
  name = "iris", 
  df = iris,
  overwrite = TRUE)


x <- conDB %>% dplyr::tbl("iris") %>% dplyr::mutate(Petal.Width = as.numeric(Petal.Width))
dbplyr::sql_render(x)

Thanks ! (Sorry but I dont see where the translation lives @krlmlr )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions