From 315ff92ac59986b9811e2d74c14368c8311e3860 Mon Sep 17 00:00:00 2001 From: Gabryel Reyes Date: Wed, 26 Jun 2024 11:15:52 +0200 Subject: [PATCH] Removed magic string --- src/pySupersetCli/cmd_upload.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pySupersetCli/cmd_upload.py b/src/pySupersetCli/cmd_upload.py index 47e0e56..7f37047 100644 --- a/src/pySupersetCli/cmd_upload.py +++ b/src/pySupersetCli/cmd_upload.py @@ -47,6 +47,7 @@ LOG: logging.Logger = logging.getLogger(__name__) _CMD_NAME = "upload" _TEMP_FILE_NAME = "./temp.csv" +DATE_COLUMN = "date" ################################################################################ # Classes @@ -127,7 +128,7 @@ 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: + if DATE_COLUMN not in data_frame: raise ValueError( "No 'date' column found in the JSON file.") @@ -137,7 +138,7 @@ def _execute(args, superset_client: Superset) -> Ret: with open(_TEMP_FILE_NAME, 'rb') as csv_file: upload_file = {'file': csv_file} upload_body = {'already_exists': 'append', - 'column_dates': ["date"], + 'column_dates': [DATE_COLUMN], 'table_name': args.table} # Upload the CSV file to the specified table