diff --git a/sqrl-planner/src/main/java/com/datasqrl/calcite/convert/SimpleCallTransform.java b/sqrl-planner/src/main/java/com/datasqrl/calcite/convert/SimpleCallTransform.java index 016313e1d..b9a6ea592 100644 --- a/sqrl-planner/src/main/java/com/datasqrl/calcite/convert/SimpleCallTransform.java +++ b/sqrl-planner/src/main/java/com/datasqrl/calcite/convert/SimpleCallTransform.java @@ -57,8 +57,11 @@ public void onMatch(RelOptRuleCall relOptRuleCall) { @Override public RexNode visitCall(RexCall call) { if (call.getOperator().equals(operator)) { - hasTransformed.set(true); - return transform.transform(relOptRuleCall.builder(), call); + var transformed = transform.transform(relOptRuleCall.builder(), call); + if (transformed != call) { + hasTransformed.set(true); + return transformed; + } } return super.visitCall(call); diff --git a/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/function-translation-duckdb-package.txt b/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/function-translation-duckdb-package.txt index 4cb4064fa..4a6dbc306 100644 --- a/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/function-translation-duckdb-package.txt +++ b/sqrl-testing/sqrl-testing-integration/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/function-translation-duckdb-package.txt @@ -52,6 +52,8 @@ type FunctionCalls { try_cast_to_timestamptz_example: Boolean! try_cast_fail_example: Int try_cast_timestampdiff_decimal_example: Float + cast_timestampdiff_decimal_example: Float + case_timestampdiff_nullif_example: Float! now_example: Boolean! local_time_example: Boolean! local_timestamp_example: Boolean! @@ -215,6 +217,8 @@ Schema: - try_cast_to_timestamptz_example: BOOLEAN NOT NULL - try_cast_fail_example: INTEGER - try_cast_timestampdiff_decimal_example: DECIMAL(38, 2) + - cast_timestampdiff_decimal_example: DECIMAL(38, 2) + - case_timestampdiff_nullif_example: DECIMAL(38, 5) NOT NULL - now_example: BOOLEAN NOT NULL - local_time_example: BOOLEAN NOT NULL - local_timestamp_example: BOOLEAN NOT NULL @@ -326,7 +330,7 @@ WITH ( ); CREATE VIEW `FunctionCalls` AS -SELECT `LOG2`(8) AS `log2_example`, `LOG`(10) AS `log_nat_example`, `LOG`(2, 8) AS `log_base_example`, `E`() AS `e_example`, RAND() IS NOT NULL AS `rand_example`, RAND_INTEGER(10) IS NOT NULL AS `rand_int_example`, `UUID`() IS NOT NULL AS `uuid_example`, `BIN`(10) AS `bin_example`, `HEX`(255) AS `hex_numeric_example`, `HEX`('AB') AS `hex_string_example`, `UNHEX`('4142') AS `unhex_example`, TRUNCATE(123.456, 2) AS `truncate_scale_example`, TRUNCATE(123.456) AS `truncate_default_example`, `PRINTF`('Hello %s %d', 'world', 42) AS `printf_example`, `STARTSWITH`('FlinkSQL', 'Flink') AS `startswith_example`, `ENDSWITH`('FlinkSQL', 'SQL') AS `endswith_example`, `REGEXP_EXTRACT`('abc-123-def', '(\d+)') AS `regexp_extract_example`, `REGEXP_EXTRACT`('abc-123-def', '(\d+)', 1) AS `regexp_extract_group_example`, `REGEXP_EXTRACT_ALL`('a1b2c3', '(\d)', 1) AS `regexp_extract_all_example`, `REGEXP_REPLACE`('a1b2c3', '[0-9]', 'X') AS `regexp_replace_example`, `REGEXP_COUNT`('a1b2c3', '[0-9]') AS `regexp_count_example`, `REGEXP_INSTR`('a1b2c3', 'c') AS `regexp_instr_example`, `DECODE`(`ENCODE`('hi', 'UTF-8'), 'UTF-8') AS `decode_example`, `ENCODE`('hi', 'UTF-8') IS NOT NULL AS `encode_example`, `FROM_BASE64`(`TO_BASE64`('hello')) AS `from_base64_example`, `TO_BASE64`('hello') AS `to_base64_example`, `INSTR`('hello world', 'world') AS `instr_example`, `LOCATE`('l', 'hello') AS `locate_example`, `REGEXP`('foo123bar', '\\d+') AS `regexp_example`, `SPLIT_INDEX`('a,b,c', ',', 1) AS `split_index_example`, `JSON_QUOTE`('hello "json"') AS `json_quote_example`, JSON_OBJECT(KEY 'k1' VALUE 'v1', KEY 'k2' VALUE 'v2' NULL ON NULL) AS `json_object_kv_example`, `ELT`(2, 'first', 'second', 'third') AS `elt_example`, TRY_CAST('123' AS INTEGER) AS `try_cast_to_int_example`, TRY_CAST('112233445566778899' AS BIGINT) AS `try_cast_to_bigint_example`, TRY_CAST('true' AS BOOLEAN) AS `try_cast_to_bool_example`, TRY_CAST(123 AS VARCHAR) AS `try_cast_to_text_example`, TRY_CAST('123.45' AS DECIMAL(10, 2)) AS `try_cast_to_decimal_example`, TRY_CAST('2024-01-02 03:04:05' AS TIMESTAMP(3)) IS NOT NULL AS `try_cast_to_timestamp_example`, TRY_CAST('2024-01-02 03:04:05' AS TIMESTAMP_LTZ(3)) IS NOT NULL AS `try_cast_to_timestamptz_example`, TRY_CAST('abc' AS INTEGER) AS `try_cast_fail_example`, TRY_CAST(TIMESTAMPDIFF(MONTH, CAST(`DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(`DATE_FORMAT`(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)) AS DECIMAL(38, 2)) AS `try_cast_timestampdiff_decimal_example`, `NOW`() IS NOT NULL AS `now_example`, LOCALTIME IS NOT NULL AS `local_time_example`, LOCALTIMESTAMP IS NOT NULL AS `local_timestamp_example`, CURRENT_TIME IS NOT NULL AS `current_time_example`, CURRENT_DATE IS NOT NULL AS `current_date_example`, CURRENT_TIMESTAMP IS NOT NULL AS `current_timestamp_example`, YEAR(DATE '2024-01-02') AS `year_example`, QUARTER(DATE '2024-01-02') AS `quarter_example`, MONTH(DATE '2024-01-02') AS `month_example`, WEEK(DATE '2024-01-02') AS `week_example`, DAYOFYEAR(DATE '2024-01-02') AS `dayofyear_example`, DAYOFMONTH(DATE '2024-01-02') AS `dayofmonth_example`, DAYOFWEEK(DATE '2024-01-02') AS `dayofweek_example`, HOUR(TIMESTAMP '2024-01-02 03:04:05') AS `hour_example`, MINUTE(TIMESTAMP '2024-01-02 03:04:05') AS `minute_example`, SECOND(TIMESTAMP '2024-01-02 03:04:05') AS `second_example`, `DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-dd') AS `date_format_example`, `DATE_FORMAT`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS `date_format_replace_t_space_pattern_example`, `DATE_FORMAT`('', 'yyyy-MM-dd') AS `date_format_empty_example`, `DATE_FORMAT`(' ', 'yyyy-MM-dd') AS `date_format_blank_example`, `DATE_FORMAT`('not-a-date', 'yyyy-MM-dd') AS `date_format_invalid_example`, `DATE_FORMAT`(CAST(NULL AS TIMESTAMP), 'yyyy-MM-dd') AS `date_format_null_example`, CAST(TIMESTAMPADD(DAY, 2, TIMESTAMP '2024-01-02 03:04:05') AS TIMESTAMP(3)) AS `timestampadd_example`, TIMESTAMPDIFF(SECOND, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30') AS `timestampdiff_second_example`, TIMESTAMPDIFF(MINUTE, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00') AS `timestampdiff_minute_example`, TIMESTAMPDIFF(HOUR, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00') AS `timestampdiff_hour_example`, TIMESTAMPDIFF(DAY, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00') AS `timestampdiff_day_example`, TIMESTAMPDIFF(WEEK, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00') AS `timestampdiff_week_example`, TIMESTAMPDIFF(MONTH, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00') AS `timestampdiff_month_example`, TIMESTAMPDIFF(QUARTER, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00') AS `timestampdiff_quarter_example`, TIMESTAMPDIFF(YEAR, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00') AS `timestampdiff_year_example`, `CONVERT_TZ`('2024-01-02 03:04:05', 'UTC', 'America/Los_Angeles') AS `convert_tz_example`, `UNIX_TIMESTAMP`() IS NOT NULL AS `unix_timestamp_now_example`, `TO_TIMESTAMP`('2024-01-02') AS `to_timestamp_example`, `TO_TIMESTAMP`('2024-01-02 03:04', 'yyyy-MM-dd HH:mm') AS `to_timestamp_pattern_example`, `TO_TIMESTAMP`('2024-01-01T23:10:07', 'yyyy-MM-dd`T`HH:mm:ss') AS `to_timestamp_escaped_t_pattern_example`, `TO_TIMESTAMP`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS `to_timestamp_replace_t_space_pattern_example`, CAST(`TO_TIMESTAMP`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS TIMESTAMP(3)) AS `to_timestamp_replace_t_space_cast_example`, `TO_TIMESTAMP`('not-a-date') AS `to_timestamp_invalid_example`, `TO_TIMESTAMP`('2024/01/02 03:04', 'yyyy-MM-dd HH:mm') AS `to_timestamp_invalid_pattern_example`, `TO_TIMESTAMP`('') AS `to_timestamp_empty_example`, `TO_TIMESTAMP`('', 'yyyy-MM-dd HH:mm') AS `to_timestamp_empty_pattern_example`, `TO_TIMESTAMP`(' ') AS `to_timestamp_blank_example`, `TO_TIMESTAMP`(' ', 'yyyy-MM-dd HH:mm') AS `to_timestamp_blank_pattern_example`, `TO_TIMESTAMP`(CAST(NULL AS STRING)) AS `to_timestamp_null_example`, `TO_TIMESTAMP`(CAST(NULL AS STRING), 'yyyy-MM-dd HH:mm') AS `to_timestamp_null_pattern_example`, `IF`(1 < 2, 'yes', 'no') AS `if_example`, `IFNULL`(CAST(NULL AS STRING), 'fallback') AS `ifnull_example`, `IS_ALPHA`('OnlyLetters') AS `is_alpha_example`, `IS_DECIMAL`('123.45') AS `is_decimal_example`, `IS_DIGIT`('12345') AS `is_digit_example`, ELEMENT(ARRAY[3]) AS `element_example`, CARDINALITY(MAP['a', 1, 'b', 2]) AS `cardinality_example`, MAP['a', 1, 'b', 2]['a'] AS `map_index_example`, `ARRAY_CONTAINS`(ARRAY[1, 2, 3], 2) AS `array_contains_example`, `ARRAY_DISTINCT`(ARRAY['a', 'b', 'b', 'c']) AS `array_distinct_example`, `ARRAY_PREPEND`(ARRAY['b', 'c'], 'a') AS `array_prepend_example`, `ARRAY_SLICE`(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS `array_slice_example`, `ARRAY_CONCAT`(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS `array_concat_example`, `ARRAY_REMOVE`(ARRAY['a', 'b', 'c'], 'b') AS `array_remove_example`, `ARRAY_REMOVE`(ARRAY['a', CAST(NULL AS STRING)], NULL) AS `array_remove_null_example`, `ARRAY_REMOVE`(ARRAY['a', CAST(NULL AS STRING)], CAST(NULL AS STRING)) AS `array_remove_null_cast_example`, `ARRAY_JOIN`(ARRAY['a', NULL, 'c'], '-', '') AS `array_join_example`, `SPLIT`('a|b|c', '|') AS `split_example`, `SHA1`('hello') AS `sha1_example`, `SHA256`('hello') AS `sha256_example`, 'end' AS `the_end` +SELECT `LOG2`(8) AS `log2_example`, `LOG`(10) AS `log_nat_example`, `LOG`(2, 8) AS `log_base_example`, `E`() AS `e_example`, RAND() IS NOT NULL AS `rand_example`, RAND_INTEGER(10) IS NOT NULL AS `rand_int_example`, `UUID`() IS NOT NULL AS `uuid_example`, `BIN`(10) AS `bin_example`, `HEX`(255) AS `hex_numeric_example`, `HEX`('AB') AS `hex_string_example`, `UNHEX`('4142') AS `unhex_example`, TRUNCATE(123.456, 2) AS `truncate_scale_example`, TRUNCATE(123.456) AS `truncate_default_example`, `PRINTF`('Hello %s %d', 'world', 42) AS `printf_example`, `STARTSWITH`('FlinkSQL', 'Flink') AS `startswith_example`, `ENDSWITH`('FlinkSQL', 'SQL') AS `endswith_example`, `REGEXP_EXTRACT`('abc-123-def', '(\d+)') AS `regexp_extract_example`, `REGEXP_EXTRACT`('abc-123-def', '(\d+)', 1) AS `regexp_extract_group_example`, `REGEXP_EXTRACT_ALL`('a1b2c3', '(\d)', 1) AS `regexp_extract_all_example`, `REGEXP_REPLACE`('a1b2c3', '[0-9]', 'X') AS `regexp_replace_example`, `REGEXP_COUNT`('a1b2c3', '[0-9]') AS `regexp_count_example`, `REGEXP_INSTR`('a1b2c3', 'c') AS `regexp_instr_example`, `DECODE`(`ENCODE`('hi', 'UTF-8'), 'UTF-8') AS `decode_example`, `ENCODE`('hi', 'UTF-8') IS NOT NULL AS `encode_example`, `FROM_BASE64`(`TO_BASE64`('hello')) AS `from_base64_example`, `TO_BASE64`('hello') AS `to_base64_example`, `INSTR`('hello world', 'world') AS `instr_example`, `LOCATE`('l', 'hello') AS `locate_example`, `REGEXP`('foo123bar', '\\d+') AS `regexp_example`, `SPLIT_INDEX`('a,b,c', ',', 1) AS `split_index_example`, `JSON_QUOTE`('hello "json"') AS `json_quote_example`, JSON_OBJECT(KEY 'k1' VALUE 'v1', KEY 'k2' VALUE 'v2' NULL ON NULL) AS `json_object_kv_example`, `ELT`(2, 'first', 'second', 'third') AS `elt_example`, TRY_CAST('123' AS INTEGER) AS `try_cast_to_int_example`, TRY_CAST('112233445566778899' AS BIGINT) AS `try_cast_to_bigint_example`, TRY_CAST('true' AS BOOLEAN) AS `try_cast_to_bool_example`, TRY_CAST(123 AS VARCHAR) AS `try_cast_to_text_example`, TRY_CAST('123.45' AS DECIMAL(10, 2)) AS `try_cast_to_decimal_example`, TRY_CAST('2024-01-02 03:04:05' AS TIMESTAMP(3)) IS NOT NULL AS `try_cast_to_timestamp_example`, TRY_CAST('2024-01-02 03:04:05' AS TIMESTAMP_LTZ(3)) IS NOT NULL AS `try_cast_to_timestamptz_example`, TRY_CAST('abc' AS INTEGER) AS `try_cast_fail_example`, TRY_CAST(TIMESTAMPDIFF(MONTH, CAST(`DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(`DATE_FORMAT`(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)) AS DECIMAL(38, 2)) AS `try_cast_timestampdiff_decimal_example`, CAST(TIMESTAMPDIFF(MONTH, CAST(`DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(`DATE_FORMAT`(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)) AS DECIMAL(38, 2)) AS `cast_timestampdiff_decimal_example`, CASE WHEN CAST(10 AS DECIMAL(38, 5)) / NULLIF(TIMESTAMPDIFF(MONTH, CAST(`DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(`DATE_FORMAT`(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)), 0) IS NOT NULL THEN CAST(10 AS DECIMAL(38, 5)) / NULLIF(TIMESTAMPDIFF(MONTH, CAST(`DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(`DATE_FORMAT`(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)), 0) ELSE CAST(0 AS DECIMAL(38, 5)) END AS `case_timestampdiff_nullif_example`, `NOW`() IS NOT NULL AS `now_example`, LOCALTIME IS NOT NULL AS `local_time_example`, LOCALTIMESTAMP IS NOT NULL AS `local_timestamp_example`, CURRENT_TIME IS NOT NULL AS `current_time_example`, CURRENT_DATE IS NOT NULL AS `current_date_example`, CURRENT_TIMESTAMP IS NOT NULL AS `current_timestamp_example`, YEAR(DATE '2024-01-02') AS `year_example`, QUARTER(DATE '2024-01-02') AS `quarter_example`, MONTH(DATE '2024-01-02') AS `month_example`, WEEK(DATE '2024-01-02') AS `week_example`, DAYOFYEAR(DATE '2024-01-02') AS `dayofyear_example`, DAYOFMONTH(DATE '2024-01-02') AS `dayofmonth_example`, DAYOFWEEK(DATE '2024-01-02') AS `dayofweek_example`, HOUR(TIMESTAMP '2024-01-02 03:04:05') AS `hour_example`, MINUTE(TIMESTAMP '2024-01-02 03:04:05') AS `minute_example`, SECOND(TIMESTAMP '2024-01-02 03:04:05') AS `second_example`, `DATE_FORMAT`(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-dd') AS `date_format_example`, `DATE_FORMAT`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS `date_format_replace_t_space_pattern_example`, `DATE_FORMAT`('', 'yyyy-MM-dd') AS `date_format_empty_example`, `DATE_FORMAT`(' ', 'yyyy-MM-dd') AS `date_format_blank_example`, `DATE_FORMAT`('not-a-date', 'yyyy-MM-dd') AS `date_format_invalid_example`, `DATE_FORMAT`(CAST(NULL AS TIMESTAMP), 'yyyy-MM-dd') AS `date_format_null_example`, CAST(TIMESTAMPADD(DAY, 2, TIMESTAMP '2024-01-02 03:04:05') AS TIMESTAMP(3)) AS `timestampadd_example`, TIMESTAMPDIFF(SECOND, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30') AS `timestampdiff_second_example`, TIMESTAMPDIFF(MINUTE, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00') AS `timestampdiff_minute_example`, TIMESTAMPDIFF(HOUR, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00') AS `timestampdiff_hour_example`, TIMESTAMPDIFF(DAY, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00') AS `timestampdiff_day_example`, TIMESTAMPDIFF(WEEK, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00') AS `timestampdiff_week_example`, TIMESTAMPDIFF(MONTH, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00') AS `timestampdiff_month_example`, TIMESTAMPDIFF(QUARTER, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00') AS `timestampdiff_quarter_example`, TIMESTAMPDIFF(YEAR, TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00') AS `timestampdiff_year_example`, `CONVERT_TZ`('2024-01-02 03:04:05', 'UTC', 'America/Los_Angeles') AS `convert_tz_example`, `UNIX_TIMESTAMP`() IS NOT NULL AS `unix_timestamp_now_example`, `TO_TIMESTAMP`('2024-01-02') AS `to_timestamp_example`, `TO_TIMESTAMP`('2024-01-02 03:04', 'yyyy-MM-dd HH:mm') AS `to_timestamp_pattern_example`, `TO_TIMESTAMP`('2024-01-01T23:10:07', 'yyyy-MM-dd`T`HH:mm:ss') AS `to_timestamp_escaped_t_pattern_example`, `TO_TIMESTAMP`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS `to_timestamp_replace_t_space_pattern_example`, CAST(`TO_TIMESTAMP`(REPLACE('2024-01-01T23:10:07', 'T', ' '), 'yyyy-MM-dd`T`HH:mm:ss') AS TIMESTAMP(3)) AS `to_timestamp_replace_t_space_cast_example`, `TO_TIMESTAMP`('not-a-date') AS `to_timestamp_invalid_example`, `TO_TIMESTAMP`('2024/01/02 03:04', 'yyyy-MM-dd HH:mm') AS `to_timestamp_invalid_pattern_example`, `TO_TIMESTAMP`('') AS `to_timestamp_empty_example`, `TO_TIMESTAMP`('', 'yyyy-MM-dd HH:mm') AS `to_timestamp_empty_pattern_example`, `TO_TIMESTAMP`(' ') AS `to_timestamp_blank_example`, `TO_TIMESTAMP`(' ', 'yyyy-MM-dd HH:mm') AS `to_timestamp_blank_pattern_example`, `TO_TIMESTAMP`(CAST(NULL AS STRING)) AS `to_timestamp_null_example`, `TO_TIMESTAMP`(CAST(NULL AS STRING), 'yyyy-MM-dd HH:mm') AS `to_timestamp_null_pattern_example`, `IF`(1 < 2, 'yes', 'no') AS `if_example`, `IFNULL`(CAST(NULL AS STRING), 'fallback') AS `ifnull_example`, `IS_ALPHA`('OnlyLetters') AS `is_alpha_example`, `IS_DECIMAL`('123.45') AS `is_decimal_example`, `IS_DIGIT`('12345') AS `is_digit_example`, ELEMENT(ARRAY[3]) AS `element_example`, CARDINALITY(MAP['a', 1, 'b', 2]) AS `cardinality_example`, MAP['a', 1, 'b', 2]['a'] AS `map_index_example`, `ARRAY_CONTAINS`(ARRAY[1, 2, 3], 2) AS `array_contains_example`, `ARRAY_DISTINCT`(ARRAY['a', 'b', 'b', 'c']) AS `array_distinct_example`, `ARRAY_PREPEND`(ARRAY['b', 'c'], 'a') AS `array_prepend_example`, `ARRAY_SLICE`(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS `array_slice_example`, `ARRAY_CONCAT`(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS `array_concat_example`, `ARRAY_REMOVE`(ARRAY['a', 'b', 'c'], 'b') AS `array_remove_example`, `ARRAY_REMOVE`(ARRAY['a', CAST(NULL AS STRING)], NULL) AS `array_remove_null_example`, `ARRAY_REMOVE`(ARRAY['a', CAST(NULL AS STRING)], CAST(NULL AS STRING)) AS `array_remove_null_cast_example`, `ARRAY_JOIN`(ARRAY['a', NULL, 'c'], '-', '') AS `array_join_example`, `SPLIT`('a|b|c', '|') AS `split_example`, `SHA1`('hello') AS `sha1_example`, `SHA256`('hello') AS `sha256_example`, 'end' AS `the_end` FROM `_InputData`; CREATE TABLE `_ArrayData` ( `id` INTEGER, @@ -391,7 +395,7 @@ CREATE TABLE IF NOT EXISTS "_InputData" ("dummy" INTEGER) >>>iceberg-duckdb-views.sql CREATE OR REPLACE VIEW "ArrayFunctions"("listagg_example", "arrayagg_example") AS SELECT LISTAGG("str_char", ',') AS "listagg_example", ARRAY_AGG("str_char") AS "arrayagg_example" FROM "iceberg_scan"('/tmp/duckdb/default_database/_ArrayData', ALLOW_MOVED_PATHS = TRUE); -CREATE OR REPLACE VIEW "FunctionCalls"("log2_example", "log_nat_example", "log_base_example", "e_example", "rand_example", "rand_int_example", "uuid_example", "bin_example", "hex_numeric_example", "hex_string_example", "unhex_example", "truncate_scale_example", "truncate_default_example", "printf_example", "startswith_example", "endswith_example", "regexp_extract_example", "regexp_extract_group_example", "regexp_extract_all_example", "regexp_replace_example", "regexp_count_example", "regexp_instr_example", "decode_example", "encode_example", "from_base64_example", "to_base64_example", "instr_example", "locate_example", "regexp_example", "split_index_example", "json_quote_example", "json_object_kv_example", "elt_example", "try_cast_to_int_example", "try_cast_to_bigint_example", "try_cast_to_bool_example", "try_cast_to_text_example", "try_cast_to_decimal_example", "try_cast_to_timestamp_example", "try_cast_to_timestamptz_example", "try_cast_fail_example", "try_cast_timestampdiff_decimal_example", "now_example", "local_time_example", "local_timestamp_example", "current_time_example", "current_date_example", "current_timestamp_example", "year_example", "quarter_example", "month_example", "week_example", "dayofyear_example", "dayofmonth_example", "dayofweek_example", "hour_example", "minute_example", "second_example", "date_format_example", "date_format_replace_t_space_pattern_example", "date_format_empty_example", "date_format_blank_example", "date_format_invalid_example", "date_format_null_example", "timestampadd_example", "timestampdiff_second_example", "timestampdiff_minute_example", "timestampdiff_hour_example", "timestampdiff_day_example", "timestampdiff_week_example", "timestampdiff_month_example", "timestampdiff_quarter_example", "timestampdiff_year_example", "convert_tz_example", "unix_timestamp_now_example", "to_timestamp_example", "to_timestamp_pattern_example", "to_timestamp_escaped_t_pattern_example", "to_timestamp_replace_t_space_pattern_example", "to_timestamp_replace_t_space_cast_example", "to_timestamp_invalid_example", "to_timestamp_invalid_pattern_example", "to_timestamp_empty_example", "to_timestamp_empty_pattern_example", "to_timestamp_blank_example", "to_timestamp_blank_pattern_example", "to_timestamp_null_example", "to_timestamp_null_pattern_example", "if_example", "ifnull_example", "is_alpha_example", "is_decimal_example", "is_digit_example", "element_example", "cardinality_example", "map_index_example", "array_contains_example", "array_distinct_example", "array_prepend_example", "array_slice_example", "array_concat_example", "array_remove_example", "array_remove_null_example", "array_remove_null_cast_example", "array_join_example", "split_example", "sha1_example", "sha256_example", "the_end") AS SELECT LOG2(8) AS "log2_example", LOG(10) AS "log_nat_example", LOG(2, 8) AS "log_base_example", EXP(1) AS "e_example", RANDOM() IS NOT NULL AS "rand_example", FLOOR(RANDOM() * 10) IS NOT NULL AS "rand_int_example", UUID() IS NOT NULL AS "uuid_example", BIN(10) AS "bin_example", HEX(255) AS "hex_numeric_example", HEX('AB') AS "hex_string_example", "UNHEX"('4142') AS "unhex_example", TRUNC(123.456, 2) AS "truncate_scale_example", TRUNC(123.456) AS "truncate_default_example", "PRINTF"('Hello %s %d', 'world', 42) AS "printf_example", STARTS_WITH('FlinkSQL', 'Flink') AS "startswith_example", ENDS_WITH('FlinkSQL', 'SQL') AS "endswith_example", REGEXP_EXTRACT('abc-123-def', '(\d+)') AS "regexp_extract_example", REGEXP_EXTRACT('abc-123-def', '(\d+)', 1) AS "regexp_extract_group_example", "REGEXP_EXTRACT_ALL"('a1b2c3', '(\d)', 1) AS "regexp_extract_all_example", REGEXP_REPLACE('a1b2c3', '[0-9]', 'X', 'g') AS "regexp_replace_example", "len"("regexp_extract_all"('a1b2c3', '[0-9]')) AS "regexp_count_example", CASE WHEN "regexp_matches"('a1b2c3', 'c') THEN "strpos"('a1b2c3', "regexp_extract"('a1b2c3', 'c')) ELSE 0 END AS "regexp_instr_example", DECODE(ENCODE('hi')) AS "decode_example", ENCODE('hi') IS NOT NULL AS "encode_example", FROM_BASE64(TO_BASE64('hello')) AS "from_base64_example", TO_BASE64('hello') AS "to_base64_example", INSTR('hello world', 'world') AS "instr_example", INSTR('hello', 'l') AS "locate_example", REGEXP_MATCHES('foo123bar', '\\d+') AS "regexp_example", SPLIT_PART('a,b,c', ',', 2) AS "split_index_example", "JSON_QUOTE"('hello "json"') AS "json_quote_example", JSON_OBJECT('k1', 'v1', 'k2', 'v2') AS "json_object_kv_example", LIST_EXTRACT(['first', 'second', 'third'], 2) AS "elt_example", (TRY_CAST ('123' AS INTEGER)) AS "try_cast_to_int_example", (TRY_CAST ('112233445566778899' AS BIGINT)) AS "try_cast_to_bigint_example", (TRY_CAST ('true' AS BOOLEAN)) AS "try_cast_to_bool_example", (TRY_CAST (123 AS VARCHAR(65536))) AS "try_cast_to_text_example", (TRY_CAST ('123.45' AS DECIMAL(10, 2))) AS "try_cast_to_decimal_example", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP(3))) IS NOT NULL AS "try_cast_to_timestamp_example", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP WITH TIME ZONE)) IS NOT NULL AS "try_cast_to_timestamptz_example", (TRY_CAST ('abc' AS INTEGER)) AS "try_cast_fail_example", (TRY_CAST (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) AS DECIMAL(19, 2))) AS "try_cast_timestampdiff_decimal_example", NOW() IS NOT NULL AS "now_example", LOCALTIME IS NOT NULL AS "local_time_example", LOCALTIMESTAMP IS NOT NULL AS "local_timestamp_example", CURRENT_TIME IS NOT NULL AS "current_time_example", CURRENT_DATE IS NOT NULL AS "current_date_example", CURRENT_TIMESTAMP IS NOT NULL AS "current_timestamp_example", EXTRACT(YEAR FROM DATE '2024-01-02') AS "year_example", EXTRACT(QUARTER FROM DATE '2024-01-02') AS "quarter_example", EXTRACT(MONTH FROM DATE '2024-01-02') AS "month_example", EXTRACT(WEEK FROM DATE '2024-01-02') AS "week_example", EXTRACT(DOY FROM DATE '2024-01-02') AS "dayofyear_example", EXTRACT(DAY FROM DATE '2024-01-02') AS "dayofmonth_example", EXTRACT(DOW FROM DATE '2024-01-02') AS "dayofweek_example", EXTRACT(HOUR FROM TIMESTAMP '2024-01-02 03:04:05') AS "hour_example", EXTRACT(MINUTE FROM TIMESTAMP '2024-01-02 03:04:05') AS "minute_example", EXTRACT(SECOND FROM TIMESTAMP '2024-01-02 03:04:05') AS "second_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d %H:%M:%S') AS "date_format_replace_t_space_pattern_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_empty_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_blank_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_invalid_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_null_example", CAST((TIMESTAMP '2024-01-02 03:04:05' + INTERVAL '1' DAY * 2) AS TIMESTAMP(3)) AS "timestampadd_example", (DATE_DIFF('second', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30')) AS "timestampdiff_second_example", (DATE_DIFF('minute', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00')) AS "timestampdiff_minute_example", (DATE_DIFF('hour', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00')) AS "timestampdiff_hour_example", (DATE_DIFF('day', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00')) AS "timestampdiff_day_example", (DATE_DIFF('week', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00')) AS "timestampdiff_week_example", (DATE_DIFF('month', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00')) AS "timestampdiff_month_example", (DATE_DIFF('quarter', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00')) AS "timestampdiff_quarter_example", (DATE_DIFF('year', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00')) AS "timestampdiff_year_example", (TIMESTAMP '2024-01-02 03:04:05' AT TIME ZONE 'UTC') AT TIME ZONE 'America/Los_Angeles' AS "convert_tz_example", (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) ::bigint)IS NOT NULL AS "unix_timestamp_now_example", TRY_CAST(NULLIF(TRIM(CAST('2024-01-02' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-01T23:10:07' AS VARCHAR)), ''), '%Y-%m-%dT%H:%M:%S') AS "to_timestamp_escaped_t_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS "to_timestamp_replace_t_space_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS "to_timestamp_replace_t_space_cast_example", TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_invalid_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024/01/02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_invalid_pattern_example", TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_empty_example", TRY_STRPTIME(NULLIF(TRIM(CAST('' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_empty_pattern_example", TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_blank_example", TRY_STRPTIME(NULLIF(TRIM(CAST(' ' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_blank_pattern_example", TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_null_example", TRY_STRPTIME(NULLIF(TRIM(CAST(NULL AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_null_pattern_example", IF(TRUE, 'yes', 'no') AS "if_example", "IFNULL"(NULL, 'fallback') AS "ifnull_example", ('OnlyLetters' ~ '^[A-Za-z]+$') AS "is_alpha_example", '123.45' ~ '^[+-]?[0-9]+(\.[0-9]+)?$' AS "is_decimal_example", ('12345' ~ '^[0-9]+$') AS "is_digit_example", "IF"("array_length"(ARRAY[3]) = 1, (ARRAY[3])[1], NULL) AS "element_example", CARDINALITY(MAP { 'a' : 1, 'b' : 2 }) AS "cardinality_example", MAP { 'a' : 1, 'b' : 2 }['a'] AS "map_index_example", "ARRAY_CONTAINS"(ARRAY[1, 2, 3], 2) AS "array_contains_example", "ARRAY_DISTINCT"(ARRAY['a', 'b', 'b', 'c']) AS "array_distinct_example", ARRAY_PREPEND('a', ARRAY['b', 'c']) AS "array_prepend_example", "ARRAY_SLICE"(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS "array_slice_example", "ARRAY_CONCAT"(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS "array_concat_example", LIST_FILTER(ARRAY['a', 'b', 'c'], x -> x <> 'b') AS "array_remove_example", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS "array_remove_null_example", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS "array_remove_null_cast_example", ARRAY_TO_STRING(LIST_TRANSFORM(ARRAY['a', NULL, 'c'], x -> COALESCE(x, '')), '-') AS "array_join_example", "SPLIT"('a|b|c', '|') AS "split_example", SHA1('hello') AS "sha1_example", SHA256('hello') AS "sha256_example", 'end' AS "the_end" +CREATE OR REPLACE VIEW "FunctionCalls"("log2_example", "log_nat_example", "log_base_example", "e_example", "rand_example", "rand_int_example", "uuid_example", "bin_example", "hex_numeric_example", "hex_string_example", "unhex_example", "truncate_scale_example", "truncate_default_example", "printf_example", "startswith_example", "endswith_example", "regexp_extract_example", "regexp_extract_group_example", "regexp_extract_all_example", "regexp_replace_example", "regexp_count_example", "regexp_instr_example", "decode_example", "encode_example", "from_base64_example", "to_base64_example", "instr_example", "locate_example", "regexp_example", "split_index_example", "json_quote_example", "json_object_kv_example", "elt_example", "try_cast_to_int_example", "try_cast_to_bigint_example", "try_cast_to_bool_example", "try_cast_to_text_example", "try_cast_to_decimal_example", "try_cast_to_timestamp_example", "try_cast_to_timestamptz_example", "try_cast_fail_example", "try_cast_timestampdiff_decimal_example", "cast_timestampdiff_decimal_example", "case_timestampdiff_nullif_example", "now_example", "local_time_example", "local_timestamp_example", "current_time_example", "current_date_example", "current_timestamp_example", "year_example", "quarter_example", "month_example", "week_example", "dayofyear_example", "dayofmonth_example", "dayofweek_example", "hour_example", "minute_example", "second_example", "date_format_example", "date_format_replace_t_space_pattern_example", "date_format_empty_example", "date_format_blank_example", "date_format_invalid_example", "date_format_null_example", "timestampadd_example", "timestampdiff_second_example", "timestampdiff_minute_example", "timestampdiff_hour_example", "timestampdiff_day_example", "timestampdiff_week_example", "timestampdiff_month_example", "timestampdiff_quarter_example", "timestampdiff_year_example", "convert_tz_example", "unix_timestamp_now_example", "to_timestamp_example", "to_timestamp_pattern_example", "to_timestamp_escaped_t_pattern_example", "to_timestamp_replace_t_space_pattern_example", "to_timestamp_replace_t_space_cast_example", "to_timestamp_invalid_example", "to_timestamp_invalid_pattern_example", "to_timestamp_empty_example", "to_timestamp_empty_pattern_example", "to_timestamp_blank_example", "to_timestamp_blank_pattern_example", "to_timestamp_null_example", "to_timestamp_null_pattern_example", "if_example", "ifnull_example", "is_alpha_example", "is_decimal_example", "is_digit_example", "element_example", "cardinality_example", "map_index_example", "array_contains_example", "array_distinct_example", "array_prepend_example", "array_slice_example", "array_concat_example", "array_remove_example", "array_remove_null_example", "array_remove_null_cast_example", "array_join_example", "split_example", "sha1_example", "sha256_example", "the_end") AS SELECT LOG2(8) AS "log2_example", LOG(10) AS "log_nat_example", LOG(2, 8) AS "log_base_example", EXP(1) AS "e_example", RANDOM() IS NOT NULL AS "rand_example", FLOOR(RANDOM() * 10) IS NOT NULL AS "rand_int_example", UUID() IS NOT NULL AS "uuid_example", BIN(10) AS "bin_example", HEX(255) AS "hex_numeric_example", HEX('AB') AS "hex_string_example", "UNHEX"('4142') AS "unhex_example", TRUNC(123.456, 2) AS "truncate_scale_example", TRUNC(123.456) AS "truncate_default_example", "PRINTF"('Hello %s %d', 'world', 42) AS "printf_example", STARTS_WITH('FlinkSQL', 'Flink') AS "startswith_example", ENDS_WITH('FlinkSQL', 'SQL') AS "endswith_example", REGEXP_EXTRACT('abc-123-def', '(\d+)') AS "regexp_extract_example", REGEXP_EXTRACT('abc-123-def', '(\d+)', 1) AS "regexp_extract_group_example", "REGEXP_EXTRACT_ALL"('a1b2c3', '(\d)', 1) AS "regexp_extract_all_example", REGEXP_REPLACE('a1b2c3', '[0-9]', 'X', 'g') AS "regexp_replace_example", "len"("regexp_extract_all"('a1b2c3', '[0-9]')) AS "regexp_count_example", CASE WHEN "regexp_matches"('a1b2c3', 'c') THEN "strpos"('a1b2c3', "regexp_extract"('a1b2c3', 'c')) ELSE 0 END AS "regexp_instr_example", DECODE(ENCODE('hi')) AS "decode_example", ENCODE('hi') IS NOT NULL AS "encode_example", FROM_BASE64(TO_BASE64('hello')) AS "from_base64_example", TO_BASE64('hello') AS "to_base64_example", INSTR('hello world', 'world') AS "instr_example", INSTR('hello', 'l') AS "locate_example", REGEXP_MATCHES('foo123bar', '\\d+') AS "regexp_example", SPLIT_PART('a,b,c', ',', 2) AS "split_index_example", "JSON_QUOTE"('hello "json"') AS "json_quote_example", JSON_OBJECT('k1', 'v1', 'k2', 'v2') AS "json_object_kv_example", LIST_EXTRACT(['first', 'second', 'third'], 2) AS "elt_example", (TRY_CAST ('123' AS INTEGER)) AS "try_cast_to_int_example", (TRY_CAST ('112233445566778899' AS BIGINT)) AS "try_cast_to_bigint_example", (TRY_CAST ('true' AS BOOLEAN)) AS "try_cast_to_bool_example", (TRY_CAST (123 AS VARCHAR(65536))) AS "try_cast_to_text_example", (TRY_CAST ('123.45' AS DECIMAL(10, 2))) AS "try_cast_to_decimal_example", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP(3))) IS NOT NULL AS "try_cast_to_timestamp_example", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP WITH TIME ZONE)) IS NOT NULL AS "try_cast_to_timestamptz_example", (TRY_CAST ('abc' AS INTEGER)) AS "try_cast_fail_example", (TRY_CAST (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) AS DECIMAL(19, 2))) AS "try_cast_timestampdiff_decimal_example", (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) AS "cast_timestampdiff_decimal_example", CASE WHEN CASE WHEN (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) = 0 THEN NULL ELSE DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) END IS NOT NULL THEN CAST(10 / CASE WHEN (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) = 0 THEN NULL ELSE DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) END AS DECIMAL(19, 5)) ELSE 0 END AS "case_timestampdiff_nullif_example", NOW() IS NOT NULL AS "now_example", LOCALTIME IS NOT NULL AS "local_time_example", LOCALTIMESTAMP IS NOT NULL AS "local_timestamp_example", CURRENT_TIME IS NOT NULL AS "current_time_example", CURRENT_DATE IS NOT NULL AS "current_date_example", CURRENT_TIMESTAMP IS NOT NULL AS "current_timestamp_example", EXTRACT(YEAR FROM DATE '2024-01-02') AS "year_example", EXTRACT(QUARTER FROM DATE '2024-01-02') AS "quarter_example", EXTRACT(MONTH FROM DATE '2024-01-02') AS "month_example", EXTRACT(WEEK FROM DATE '2024-01-02') AS "week_example", EXTRACT(DOY FROM DATE '2024-01-02') AS "dayofyear_example", EXTRACT(DAY FROM DATE '2024-01-02') AS "dayofmonth_example", EXTRACT(DOW FROM DATE '2024-01-02') AS "dayofweek_example", EXTRACT(HOUR FROM TIMESTAMP '2024-01-02 03:04:05') AS "hour_example", EXTRACT(MINUTE FROM TIMESTAMP '2024-01-02 03:04:05') AS "minute_example", EXTRACT(SECOND FROM TIMESTAMP '2024-01-02 03:04:05') AS "second_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d %H:%M:%S') AS "date_format_replace_t_space_pattern_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_empty_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_blank_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_invalid_example", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS "date_format_null_example", CAST((TIMESTAMP '2024-01-02 03:04:05' + INTERVAL '1' DAY * 2) AS TIMESTAMP(3)) AS "timestampadd_example", (DATE_DIFF('second', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30')) AS "timestampdiff_second_example", (DATE_DIFF('minute', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00')) AS "timestampdiff_minute_example", (DATE_DIFF('hour', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00')) AS "timestampdiff_hour_example", (DATE_DIFF('day', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00')) AS "timestampdiff_day_example", (DATE_DIFF('week', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00')) AS "timestampdiff_week_example", (DATE_DIFF('month', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00')) AS "timestampdiff_month_example", (DATE_DIFF('quarter', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00')) AS "timestampdiff_quarter_example", (DATE_DIFF('year', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00')) AS "timestampdiff_year_example", (TIMESTAMP '2024-01-02 03:04:05' AT TIME ZONE 'UTC') AT TIME ZONE 'America/Los_Angeles' AS "convert_tz_example", (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) ::bigint)IS NOT NULL AS "unix_timestamp_now_example", TRY_CAST(NULLIF(TRIM(CAST('2024-01-02' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-01T23:10:07' AS VARCHAR)), ''), '%Y-%m-%dT%H:%M:%S') AS "to_timestamp_escaped_t_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS "to_timestamp_replace_t_space_pattern_example", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS "to_timestamp_replace_t_space_cast_example", TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_invalid_example", TRY_STRPTIME(NULLIF(TRIM(CAST('2024/01/02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_invalid_pattern_example", TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_empty_example", TRY_STRPTIME(NULLIF(TRIM(CAST('' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_empty_pattern_example", TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_blank_example", TRY_STRPTIME(NULLIF(TRIM(CAST(' ' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_blank_pattern_example", TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP) AS "to_timestamp_null_example", TRY_STRPTIME(NULLIF(TRIM(CAST(NULL AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS "to_timestamp_null_pattern_example", IF(TRUE, 'yes', 'no') AS "if_example", "IFNULL"(NULL, 'fallback') AS "ifnull_example", ('OnlyLetters' ~ '^[A-Za-z]+$') AS "is_alpha_example", '123.45' ~ '^[+-]?[0-9]+(\.[0-9]+)?$' AS "is_decimal_example", ('12345' ~ '^[0-9]+$') AS "is_digit_example", "IF"("array_length"(ARRAY[3]) = 1, (ARRAY[3])[1], NULL) AS "element_example", CARDINALITY(MAP { 'a' : 1, 'b' : 2 }) AS "cardinality_example", MAP { 'a' : 1, 'b' : 2 }['a'] AS "map_index_example", "ARRAY_CONTAINS"(ARRAY[1, 2, 3], 2) AS "array_contains_example", "ARRAY_DISTINCT"(ARRAY['a', 'b', 'b', 'c']) AS "array_distinct_example", ARRAY_PREPEND('a', ARRAY['b', 'c']) AS "array_prepend_example", "ARRAY_SLICE"(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS "array_slice_example", "ARRAY_CONCAT"(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS "array_concat_example", LIST_FILTER(ARRAY['a', 'b', 'c'], x -> x <> 'b') AS "array_remove_example", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS "array_remove_null_example", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS "array_remove_null_cast_example", ARRAY_TO_STRING(LIST_TRANSFORM(ARRAY['a', NULL, 'c'], x -> COALESCE(x, '')), '-') AS "array_join_example", "SPLIT"('a|b|c', '|') AS "split_example", SHA1('hello') AS "sha1_example", SHA256('hello') AS "sha256_example", 'end' AS "the_end" FROM "iceberg_scan"('/tmp/duckdb/default_database/_InputData', ALLOW_MOVED_PATHS = TRUE) >>>iceberg-schema.sql CREATE TABLE IF NOT EXISTS "_ArrayData" ("id" INTEGER, "str_char" TEXT); @@ -445,7 +449,7 @@ CREATE TABLE IF NOT EXISTS "_InputData" ("dummy" INTEGER) ], "query" : { "type" : "SqlQuery", - "sql" : "SELECT LOG2(8) AS \"log2_example\", LOG(10) AS \"log_nat_example\", LOG(2, 8) AS \"log_base_example\", EXP(1) AS \"e_example\", RANDOM() IS NOT NULL AS \"rand_example\", FLOOR(RANDOM() * 10) IS NOT NULL AS \"rand_int_example\", UUID() IS NOT NULL AS \"uuid_example\", BIN(10) AS \"bin_example\", HEX(255) AS \"hex_numeric_example\", HEX('AB') AS \"hex_string_example\", \"UNHEX\"('4142') AS \"unhex_example\", TRUNC(123.456, 2) AS \"truncate_scale_example\", TRUNC(123.456) AS \"truncate_default_example\", \"PRINTF\"('Hello %s %d', 'world', 42) AS \"printf_example\", STARTS_WITH('FlinkSQL', 'Flink') AS \"startswith_example\", ENDS_WITH('FlinkSQL', 'SQL') AS \"endswith_example\", REGEXP_EXTRACT('abc-123-def', '(\\d+)') AS \"regexp_extract_example\", REGEXP_EXTRACT('abc-123-def', '(\\d+)', 1) AS \"regexp_extract_group_example\", \"REGEXP_EXTRACT_ALL\"('a1b2c3', '(\\d)', 1) AS \"regexp_extract_all_example\", REGEXP_REPLACE('a1b2c3', '[0-9]', 'X', 'g') AS \"regexp_replace_example\", \"len\"(\"regexp_extract_all\"('a1b2c3', '[0-9]')) AS \"regexp_count_example\", CASE WHEN \"regexp_matches\"('a1b2c3', 'c') THEN \"strpos\"('a1b2c3', \"regexp_extract\"('a1b2c3', 'c')) ELSE 0 END AS \"regexp_instr_example\", DECODE(ENCODE('hi')) AS \"decode_example\", ENCODE('hi') IS NOT NULL AS \"encode_example\", FROM_BASE64(TO_BASE64('hello')) AS \"from_base64_example\", TO_BASE64('hello') AS \"to_base64_example\", INSTR('hello world', 'world') AS \"instr_example\", INSTR('hello', 'l') AS \"locate_example\", REGEXP_MATCHES('foo123bar', '\\\\d+') AS \"regexp_example\", SPLIT_PART('a,b,c', ',', 2) AS \"split_index_example\", \"JSON_QUOTE\"('hello \"json\"') AS \"json_quote_example\", JSON_OBJECT('k1', 'v1', 'k2', 'v2') AS \"json_object_kv_example\", LIST_EXTRACT(['first', 'second', 'third'], 2) AS \"elt_example\", (TRY_CAST ('123' AS INTEGER)) AS \"try_cast_to_int_example\", (TRY_CAST ('112233445566778899' AS BIGINT)) AS \"try_cast_to_bigint_example\", (TRY_CAST ('true' AS BOOLEAN)) AS \"try_cast_to_bool_example\", (TRY_CAST (123 AS VARCHAR(65536))) AS \"try_cast_to_text_example\", (TRY_CAST ('123.45' AS DECIMAL(10, 2))) AS \"try_cast_to_decimal_example\", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP(3))) IS NOT NULL AS \"try_cast_to_timestamp_example\", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP WITH TIME ZONE)) IS NOT NULL AS \"try_cast_to_timestamptz_example\", (TRY_CAST ('abc' AS INTEGER)) AS \"try_cast_fail_example\", (TRY_CAST (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) AS DECIMAL(19, 2))) AS \"try_cast_timestampdiff_decimal_example\", NOW() IS NOT NULL AS \"now_example\", LOCALTIME IS NOT NULL AS \"local_time_example\", LOCALTIMESTAMP IS NOT NULL AS \"local_timestamp_example\", CURRENT_TIME IS NOT NULL AS \"current_time_example\", CURRENT_DATE IS NOT NULL AS \"current_date_example\", CURRENT_TIMESTAMP IS NOT NULL AS \"current_timestamp_example\", EXTRACT(YEAR FROM DATE '2024-01-02') AS \"year_example\", EXTRACT(QUARTER FROM DATE '2024-01-02') AS \"quarter_example\", EXTRACT(MONTH FROM DATE '2024-01-02') AS \"month_example\", EXTRACT(WEEK FROM DATE '2024-01-02') AS \"week_example\", EXTRACT(DOY FROM DATE '2024-01-02') AS \"dayofyear_example\", EXTRACT(DAY FROM DATE '2024-01-02') AS \"dayofmonth_example\", EXTRACT(DOW FROM DATE '2024-01-02') AS \"dayofweek_example\", EXTRACT(HOUR FROM TIMESTAMP '2024-01-02 03:04:05') AS \"hour_example\", EXTRACT(MINUTE FROM TIMESTAMP '2024-01-02 03:04:05') AS \"minute_example\", EXTRACT(SECOND FROM TIMESTAMP '2024-01-02 03:04:05') AS \"second_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d %H:%M:%S') AS \"date_format_replace_t_space_pattern_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_empty_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_blank_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_invalid_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_null_example\", CAST((TIMESTAMP '2024-01-02 03:04:05' + INTERVAL '1' DAY * 2) AS TIMESTAMP(3)) AS \"timestampadd_example\", (DATE_DIFF('second', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30')) AS \"timestampdiff_second_example\", (DATE_DIFF('minute', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00')) AS \"timestampdiff_minute_example\", (DATE_DIFF('hour', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00')) AS \"timestampdiff_hour_example\", (DATE_DIFF('day', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00')) AS \"timestampdiff_day_example\", (DATE_DIFF('week', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00')) AS \"timestampdiff_week_example\", (DATE_DIFF('month', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00')) AS \"timestampdiff_month_example\", (DATE_DIFF('quarter', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00')) AS \"timestampdiff_quarter_example\", (DATE_DIFF('year', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00')) AS \"timestampdiff_year_example\", (TIMESTAMP '2024-01-02 03:04:05' AT TIME ZONE 'UTC') AT TIME ZONE 'America/Los_Angeles' AS \"convert_tz_example\", (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) ::bigint)IS NOT NULL AS \"unix_timestamp_now_example\", TRY_CAST(NULLIF(TRIM(CAST('2024-01-02' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-01T23:10:07' AS VARCHAR)), ''), '%Y-%m-%dT%H:%M:%S') AS \"to_timestamp_escaped_t_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS \"to_timestamp_replace_t_space_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS \"to_timestamp_replace_t_space_cast_example\", TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_invalid_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024/01/02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_invalid_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_empty_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_empty_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_blank_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(' ' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_blank_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_null_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(NULL AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_null_pattern_example\", IF(TRUE, 'yes', 'no') AS \"if_example\", \"IFNULL\"(NULL, 'fallback') AS \"ifnull_example\", ('OnlyLetters' ~ '^[A-Za-z]+$') AS \"is_alpha_example\", '123.45' ~ '^[+-]?[0-9]+(\\.[0-9]+)?$' AS \"is_decimal_example\", ('12345' ~ '^[0-9]+$') AS \"is_digit_example\", \"IF\"(\"array_length\"(ARRAY[3]) = 1, (ARRAY[3])[1], NULL) AS \"element_example\", CARDINALITY(MAP { 'a' : 1, 'b' : 2 }) AS \"cardinality_example\", MAP { 'a' : 1, 'b' : 2 }['a'] AS \"map_index_example\", \"ARRAY_CONTAINS\"(ARRAY[1, 2, 3], 2) AS \"array_contains_example\", \"ARRAY_DISTINCT\"(ARRAY['a', 'b', 'b', 'c']) AS \"array_distinct_example\", ARRAY_PREPEND('a', ARRAY['b', 'c']) AS \"array_prepend_example\", \"ARRAY_SLICE\"(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS \"array_slice_example\", \"ARRAY_CONCAT\"(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS \"array_concat_example\", LIST_FILTER(ARRAY['a', 'b', 'c'], x -> x <> 'b') AS \"array_remove_example\", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS \"array_remove_null_example\", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS \"array_remove_null_cast_example\", ARRAY_TO_STRING(LIST_TRANSFORM(ARRAY['a', NULL, 'c'], x -> COALESCE(x, '')), '-') AS \"array_join_example\", \"SPLIT\"('a|b|c', '|') AS \"split_example\", SHA1('hello') AS \"sha1_example\", SHA256('hello') AS \"sha256_example\", 'end' AS \"the_end\"\nFROM \"iceberg_scan\"('/tmp/duckdb/default_database/_InputData', ALLOW_MOVED_PATHS = TRUE)", + "sql" : "SELECT LOG2(8) AS \"log2_example\", LOG(10) AS \"log_nat_example\", LOG(2, 8) AS \"log_base_example\", EXP(1) AS \"e_example\", RANDOM() IS NOT NULL AS \"rand_example\", FLOOR(RANDOM() * 10) IS NOT NULL AS \"rand_int_example\", UUID() IS NOT NULL AS \"uuid_example\", BIN(10) AS \"bin_example\", HEX(255) AS \"hex_numeric_example\", HEX('AB') AS \"hex_string_example\", \"UNHEX\"('4142') AS \"unhex_example\", TRUNC(123.456, 2) AS \"truncate_scale_example\", TRUNC(123.456) AS \"truncate_default_example\", \"PRINTF\"('Hello %s %d', 'world', 42) AS \"printf_example\", STARTS_WITH('FlinkSQL', 'Flink') AS \"startswith_example\", ENDS_WITH('FlinkSQL', 'SQL') AS \"endswith_example\", REGEXP_EXTRACT('abc-123-def', '(\\d+)') AS \"regexp_extract_example\", REGEXP_EXTRACT('abc-123-def', '(\\d+)', 1) AS \"regexp_extract_group_example\", \"REGEXP_EXTRACT_ALL\"('a1b2c3', '(\\d)', 1) AS \"regexp_extract_all_example\", REGEXP_REPLACE('a1b2c3', '[0-9]', 'X', 'g') AS \"regexp_replace_example\", \"len\"(\"regexp_extract_all\"('a1b2c3', '[0-9]')) AS \"regexp_count_example\", CASE WHEN \"regexp_matches\"('a1b2c3', 'c') THEN \"strpos\"('a1b2c3', \"regexp_extract\"('a1b2c3', 'c')) ELSE 0 END AS \"regexp_instr_example\", DECODE(ENCODE('hi')) AS \"decode_example\", ENCODE('hi') IS NOT NULL AS \"encode_example\", FROM_BASE64(TO_BASE64('hello')) AS \"from_base64_example\", TO_BASE64('hello') AS \"to_base64_example\", INSTR('hello world', 'world') AS \"instr_example\", INSTR('hello', 'l') AS \"locate_example\", REGEXP_MATCHES('foo123bar', '\\\\d+') AS \"regexp_example\", SPLIT_PART('a,b,c', ',', 2) AS \"split_index_example\", \"JSON_QUOTE\"('hello \"json\"') AS \"json_quote_example\", JSON_OBJECT('k1', 'v1', 'k2', 'v2') AS \"json_object_kv_example\", LIST_EXTRACT(['first', 'second', 'third'], 2) AS \"elt_example\", (TRY_CAST ('123' AS INTEGER)) AS \"try_cast_to_int_example\", (TRY_CAST ('112233445566778899' AS BIGINT)) AS \"try_cast_to_bigint_example\", (TRY_CAST ('true' AS BOOLEAN)) AS \"try_cast_to_bool_example\", (TRY_CAST (123 AS VARCHAR(65536))) AS \"try_cast_to_text_example\", (TRY_CAST ('123.45' AS DECIMAL(10, 2))) AS \"try_cast_to_decimal_example\", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP(3))) IS NOT NULL AS \"try_cast_to_timestamp_example\", (TRY_CAST ('2024-01-02 03:04:05' AS TIMESTAMP WITH TIME ZONE)) IS NOT NULL AS \"try_cast_to_timestamptz_example\", (TRY_CAST ('abc' AS INTEGER)) AS \"try_cast_fail_example\", (TRY_CAST (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) AS DECIMAL(19, 2))) AS \"try_cast_timestampdiff_decimal_example\", (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) AS \"cast_timestampdiff_decimal_example\", CASE WHEN CASE WHEN (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) = 0 THEN NULL ELSE DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) END IS NOT NULL THEN CAST(10 / CASE WHEN (DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)))) = 0 THEN NULL ELSE DATE_DIFF('month', CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6)), CAST(STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-03-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-01') AS TIMESTAMP(6))) END AS DECIMAL(19, 5)) ELSE 0 END AS \"case_timestampdiff_nullif_example\", NOW() IS NOT NULL AS \"now_example\", LOCALTIME IS NOT NULL AS \"local_time_example\", LOCALTIMESTAMP IS NOT NULL AS \"local_timestamp_example\", CURRENT_TIME IS NOT NULL AS \"current_time_example\", CURRENT_DATE IS NOT NULL AS \"current_date_example\", CURRENT_TIMESTAMP IS NOT NULL AS \"current_timestamp_example\", EXTRACT(YEAR FROM DATE '2024-01-02') AS \"year_example\", EXTRACT(QUARTER FROM DATE '2024-01-02') AS \"quarter_example\", EXTRACT(MONTH FROM DATE '2024-01-02') AS \"month_example\", EXTRACT(WEEK FROM DATE '2024-01-02') AS \"week_example\", EXTRACT(DOY FROM DATE '2024-01-02') AS \"dayofyear_example\", EXTRACT(DAY FROM DATE '2024-01-02') AS \"dayofmonth_example\", EXTRACT(DOW FROM DATE '2024-01-02') AS \"dayofweek_example\", EXTRACT(HOUR FROM TIMESTAMP '2024-01-02 03:04:05') AS \"hour_example\", EXTRACT(MINUTE FROM TIMESTAMP '2024-01-02 03:04:05') AS \"minute_example\", EXTRACT(SECOND FROM TIMESTAMP '2024-01-02 03:04:05') AS \"second_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(TIMESTAMP '2024-01-02 03:04:05' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d %H:%M:%S') AS \"date_format_replace_t_space_pattern_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_empty_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_blank_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_invalid_example\", STRFTIME(TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP), '%Y-%m-%d') AS \"date_format_null_example\", CAST((TIMESTAMP '2024-01-02 03:04:05' + INTERVAL '1' DAY * 2) AS TIMESTAMP(3)) AS \"timestampadd_example\", (DATE_DIFF('second', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:00:30')) AS \"timestampdiff_second_example\", (DATE_DIFF('minute', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-01 00:15:00')) AS \"timestampdiff_minute_example\", (DATE_DIFF('hour', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-02 05:00:00')) AS \"timestampdiff_hour_example\", (DATE_DIFF('day', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-03 00:00:00')) AS \"timestampdiff_day_example\", (DATE_DIFF('week', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-01-22 00:00:00')) AS \"timestampdiff_week_example\", (DATE_DIFF('month', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-04-01 00:00:00')) AS \"timestampdiff_month_example\", (DATE_DIFF('quarter', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2024-10-01 00:00:00')) AS \"timestampdiff_quarter_example\", (DATE_DIFF('year', TIMESTAMP '2024-01-01 00:00:00', TIMESTAMP '2027-01-01 00:00:00')) AS \"timestampdiff_year_example\", (TIMESTAMP '2024-01-02 03:04:05' AT TIME ZONE 'UTC') AT TIME ZONE 'America/Los_Angeles' AS \"convert_tz_example\", (EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) ::bigint)IS NOT NULL AS \"unix_timestamp_now_example\", TRY_CAST(NULLIF(TRIM(CAST('2024-01-02' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024-01-01T23:10:07' AS VARCHAR)), ''), '%Y-%m-%dT%H:%M:%S') AS \"to_timestamp_escaped_t_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS \"to_timestamp_replace_t_space_pattern_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(REPLACE('2024-01-01T23:10:07', 'T', ' ') AS VARCHAR)), ''), '%Y-%m-%d %H:%M:%S') AS \"to_timestamp_replace_t_space_cast_example\", TRY_CAST(NULLIF(TRIM(CAST('not-a-date' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_invalid_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('2024/01/02 03:04' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_invalid_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST('' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_empty_example\", TRY_STRPTIME(NULLIF(TRIM(CAST('' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_empty_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST(' ' AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_blank_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(' ' AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_blank_pattern_example\", TRY_CAST(NULLIF(TRIM(CAST(NULL AS VARCHAR)), '') AS TIMESTAMP) AS \"to_timestamp_null_example\", TRY_STRPTIME(NULLIF(TRIM(CAST(NULL AS VARCHAR)), ''), '%Y-%m-%d %H:%M') AS \"to_timestamp_null_pattern_example\", IF(TRUE, 'yes', 'no') AS \"if_example\", \"IFNULL\"(NULL, 'fallback') AS \"ifnull_example\", ('OnlyLetters' ~ '^[A-Za-z]+$') AS \"is_alpha_example\", '123.45' ~ '^[+-]?[0-9]+(\\.[0-9]+)?$' AS \"is_decimal_example\", ('12345' ~ '^[0-9]+$') AS \"is_digit_example\", \"IF\"(\"array_length\"(ARRAY[3]) = 1, (ARRAY[3])[1], NULL) AS \"element_example\", CARDINALITY(MAP { 'a' : 1, 'b' : 2 }) AS \"cardinality_example\", MAP { 'a' : 1, 'b' : 2 }['a'] AS \"map_index_example\", \"ARRAY_CONTAINS\"(ARRAY[1, 2, 3], 2) AS \"array_contains_example\", \"ARRAY_DISTINCT\"(ARRAY['a', 'b', 'b', 'c']) AS \"array_distinct_example\", ARRAY_PREPEND('a', ARRAY['b', 'c']) AS \"array_prepend_example\", \"ARRAY_SLICE\"(ARRAY['a', 'b', 'c', 'd', 'e'], 2, 4) AS \"array_slice_example\", \"ARRAY_CONCAT\"(ARRAY['a', 'b'], ARRAY['c', 'd'], ARRAY['e']) AS \"array_concat_example\", LIST_FILTER(ARRAY['a', 'b', 'c'], x -> x <> 'b') AS \"array_remove_example\", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS \"array_remove_null_example\", LIST_FILTER(ARRAY['a', NULL], x -> x IS NOT NULL) AS \"array_remove_null_cast_example\", ARRAY_TO_STRING(LIST_TRANSFORM(ARRAY['a', NULL, 'c'], x -> COALESCE(x, '')), '-') AS \"array_join_example\", \"SPLIT\"('a|b|c', '|') AS \"split_example\", SHA1('hello') AS \"sha1_example\", SHA256('hello') AS \"sha256_example\", 'end' AS \"the_end\"\nFROM \"iceberg_scan\"('/tmp/duckdb/default_database/_InputData', ALLOW_MOVED_PATHS = TRUE)", "parameters" : [ ], "pagination" : "LIMIT_AND_OFFSET", "cacheDurationMs" : 0, @@ -501,7 +505,7 @@ CREATE TABLE IF NOT EXISTS "_InputData" ("dummy" INTEGER) }, "format" : "JSON", "apiQuery" : { - "query" : "query FunctionCalls($limit: Int = 10, $offset: Int = 0) {\nFunctionCalls(limit: $limit, offset: $offset) {\nlog2_example\nlog_nat_example\nlog_base_example\ne_example\nrand_example\nrand_int_example\nuuid_example\nbin_example\nhex_numeric_example\nhex_string_example\ntruncate_scale_example\ntruncate_default_example\nprintf_example\nstartswith_example\nendswith_example\nregexp_extract_example\nregexp_extract_group_example\nregexp_extract_all_example\nregexp_replace_example\nregexp_count_example\nregexp_instr_example\ndecode_example\nencode_example\nfrom_base64_example\nto_base64_example\ninstr_example\nlocate_example\nregexp_example\nsplit_index_example\njson_quote_example\njson_object_kv_example\nelt_example\ntry_cast_to_int_example\ntry_cast_to_bigint_example\ntry_cast_to_bool_example\ntry_cast_to_text_example\ntry_cast_to_decimal_example\ntry_cast_to_timestamp_example\ntry_cast_to_timestamptz_example\ntry_cast_fail_example\ntry_cast_timestampdiff_decimal_example\nnow_example\nlocal_time_example\nlocal_timestamp_example\ncurrent_time_example\ncurrent_date_example\ncurrent_timestamp_example\nyear_example\nquarter_example\nmonth_example\nweek_example\ndayofyear_example\ndayofmonth_example\ndayofweek_example\nhour_example\nminute_example\nsecond_example\ndate_format_example\ndate_format_replace_t_space_pattern_example\ndate_format_empty_example\ndate_format_blank_example\ndate_format_invalid_example\ndate_format_null_example\ntimestampadd_example\ntimestampdiff_second_example\ntimestampdiff_minute_example\ntimestampdiff_hour_example\ntimestampdiff_day_example\ntimestampdiff_week_example\ntimestampdiff_month_example\ntimestampdiff_quarter_example\ntimestampdiff_year_example\nconvert_tz_example\nunix_timestamp_now_example\nto_timestamp_example\nto_timestamp_pattern_example\nto_timestamp_escaped_t_pattern_example\nto_timestamp_replace_t_space_pattern_example\nto_timestamp_replace_t_space_cast_example\nto_timestamp_invalid_example\nto_timestamp_invalid_pattern_example\nto_timestamp_empty_example\nto_timestamp_empty_pattern_example\nto_timestamp_blank_example\nto_timestamp_blank_pattern_example\nto_timestamp_null_example\nto_timestamp_null_pattern_example\nif_example\nifnull_example\nis_alpha_example\nis_decimal_example\nis_digit_example\nelement_example\ncardinality_example\nmap_index_example\narray_contains_example\narray_distinct_example\narray_prepend_example\narray_slice_example\narray_concat_example\narray_remove_example\narray_remove_null_example\narray_remove_null_cast_example\narray_join_example\nsplit_example\nsha1_example\nsha256_example\nthe_end\n}\n\n}", + "query" : "query FunctionCalls($limit: Int = 10, $offset: Int = 0) {\nFunctionCalls(limit: $limit, offset: $offset) {\nlog2_example\nlog_nat_example\nlog_base_example\ne_example\nrand_example\nrand_int_example\nuuid_example\nbin_example\nhex_numeric_example\nhex_string_example\ntruncate_scale_example\ntruncate_default_example\nprintf_example\nstartswith_example\nendswith_example\nregexp_extract_example\nregexp_extract_group_example\nregexp_extract_all_example\nregexp_replace_example\nregexp_count_example\nregexp_instr_example\ndecode_example\nencode_example\nfrom_base64_example\nto_base64_example\ninstr_example\nlocate_example\nregexp_example\nsplit_index_example\njson_quote_example\njson_object_kv_example\nelt_example\ntry_cast_to_int_example\ntry_cast_to_bigint_example\ntry_cast_to_bool_example\ntry_cast_to_text_example\ntry_cast_to_decimal_example\ntry_cast_to_timestamp_example\ntry_cast_to_timestamptz_example\ntry_cast_fail_example\ntry_cast_timestampdiff_decimal_example\ncast_timestampdiff_decimal_example\ncase_timestampdiff_nullif_example\nnow_example\nlocal_time_example\nlocal_timestamp_example\ncurrent_time_example\ncurrent_date_example\ncurrent_timestamp_example\nyear_example\nquarter_example\nmonth_example\nweek_example\ndayofyear_example\ndayofmonth_example\ndayofweek_example\nhour_example\nminute_example\nsecond_example\ndate_format_example\ndate_format_replace_t_space_pattern_example\ndate_format_empty_example\ndate_format_blank_example\ndate_format_invalid_example\ndate_format_null_example\ntimestampadd_example\ntimestampdiff_second_example\ntimestampdiff_minute_example\ntimestampdiff_hour_example\ntimestampdiff_day_example\ntimestampdiff_week_example\ntimestampdiff_month_example\ntimestampdiff_quarter_example\ntimestampdiff_year_example\nconvert_tz_example\nunix_timestamp_now_example\nto_timestamp_example\nto_timestamp_pattern_example\nto_timestamp_escaped_t_pattern_example\nto_timestamp_replace_t_space_pattern_example\nto_timestamp_replace_t_space_cast_example\nto_timestamp_invalid_example\nto_timestamp_invalid_pattern_example\nto_timestamp_empty_example\nto_timestamp_empty_pattern_example\nto_timestamp_blank_example\nto_timestamp_blank_pattern_example\nto_timestamp_null_example\nto_timestamp_null_pattern_example\nif_example\nifnull_example\nis_alpha_example\nis_decimal_example\nis_digit_example\nelement_example\ncardinality_example\nmap_index_example\narray_contains_example\narray_distinct_example\narray_prepend_example\narray_slice_example\narray_concat_example\narray_remove_example\narray_remove_null_example\narray_remove_null_cast_example\narray_join_example\nsplit_example\nsha1_example\nsha256_example\nthe_end\n}\n\n}", "queryName" : "FunctionCalls", "operationType" : "QUERY" }, @@ -512,7 +516,7 @@ CREATE TABLE IF NOT EXISTS "_InputData" ("dummy" INTEGER) ], "schema" : { "type" : "string", - "schema" : "type ArrayFunctions {\n listagg_example: String\n arrayagg_example: [String]\n}\n\n\"An RFC-3339 compliant Full Date Scalar\"\nscalar Date\n\n\"A DateTime scalar that handles both full RFC3339 and shorter timestamp formats\"\nscalar DateTime\n\ntype FunctionCalls {\n log2_example: Float!\n log_nat_example: Float!\n log_base_example: Float!\n e_example: Float!\n rand_example: Boolean!\n rand_int_example: Boolean!\n uuid_example: Boolean!\n bin_example: String!\n hex_numeric_example: String!\n hex_string_example: String!\n truncate_scale_example: Float!\n truncate_default_example: Float!\n printf_example: String\n startswith_example: Boolean!\n endswith_example: Boolean!\n regexp_extract_example: String\n regexp_extract_group_example: String\n regexp_extract_all_example: [String]\n regexp_replace_example: String!\n regexp_count_example: Int\n regexp_instr_example: Int\n decode_example: String!\n encode_example: Boolean!\n from_base64_example: String!\n to_base64_example: String!\n instr_example: Int!\n locate_example: Int!\n regexp_example: Boolean!\n split_index_example: String\n json_quote_example: String!\n json_object_kv_example: String!\n elt_example: String\n try_cast_to_int_example: Int\n try_cast_to_bigint_example: Long\n try_cast_to_bool_example: Boolean\n try_cast_to_text_example: String\n try_cast_to_decimal_example: Float\n try_cast_to_timestamp_example: Boolean!\n try_cast_to_timestamptz_example: Boolean!\n try_cast_fail_example: Int\n try_cast_timestampdiff_decimal_example: Float\n now_example: Boolean!\n local_time_example: Boolean!\n local_timestamp_example: Boolean!\n current_time_example: Boolean!\n current_date_example: Boolean!\n current_timestamp_example: Boolean!\n year_example: Long!\n quarter_example: Long!\n month_example: Long!\n week_example: Long!\n dayofyear_example: Long!\n dayofmonth_example: Long!\n dayofweek_example: Long!\n hour_example: Long!\n minute_example: Long!\n second_example: Long!\n date_format_example: String\n date_format_replace_t_space_pattern_example: String\n date_format_empty_example: String\n date_format_blank_example: String\n date_format_invalid_example: String\n date_format_null_example: String\n timestampadd_example: DateTime!\n timestampdiff_second_example: Int!\n timestampdiff_minute_example: Int!\n timestampdiff_hour_example: Int!\n timestampdiff_day_example: Int!\n timestampdiff_week_example: Int!\n timestampdiff_month_example: Int!\n timestampdiff_quarter_example: Int!\n timestampdiff_year_example: Int!\n convert_tz_example: String\n unix_timestamp_now_example: Boolean!\n to_timestamp_example: DateTime\n to_timestamp_pattern_example: DateTime\n to_timestamp_escaped_t_pattern_example: DateTime\n to_timestamp_replace_t_space_pattern_example: DateTime\n to_timestamp_replace_t_space_cast_example: DateTime\n to_timestamp_invalid_example: DateTime\n to_timestamp_invalid_pattern_example: DateTime\n to_timestamp_empty_example: DateTime\n to_timestamp_empty_pattern_example: DateTime\n to_timestamp_blank_example: DateTime\n to_timestamp_blank_pattern_example: DateTime\n to_timestamp_null_example: DateTime\n to_timestamp_null_pattern_example: DateTime\n if_example: String!\n ifnull_example: String!\n is_alpha_example: Boolean!\n is_decimal_example: Boolean!\n is_digit_example: Boolean!\n element_example: Int!\n cardinality_example: Int!\n map_index_example: Int\n array_contains_example: Boolean!\n array_distinct_example: [String]!\n array_prepend_example: [String]!\n array_slice_example: [String]!\n array_concat_example: [String]!\n array_remove_example: [String]!\n array_remove_null_example: [String]!\n array_remove_null_cast_example: [String]!\n array_join_example: String!\n split_example: [String]\n sha1_example: String!\n sha256_example: String!\n the_end: String!\n}\n\n\"A JSON scalar\"\nscalar JSON\n\n\"24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.\"\nscalar LocalTime\n\n\"A 64-bit signed integer\"\nscalar Long\n\ntype Query {\n ArrayFunctions(limit: Int = 10, offset: Int = 0): [ArrayFunctions!]\n FunctionCalls(limit: Int = 10, offset: Int = 0): [FunctionCalls!]\n}\n\nenum _McpMethodType {\n NONE\n TOOL\n RESOURCE\n}\n\nenum _RestMethodType {\n NONE\n GET\n POST\n}\n\ndirective @api(mcp: _McpMethodType, rest: _RestMethodType, uri: String) on QUERY | MUTATION | FIELD_DEFINITION\n" + "schema" : "type ArrayFunctions {\n listagg_example: String\n arrayagg_example: [String]\n}\n\n\"An RFC-3339 compliant Full Date Scalar\"\nscalar Date\n\n\"A DateTime scalar that handles both full RFC3339 and shorter timestamp formats\"\nscalar DateTime\n\ntype FunctionCalls {\n log2_example: Float!\n log_nat_example: Float!\n log_base_example: Float!\n e_example: Float!\n rand_example: Boolean!\n rand_int_example: Boolean!\n uuid_example: Boolean!\n bin_example: String!\n hex_numeric_example: String!\n hex_string_example: String!\n truncate_scale_example: Float!\n truncate_default_example: Float!\n printf_example: String\n startswith_example: Boolean!\n endswith_example: Boolean!\n regexp_extract_example: String\n regexp_extract_group_example: String\n regexp_extract_all_example: [String]\n regexp_replace_example: String!\n regexp_count_example: Int\n regexp_instr_example: Int\n decode_example: String!\n encode_example: Boolean!\n from_base64_example: String!\n to_base64_example: String!\n instr_example: Int!\n locate_example: Int!\n regexp_example: Boolean!\n split_index_example: String\n json_quote_example: String!\n json_object_kv_example: String!\n elt_example: String\n try_cast_to_int_example: Int\n try_cast_to_bigint_example: Long\n try_cast_to_bool_example: Boolean\n try_cast_to_text_example: String\n try_cast_to_decimal_example: Float\n try_cast_to_timestamp_example: Boolean!\n try_cast_to_timestamptz_example: Boolean!\n try_cast_fail_example: Int\n try_cast_timestampdiff_decimal_example: Float\n cast_timestampdiff_decimal_example: Float\n case_timestampdiff_nullif_example: Float!\n now_example: Boolean!\n local_time_example: Boolean!\n local_timestamp_example: Boolean!\n current_time_example: Boolean!\n current_date_example: Boolean!\n current_timestamp_example: Boolean!\n year_example: Long!\n quarter_example: Long!\n month_example: Long!\n week_example: Long!\n dayofyear_example: Long!\n dayofmonth_example: Long!\n dayofweek_example: Long!\n hour_example: Long!\n minute_example: Long!\n second_example: Long!\n date_format_example: String\n date_format_replace_t_space_pattern_example: String\n date_format_empty_example: String\n date_format_blank_example: String\n date_format_invalid_example: String\n date_format_null_example: String\n timestampadd_example: DateTime!\n timestampdiff_second_example: Int!\n timestampdiff_minute_example: Int!\n timestampdiff_hour_example: Int!\n timestampdiff_day_example: Int!\n timestampdiff_week_example: Int!\n timestampdiff_month_example: Int!\n timestampdiff_quarter_example: Int!\n timestampdiff_year_example: Int!\n convert_tz_example: String\n unix_timestamp_now_example: Boolean!\n to_timestamp_example: DateTime\n to_timestamp_pattern_example: DateTime\n to_timestamp_escaped_t_pattern_example: DateTime\n to_timestamp_replace_t_space_pattern_example: DateTime\n to_timestamp_replace_t_space_cast_example: DateTime\n to_timestamp_invalid_example: DateTime\n to_timestamp_invalid_pattern_example: DateTime\n to_timestamp_empty_example: DateTime\n to_timestamp_empty_pattern_example: DateTime\n to_timestamp_blank_example: DateTime\n to_timestamp_blank_pattern_example: DateTime\n to_timestamp_null_example: DateTime\n to_timestamp_null_pattern_example: DateTime\n if_example: String!\n ifnull_example: String!\n is_alpha_example: Boolean!\n is_decimal_example: Boolean!\n is_digit_example: Boolean!\n element_example: Int!\n cardinality_example: Int!\n map_index_example: Int\n array_contains_example: Boolean!\n array_distinct_example: [String]!\n array_prepend_example: [String]!\n array_slice_example: [String]!\n array_concat_example: [String]!\n array_remove_example: [String]!\n array_remove_null_example: [String]!\n array_remove_null_cast_example: [String]!\n array_join_example: String!\n split_example: [String]\n sha1_example: String!\n sha256_example: String!\n the_end: String!\n}\n\n\"A JSON scalar\"\nscalar JSON\n\n\"24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.\"\nscalar LocalTime\n\n\"A 64-bit signed integer\"\nscalar Long\n\ntype Query {\n ArrayFunctions(limit: Int = 10, offset: Int = 0): [ArrayFunctions!]\n FunctionCalls(limit: Int = 10, offset: Int = 0): [FunctionCalls!]\n}\n\nenum _McpMethodType {\n NONE\n TOOL\n RESOURCE\n}\n\nenum _RestMethodType {\n NONE\n GET\n POST\n}\n\ndirective @api(mcp: _McpMethodType, rest: _RestMethodType, uri: String) on QUERY | MUTATION | FIELD_DEFINITION\n" } } } diff --git a/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/duckdb-translation.sqrl b/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/duckdb-translation.sqrl index 15b8cab7c..1d31c27e4 100644 --- a/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/duckdb-translation.sqrl +++ b/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/duckdb-translation.sqrl @@ -62,6 +62,26 @@ FunctionCalls := SELECT CAST(DATE_FORMAT(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), CAST(DATE_FORMAT(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)) AS DECIMAL(38, 2)) AS try_cast_timestampdiff_decimal_example, + CAST( + TIMESTAMPDIFF( + MONTH, + CAST(DATE_FORMAT(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), + CAST(DATE_FORMAT(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)) + AS DECIMAL(38, 2)) AS cast_timestampdiff_decimal_example, + CASE WHEN ( + CAST(10 AS DECIMAL(38, 5)) / NULLIF( + TIMESTAMPDIFF( + MONTH, + CAST(DATE_FORMAT(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), + CAST(DATE_FORMAT(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)), + 0)) IS NOT NULL + THEN CAST(10 AS DECIMAL(38, 5)) / NULLIF( + TIMESTAMPDIFF( + MONTH, + CAST(DATE_FORMAT(TIMESTAMP '2024-01-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP), + CAST(DATE_FORMAT(TIMESTAMP '2024-03-02 03:04:05', 'yyyy-MM-01') AS TIMESTAMP)), + 0) + ELSE CAST(0 AS DECIMAL(38, 5)) END AS case_timestampdiff_nullif_example, NOW() IS NOT NULL AS now_example, LOCALTIME IS NOT NULL AS local_time_example, diff --git a/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/snapshots/FunctionCallsTest.snapshot b/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/snapshots/FunctionCallsTest.snapshot index a563814f0..a6c9c4e61 100644 --- a/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/snapshots/FunctionCallsTest.snapshot +++ b/sqrl-testing/sqrl-testing-integration/src/test/resources/usecases/function-translation/duckdb/snapshots/FunctionCallsTest.snapshot @@ -42,6 +42,8 @@ "try_cast_to_timestamptz_example" : true, "try_cast_fail_example" : null, "try_cast_timestampdiff_decimal_example" : 2.0, + "cast_timestampdiff_decimal_example" : 2.0, + "case_timestampdiff_nullif_example" : 5.0, "now_example" : true, "local_time_example" : true, "local_timestamp_example" : true,