(
entity_df: Union[pd.DataFrame, str],
redshift_client,
config: RepoConfig,
s3_resource,
)
| 1155 | |
| 1156 | |
| 1157 | def _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 | |
| 1180 | def _get_entity_df_event_timestamp_range( |
no test coverage detected