From 22c20238c2a0e16301ed85ef52681ff08b2860a6 Mon Sep 17 00:00:00 2001 From: Gabryel Reyes Date: Wed, 26 Jun 2024 10:50:32 +0200 Subject: [PATCH] Date column is interpreted as date by superset --- src/pySupersetCli/cmd_upload.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pySupersetCli/cmd_upload.py b/src/pySupersetCli/cmd_upload.py index 5f15fc0..47e0e56 100644 --- a/src/pySupersetCli/cmd_upload.py +++ b/src/pySupersetCli/cmd_upload.py @@ -127,12 +127,17 @@ def _execute(args, superset_client: Superset) -> Ret: # Input is a dictionary, with keys as index data_frame = pd.read_json(json_file, orient='index') + if "date" not in data_frame: + raise ValueError( + "No 'date' column found in the JSON file.") + # pylint: disable=no-member data_frame.to_csv(_TEMP_FILE_NAME, encoding="UTF-8", index=False) with open(_TEMP_FILE_NAME, 'rb') as csv_file: upload_file = {'file': csv_file} upload_body = {'already_exists': 'append', + 'column_dates': ["date"], 'table_name': args.table} # Upload the CSV file to the specified table