Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust JSON log locations #115

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/gretel_trainer/relational/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def _check_for_json(
) -> Optional[IngestResponseT]:
json_cols = get_json_columns(data)
if len(json_cols) > 0:
logger.info(
f"Detected JSON data in table `{table}`. Running JSON normalization."
)
return RelationalJson.ingest(table, primary_key, data, json_cols)

def _add_rel_json_and_tables(self, table: str, rj_ingest: IngestResponseT) -> None:
Expand Down
5 changes: 1 addition & 4 deletions src/gretel_trainer/relational/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,11 @@ def ingest(
df: pd.DataFrame,
json_columns: Optional[list[str]] = None,
) -> Optional[IngestResponseT]:
logger.debug(f"Checking table `{table_name}` for JSON columns")
tables = _normalize_json([(table_name, df.copy())], [], json_columns)
# If we created additional tables (from JSON lists) or added columns (from JSON dicts)
if len(tables) > 1 or len(tables[0][1].columns) > len(df.columns):
mappings = {name: sanitize_str(name) for name, _ in tables}
logger.info(
f"Found JSON data in table `{table_name}`, transformed into {len(mappings)} tables for modeling."
)
logger.info(f"Transformed JSON into {len(mappings)} tables for modeling.")
logger.debug(f"Invented table names: {list(mappings.values())}")
rel_json = RelationalJson(
original_table_name=table_name,
Expand Down