From a847220f1c37525fe2491602a036448c114a787a Mon Sep 17 00:00:00 2001 From: "mate.valko" Date: Wed, 4 Dec 2024 01:51:15 +0100 Subject: [PATCH 1/2] If input is null, should return null --- src/template/check_yaml.sql | 2 +- src/template/yaml_to_json_array.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/template/check_yaml.sql b/src/template/check_yaml.sql index 7465292..6bf1e19 100644 --- a/src/template/check_yaml.sql +++ b/src/template/check_yaml.sql @@ -34,5 +34,5 @@ CREATE OR REPLACE FUNCTION COMMENT = 'Parses and validates a YAML string.' AS $$ - TO_VARCHAR(CHECK_YAML_ARRAY(TO_BINARY(YAML_STRING, 'UTF-8')), 'UTF-8') +CASE WHEN YAML_STRING IS NULL THEN NULL ELSE TO_VARCHAR(CHECK_YAML_ARRAY(TO_BINARY(YAML_STRING, 'UTF-8')), 'UTF-8') END $$ diff --git a/src/template/yaml_to_json_array.sql b/src/template/yaml_to_json_array.sql index 31c5585..6fdffce 100644 --- a/src/template/yaml_to_json_array.sql +++ b/src/template/yaml_to_json_array.sql @@ -34,5 +34,5 @@ CREATE OR REPLACE FUNCTION COMMENT = 'Parses a YAML string into a semi-structured value.' AS $$ - PARSE_JSON(TO_VARCHAR(YAML_TO_JSON_ARRAY(TO_BINARY(YAML_STRING, 'UTF-8')), 'UTF-8')) +CASE WHEN YAML_STRING IS NULL THEN NULL ELSE PARSE_JSON(TO_VARCHAR(YAML_TO_JSON_ARRAY(TO_BINARY(YAML_STRING, 'UTF-8')), 'UTF-8')) END $$ From fa4d04b5213e88aad035452c68d3de96dc92d263 Mon Sep 17 00:00:00 2001 From: "mate.valko" Date: Wed, 4 Dec 2024 01:53:11 +0100 Subject: [PATCH 2/2] If input is null, should return null --- src/template/yaml_to_json_string.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template/yaml_to_json_string.sql b/src/template/yaml_to_json_string.sql index dc03a45..92e6ff9 100644 --- a/src/template/yaml_to_json_string.sql +++ b/src/template/yaml_to_json_string.sql @@ -34,5 +34,5 @@ CREATE OR REPLACE FUNCTION COMMENT = 'Parses a YAML string into a semi-structured value.' AS $$ - PARSE_JSON(YAML_TO_JSON_STRING(YAML_STRING)) +CASE WHEN YAML_STRING IS NULL THEN NULL ELSE PARSE_JSON(YAML_TO_JSON_STRING(YAML_STRING)) END $$