client.get_slice

Retrieve a slice of data as a pandas DataFrame.

Input ParameterTypeDefaultDescription
sql_querystrNoneThe SQL query used to retrieve the slice.
project_idstrNoneThe unique identifier for the project. The model and/or the dataset to be queried within the project are designated in the sql_query itself.
columns_overrideOptional [list]NoneA list of columns to include in the slice, even if they aren't specified in the query.
import pandas as pd

PROJECT_ID = 'example_project'
DATASET_ID = 'example_dataset'
MODEL_ID = 'example_model'

query = f""" SELECT * FROM "{DATASET_ID}.{MODEL_ID}" """

slice_df = client.get_slice(
    sql_query=query,
    project_id=PROJECT_ID
)
import pandas as pd

PROJECT_ID = 'example_project'
MODEL_ID = 'example_model'

query = f""" SELECT * FROM "production.{MODEL_ID}" """

slice_df = client.get_slice(
    sql_query=query,
    project_id=PROJECT_ID
)
Return TypeDescription
pd.DataFrameA pandas DataFrame containing the slice returned by the query.

πŸ“˜

Info

Only read-only SQL operations are supported. Certain SQL operations like aggregations and joins might not result in a valid slice.