% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/translate-sql-scalar.R
\name{sql_translation_scalar}
\alias{sql_translation_scalar}
\alias{sql_infix}
\alias{sql_prefix}
\alias{sql_cast}
\alias{sql_try_cast}
\alias{sql_log}
\alias{sql_cot}
\alias{sql_runif}
\title{SQL helpers for scalar functions}
\usage{
sql_infix(f, pad = TRUE)

sql_prefix(f, n = NULL)

sql_cast(type)

sql_try_cast(type)

sql_log()

sql_cot()

sql_runif(rand_expr, n = n(), min = 0, max = 1)
}
\arguments{
\item{f}{The name of the SQL function as a string.}

\item{pad}{If \code{TRUE}, the default, pad the infix operator with spaces.}

\item{n}{For \code{sql_prefix()}, an optional number of arguments to expect.
Will signal error if not correct.}

\item{type}{SQL type name as a string.}

\item{rand_expr}{A string giving an SQL expression that generates a
random number between 0 and 1, e.g. \code{"RANDOM()"}.}

\item{min, max}{Range of random values.}
}
\description{
These functions help you create custom scalar SQL translations when
implementing a new backend. They are typically used within \code{\link[=sql_translator]{sql_translator()}}
to define how R functions should be translated to SQL.
\itemize{
\item \code{sql_infix()} creates SQL infix operators like \code{+}, \code{-}, \code{*}, \code{/}.
\item \code{sql_prefix()} creates SQL prefix functions like \code{ABS()}, \code{SQRT()}.
\item \code{sql_cast()} creates SQL cast expressions like \verb{CAST(x AS type)}.
\item \code{sql_try_cast()} creates SQL try_cast expressions (for safe casting).
\item \code{sql_log()} creates a SQL logarithm function with optional base.
\item \code{sql_cot()} creates a SQL cotangent function (as \code{1 / TAN(x)}).
\item \code{sql_runif()} creates a SQL expression for generating uniform random
numbers.
}
}
\seealso{
Other SQL translation helpers:
\code{\link{sql_translation_agg}},
\code{\link{sql_translation_string}},
\code{\link{sql_translation_window}},
\code{\link[=sql_variant]{sql_variant()}}
}
\concept{SQL translation helpers}
