R/sql_utils.R

Defines functions quote_sql_name.character quote_sql_name.name quote_sql_name

Documented in quote_sql_name

#' Translate input character vector or symbol to a SQL identifier
#'
#' @description
#' Calls dbplyr::translate_sql_ on the input character vector or symbol to obtain
#' the corresponding SQL identifier that is escaped and quoted properly
#'
#' @keywords internal
#' @export
quote_sql_name <- function(x, con = NULL) {
  UseMethod("quote_sql_name")
}

#' @export
quote_sql_name.name <- function(x, con = NULL) {
  as.character(
    dbplyr::translate_sql_(
      list(x),
      con = con %||% dbplyr::simulate_hive()
    )
  )
}

#' @export
quote_sql_name.character <- function(x, con = NULL) {
  quote_sql_name(as.symbol(x), con)
}

Try the sparklyr package in your browser

Any scripts or data that you put into this service are public.

sparklyr documentation built on Nov. 2, 2023, 5:09 p.m.