MCPcopy Create free account
hub / github.com/feast-dev/feast / _upload_entity_df

Function _upload_entity_df

sdk/python/feast/infra/offline_stores/bigquery.py:1400–1425  ·  view source on GitHub ↗

Uploads a Pandas entity dataframe into a BigQuery table and returns the resulting table

(
    client: Client,
    table_name: str,
    entity_df: Union[pd.DataFrame, str],
)

Source from the content-addressed store, hash-verified

1398
1399
1400def _upload_entity_df(
1401 client: Client,
1402 table_name: str,
1403 entity_df: Union[pd.DataFrame, str],
1404) -> Table:
1405 """Uploads a Pandas entity dataframe into a BigQuery table and returns the resulting table"""
1406 job: Union[bigquery.job.query.QueryJob, bigquery.job.load.LoadJob]
1407
1408 if isinstance(entity_df, str):
1409 job = client.query(f"CREATE TABLE `{table_name}` AS ({entity_df})")
1410
1411 elif isinstance(entity_df, pd.DataFrame):
1412 # Drop the index so that we don't have unnecessary columns
1413 entity_df.reset_index(drop=True, inplace=True)
1414 job = client.load_table_from_dataframe(entity_df, table_name)
1415 else:
1416 raise InvalidEntityType(type(entity_df))
1417
1418 block_until_done(client, job)
1419
1420 # Ensure that the table expires after some time
1421 table = client.get_table(table=table_name)
1422 table.expires = _utc_now() + timedelta(minutes=30)
1423 client.update_table(table, ["expires"])
1424
1425 return table
1426
1427
1428def _get_entity_schema(

Callers 1

query_generatorMethod · 0.70

Calls 4

InvalidEntityTypeClass · 0.90
_utc_nowFunction · 0.90
block_until_doneFunction · 0.85
queryMethod · 0.45

Tested by

no test coverage detected