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

Function _get_entity_schema

sdk/python/feast/infra/offline_stores/redshift.py:1157–1177  ·  view source on GitHub ↗
(
    entity_df: Union[pd.DataFrame, str],
    redshift_client,
    config: RepoConfig,
    s3_resource,
)

Source from the content-addressed store, hash-verified

1155
1156
1157def _get_entity_schema(
1158 entity_df: Union[pd.DataFrame, str],
1159 redshift_client,
1160 config: RepoConfig,
1161 s3_resource,
1162) -> Dict[str, np.dtype]:
1163 if isinstance(entity_df, pd.DataFrame):
1164 return dict(zip(entity_df.columns, entity_df.dtypes))
1165
1166 elif isinstance(entity_df, str):
1167 # get pandas dataframe consisting of 1 row (LIMIT 1) and generate the schema out of it
1168 entity_df_sample = RedshiftRetrievalJob(
1169 f"SELECT * FROM ({entity_df}) LIMIT 1",
1170 redshift_client,
1171 s3_resource,
1172 config,
1173 full_feature_names=False,
1174 ).to_df()
1175 return dict(zip(entity_df_sample.columns, entity_df_sample.dtypes))
1176 else:
1177 raise InvalidEntityType(type(entity_df))
1178
1179
1180def _get_entity_df_event_timestamp_range(

Callers 1

Calls 3

InvalidEntityTypeClass · 0.90
to_dfMethod · 0.45

Tested by

no test coverage detected