Skip to content

Commit

Permalink
Adjust JSON log locations (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeknep authored Jun 1, 2023
1 parent a2c994d commit a28ad4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit a28ad4e

Please sign in to comment.