# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DO NOT MODIFY THIS FILE DIRECTLY.
# This file was generated by the script: scripts/generate_bigframes_bigquery.py
#
from __future__ import annotations
import abc
import datetime
from typing import (
Any,
Literal,
Optional,
TypeVar,
Union,
cast,
)
from bigframes import series, session
from bigframes.core import col, sentinels
from bigframes.extensions.core import abstract_series_accessor, series_tvf_mixins
T = TypeVar("T")
S = TypeVar("S")
[docs]
class BigQuerySeriesAccessor(
abstract_series_accessor.AbstractBigQuerySeriesAccessor[T, S]
):
"""Series accessor for BigQuery functions."""
@property
@abc.abstractmethod
def ai(self) -> AiSeriesAccessor[T, S]:
"""Accessor for BigQuery ai functions."""
@property
@abc.abstractmethod
def aead(self) -> AeadSeriesAccessor[T, S]:
"""Accessor for BigQuery aead functions."""
[docs]
def deterministic_decrypt_bytes(
self,
ciphertext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Uses the matching key from `keyset` to decrypt `ciphertext` and verifies the integrity of the data using `additional_data`. Returns an error if decryption fails."""
from bigframes.operations.googlesql.global_namespace.aead_encryption import (
deterministic_decrypt_bytes as deterministic_decrypt_bytes_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
ciphertext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = deterministic_decrypt_bytes_impl(
bf_series,
ciphertext,
additional_data,
)
return self._to_series(cast(series.Series, result))
[docs]
def deterministic_decrypt_string(
self,
ciphertext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Like `DETERMINISTIC_DECRYPT_BYTES`, but where plaintext is of type STRING."""
from bigframes.operations.googlesql.global_namespace.aead_encryption import (
deterministic_decrypt_string as deterministic_decrypt_string_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
ciphertext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = deterministic_decrypt_string_impl(
bf_series,
ciphertext,
additional_data,
)
return self._to_series(cast(series.Series, result))
[docs]
def deterministic_encrypt(
self,
plaintext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Encrypts `plaintext` using the primary cryptographic key in `keyset` using deterministic AEAD. The algorithm of the primary key must be `DETERMINISTIC_AEAD_AES_SIV_CMAC_256`. Binds the ciphertext to the context defined by `additional_data`. Returns `NULL` if any input is `NULL`."""
from bigframes.operations.googlesql.global_namespace.aead_encryption import (
deterministic_encrypt as deterministic_encrypt_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
plaintext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = deterministic_encrypt_impl(
bf_series,
plaintext,
additional_data,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_concat(
self,
array_expression_2: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Concatenates one or more arrays with the same element type into a single array."""
from bigframes.operations.googlesql.global_namespace.array import (
array_concat as array_concat_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
array_expression_2,
)
bf_series = self._bf_from_series(session)
result = array_concat_impl(
bf_series,
array_expression_2,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_first(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array and returns the first element in the array."""
from bigframes.operations.googlesql.global_namespace.array import (
array_first as array_first_impl,
)
bf_series = self._bf_from_series(session)
result = array_first_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_first_n(
self,
n: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns a prefix of `input_array` consisting of the first `n` elements."""
from bigframes.operations.googlesql.global_namespace.array import (
array_first_n as array_first_n_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
n,
)
bf_series = self._bf_from_series(session)
result = array_first_n_impl(
bf_series,
n,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_includes(
self,
search_value: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array and returns `TRUE` if there is an element in the array that is equal to the search_value."""
from bigframes.operations.googlesql.global_namespace.array import (
array_includes as array_includes_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
search_value,
)
bf_series = self._bf_from_series(session)
result = array_includes_impl(
bf_series,
search_value,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_includes_all(
self,
search_values: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array to search and an array of search values. Returns `TRUE` if all search values are in the array to search, otherwise returns `FALSE`."""
from bigframes.operations.googlesql.global_namespace.array import (
array_includes_all as array_includes_all_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
search_values,
)
bf_series = self._bf_from_series(session)
result = array_includes_all_impl(
bf_series,
search_values,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_includes_any(
self,
search_values: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array to search and an array of search values. Returns `TRUE` if any search values are in the array to search, otherwise returns `FALSE`."""
from bigframes.operations.googlesql.global_namespace.array import (
array_includes_any as array_includes_any_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
search_values,
)
bf_series = self._bf_from_series(session)
result = array_includes_any_impl(
bf_series,
search_values,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_is_distinct(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns `TRUE` if the array contains no repeated elements, using the same equality comparison logic as `SELECT DISTINCT`."""
from bigframes.operations.googlesql.global_namespace.array import (
array_is_distinct as array_is_distinct_impl,
)
bf_series = self._bf_from_series(session)
result = array_is_distinct_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_last(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array and returns the last element in the array."""
from bigframes.operations.googlesql.global_namespace.array import (
array_last as array_last_impl,
)
bf_series = self._bf_from_series(session)
result = array_last_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_length(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Compute the length of each array element in the Series.
**Examples:**
>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> s = bpd.Series([[1, 2, 8, 3], [], [3, 4]])
>>> bbq.array_length(s)
0 4
1 0
2 2
dtype: Int64
You can call this function using the Series `bigquery` accessor.
>>> s.bigquery.array_length()
0 4
1 0
2 2
dtype: Int64
You can also use this accessor on a pandas Series after importing bigframes.
>>> import bigframes
>>> import pandas as pd
>>> ps = pd.Series([[1, 2, 8, 3], [], [3, 4]])
>>> ps.bigquery.array_length()
0 4
1 0
2 2
dtype: Int64
You can also apply this function directly to Series using `apply`.
>>> s.apply(bbq.array_length, by_row=False)
0 4
1 0
2 2
dtype: Int64
Args:
series (bigframes.series.Series): A Series with array columns.
Returns:
bigframes.series.Series: A Series of integer values indicating
the length of each element in the Series.
"""
from bigframes.operations.googlesql.global_namespace.array import (
array_length as array_length_impl,
)
bf_series = self._bf_from_series(session)
result = array_length_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_reverse(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns the input `ARRAY` with elements in reverse order."""
from bigframes.operations.googlesql.global_namespace.array import (
array_reverse as array_reverse_impl,
)
bf_series = self._bf_from_series(session)
result = array_reverse_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_slice(
self,
start_offset: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
],
end_offset: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns an array containing zero or more consecutive elements from the input array."""
from bigframes.operations.googlesql.global_namespace.array import (
array_slice as array_slice_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
start_offset,
end_offset,
)
bf_series = self._bf_from_series(session)
result = array_slice_impl(
bf_series,
start_offset,
end_offset,
)
return self._to_series(cast(series.Series, result))
[docs]
def array_to_string(
self,
delimiter: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
],
null_text: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts array elements within a Series into delimited strings.
**Examples:**
>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> s = bpd.Series([["H", "i", "!"], ["Hello", "World"], np.nan, [], ["Hi"]])
>>> bbq.array_to_string(s, delimiter=", ")
0 H, i, !
1 Hello, World
2
3
4 Hi
dtype: string
You can call this function using the Series `bigquery` accessor.
>>> s.bigquery.array_to_string(delimiter=", ")
0 H, i, !
1 Hello, World
2
3
4 Hi
dtype: string
You can also use this accessor on a pandas Series after importing bigframes.
>>> import bigframes
>>> import pandas as pd
>>> ps = pd.Series([["H", "i", "!"], ["Hello", "World"], None, [], ["Hi"]])
>>> ps.bigquery.array_to_string(delimiter=", ")
0 H, i, !
1 Hello, World
2
3
4 Hi
dtype: string
Args:
series (bigframes.series.Series): A Series containing arrays.
delimiter (str): The string used to separate array elements.
null_text (str, optional): The string to replace any NULL values in the array with.
Returns:
bigframes.series.Series: A Series containing delimited strings.
"""
from bigframes.operations.googlesql.global_namespace.array import (
array_to_string as array_to_string_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
delimiter,
null_text,
)
bf_series = self._bf_from_series(session)
result = array_to_string_impl(
bf_series,
delimiter,
null_text,
)
return self._to_series(cast(series.Series, result))
[docs]
def flatten(
self,
depth: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Takes an array of nested data and flattens a specific part of it into a single, flat array with the [array elements field access operator][array-el-field-operator]. Returns `NULL` if the input value is `NULL`."""
from bigframes.operations.googlesql.global_namespace.array import (
flatten as flatten_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
depth,
)
bf_series = self._bf_from_series(session)
result = flatten_impl(
bf_series,
depth,
)
return self._to_series(cast(series.Series, result))
[docs]
def bit_count(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""The input, `expression`, must be an integer or `BYTES`. Returns the number of bits that are set in the input expression. For signed integers, this is the number of bits in two's complement form."""
from bigframes.operations.googlesql.global_namespace.bit import (
bit_count as bit_count_impl,
)
bf_series = self._bf_from_series(session)
result = bit_count_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def bool_(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a JSON boolean to a SQL BOOL value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
bool_ as bool__impl,
)
bf_series = self._bf_from_series(session)
result = bool__impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def double(
self,
wide_number_mode: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a JSON number to a SQL FLOAT64 value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
double as double_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
wide_number_mode,
)
bf_series = self._bf_from_series(session)
result = double_impl(
bf_series,
wide_number_mode,
)
return self._to_series(cast(series.Series, result))
[docs]
def float64(
self,
wide_number_mode: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a JSON number to a SQL FLOAT64 value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
float64 as float64_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
wide_number_mode,
)
bf_series = self._bf_from_series(session)
result = float64_impl(
bf_series,
wide_number_mode,
)
return self._to_series(cast(series.Series, result))
[docs]
def int64(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a JSON number to a SQL INT64 value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
int64 as int64_impl,
)
bf_series = self._bf_from_series(session)
result = int64_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def parse_bignumeric(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a STRING to a BIGNUMERIC value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
parse_bignumeric as parse_bignumeric_impl,
)
bf_series = self._bf_from_series(session)
result = parse_bignumeric_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def parse_numeric(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a STRING to a NUMERIC value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
parse_numeric as parse_numeric_impl,
)
bf_series = self._bf_from_series(session)
result = parse_numeric_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def string(
self,
timezone: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a value to a STRING value."""
from bigframes.operations.googlesql.global_namespace.conversion import (
string as string_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
timezone,
)
bf_series = self._bf_from_series(session)
result = string_impl(
bf_series,
timezone,
)
return self._to_series(cast(series.Series, result))
[docs]
def date(
self,
time_zone_expression: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
year: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
month: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
day: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Constructs or extracts a date."""
from bigframes.operations.googlesql.global_namespace.date import (
date as date_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
time_zone_expression,
year,
month,
day,
)
bf_series = self._bf_from_series(session)
result = date_impl(
bf_series,
time_zone_expression,
year,
month,
day,
)
return self._to_series(cast(series.Series, result))
[docs]
def date_add(
self,
int64_expression: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
],
date_part: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Adds a specified time interval to a DATE."""
from bigframes.operations.googlesql.global_namespace.date import (
date_add as date_add_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
int64_expression,
date_part,
)
bf_series = self._bf_from_series(session)
result = date_add_impl(
bf_series,
int64_expression,
date_part,
)
return self._to_series(cast(series.Series, result))
[docs]
def date_diff(
self,
start_date: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], datetime.date],
],
granularity: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Gets the number of unit boundaries between two DATE values (end_date - start_date) at a particular time granularity."""
from bigframes.operations.googlesql.global_namespace.date import (
date_diff as date_diff_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
start_date,
granularity,
)
bf_series = self._bf_from_series(session)
result = date_diff_impl(
bf_series,
start_date,
granularity,
)
return self._to_series(cast(series.Series, result))
[docs]
def date_from_unix_date(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Interprets an INT64 expression as the number of days since 1970-01-01."""
from bigframes.operations.googlesql.global_namespace.date import (
date_from_unix_date as date_from_unix_date_impl,
)
bf_series = self._bf_from_series(session)
result = date_from_unix_date_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def date_sub(
self,
int64_expression: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], int],
],
date_part: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Subtracts a specified time interval from a DATE."""
from bigframes.operations.googlesql.global_namespace.date import (
date_sub as date_sub_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
int64_expression,
date_part,
)
bf_series = self._bf_from_series(session)
result = date_sub_impl(
bf_series,
int64_expression,
date_part,
)
return self._to_series(cast(series.Series, result))
[docs]
def date_trunc(
self,
granularity: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Truncates a DATE, DATETIME, or TIMESTAMP value at a particular granularity."""
from bigframes.operations.googlesql.global_namespace.date import (
date_trunc as date_trunc_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
granularity,
)
bf_series = self._bf_from_series(session)
result = date_trunc_impl(
bf_series,
granularity,
)
return self._to_series(cast(series.Series, result))
[docs]
def last_day(
self,
date_part: Union[
series.Series,
col.Expression,
Union[Any, Literal[sentinels.Sentinel.ARGUMENT_DEFAULT]],
] = sentinels.Sentinel.ARGUMENT_DEFAULT,
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns the last day from a date expression. This is commonly used to return the last day of the month."""
from bigframes.operations.googlesql.global_namespace.date import (
last_day as last_day_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
date_part,
)
bf_series = self._bf_from_series(session)
result = last_day_impl(
bf_series,
date_part,
)
return self._to_series(cast(series.Series, result))
[docs]
def parse_date(
self,
format_string: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Converts a STRING value to a DATE value."""
from bigframes.operations.googlesql.global_namespace.date import (
parse_date as parse_date_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
format_string,
)
bf_series = self._bf_from_series(session)
result = parse_date_impl(
format_string,
bf_series,
)
return self._to_series(cast(series.Series, result))
[docs]
def unix_date(
self,
*,
session: Optional[session.Session] = None,
) -> S:
"""Returns the number of days since 1970-01-01."""
from bigframes.operations.googlesql.global_namespace.date import (
unix_date as unix_date_impl,
)
bf_series = self._bf_from_series(session)
result = unix_date_impl(
bf_series,
)
return self._to_series(cast(series.Series, result))
class AiSeriesAccessor(series_tvf_mixins.AITVFMixin[T, S]):
"""Series accessor for BigQuery ai functions."""
[docs]
class AeadSeriesAccessor(abstract_series_accessor.AbstractBigQuerySeriesAccessor[T, S]):
"""Series accessor for BigQuery aead functions."""
[docs]
def decrypt_bytes(
self,
ciphertext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Uses the matching key from keyset to decrypt ciphertext and verifies the integrity of the data using additional_data. Returns an error if decryption or verification fails."""
from bigframes.operations.googlesql.aead import (
decrypt_bytes as decrypt_bytes_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
ciphertext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = decrypt_bytes_impl(
bf_series,
ciphertext,
additional_data,
)
return self._to_series(cast(series.Series, result))
[docs]
def decrypt_string(
self,
ciphertext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], str],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Like AEAD.DECRYPT_BYTES, but where additional_data is of type STRING."""
from bigframes.operations.googlesql.aead import (
decrypt_string as decrypt_string_impl,
)
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
ciphertext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = decrypt_string_impl(
bf_series,
ciphertext,
additional_data,
)
return self._to_series(cast(series.Series, result))
[docs]
def encrypt(
self,
plaintext: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
],
additional_data: Union[
series.Series,
col.Expression,
Union[Literal[sentinels.Sentinel.ARGUMENT_DEFAULT], bytes, str],
],
*,
session: Optional[session.Session] = None,
) -> S:
"""Encrypts plaintext using the primary cryptographic key in keyset. The algorithm of the primary key must be AEAD_AES_GCM_256. Binds the ciphertext to the context defined by additional_data. Returns NULL if any input is NULL."""
from bigframes.operations.googlesql.aead import encrypt as encrypt_impl
# Resolve session from other arguments if not passed
if session is None:
from bigframes.core import googlesql
session = googlesql._find_session(
plaintext,
additional_data,
)
bf_series = self._bf_from_series(session)
result = encrypt_impl(
bf_series,
plaintext,
additional_data,
)
return self._to_series(cast(series.Series, result))