bigframes.bigquery.sql_scalar#
- bigframes.bigquery.sql_scalar(sql_template: str, columns: Sequence[Series]) Series[source]#
Create a Series from a SQL template.
Examples:
>>> import bigframes.pandas as bpd >>> import bigframes.bigquery as bbq
>>> s = bpd.Series(["1.5", "2.5", "3.5"]) >>> s = s.astype(pd.ArrowDtype(pa.decimal128(38, 9))) >>> bbq.sql_scalar("ROUND({0}, 0, 'ROUND_HALF_EVEN')", [s]) 0 2.000000000 1 2.000000000 2 4.000000000 dtype: decimal128(38, 9)[pyarrow]
- Parameters:
sql_template (str) – A SQL format string with Python-style {0} placeholders for each of the Series objects in
columns.columns (Sequence[bigframes.pandas.Series]) – Series objects representing the column inputs to the
sql_template. Must contain at least one Series.
- Returns:
A Series with the SQL applied.
- Return type:
- Raises:
ValueError – If
columnsis empty.