From 60d689015aa7dba8f562e943cc2a31750a560f86 Mon Sep 17 00:00:00 2001 From: rlsalcido24 Date: Tue, 2 Apr 2024 16:33:41 +0000 Subject: [PATCH] year date format year date format --- helper/_resources/config/redshift/syntax_mappings.json | 4 ++-- helper/convert_to_databricks.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/helper/_resources/config/redshift/syntax_mappings.json b/helper/_resources/config/redshift/syntax_mappings.json index b585fd7..50a558c 100644 --- a/helper/_resources/config/redshift/syntax_mappings.json +++ b/helper/_resources/config/redshift/syntax_mappings.json @@ -73,8 +73,8 @@ "customnoposix" : {"source_pattern": "!~", "target_pattern": "not rlike" }, -"tocharlower" : {"source_pattern": "to_char\\([^)]*?\\)", - "target_pattern": "to_char(#arg0, lower(#arg1))" +"yearformat" : {"source_pattern": "YYYY-", + "target_pattern": "yyyy-" }, "getdate_to_df" : {"source_pattern": "getdate\\(\\)", "target_pattern": "date_format(date_trunc('second', current_timestamp()), 'yyyy-MM-dd HH:mm:ss')" diff --git a/helper/convert_to_databricks.py b/helper/convert_to_databricks.py index 1061cc3..41066b2 100644 --- a/helper/convert_to_databricks.py +++ b/helper/convert_to_databricks.py @@ -598,7 +598,12 @@ def convert_syntax_expressions(content: str, source_pattern: str, target_pattern elif target_pattern == "not rlike": encontrar = re.findall(source_pattern, content, flags= re.DOTALL | re.IGNORECASE) num_matches = len(encontrar) - updated_content = re.sub(source_pattern, target_pattern, content, flags= re.DOTALL | re.IGNORECASE) + updated_content = re.sub(source_pattern, target_pattern, content, flags= re.DOTALL | re.IGNORECASE) + + elif target_pattern == "yyyy-": + encontrar = re.findall(source_pattern, content) + num_matches = len(encontrar) + updated_content = re.sub(source_pattern, target_pattern, content) else: initargs = findargs(content, source_pattern)