From aa466f36056d0471f0af951bde48227d652608cb Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 09:01:14 +0100 Subject: [PATCH 01/12] prune sqlglot transpiler --- src/databricks/labs/remorph/cli.py | 10 +- .../remorph_snow_transpilation_coverage.py | 4 +- src/databricks/labs/remorph/install.py | 2 +- .../labs/remorph/intermediate/root_tables.py | 30 +- src/databricks/labs/remorph/lineage.py | 5 +- .../reconcile/connectors/source_adapter.py | 5 +- .../labs/remorph/reconcile/execute.py | 2 +- .../query_builder/aggregate_query.py | 2 +- .../remorph/reconcile/query_builder/base.py | 20 +- .../query_builder/expression_generator.py | 2 +- .../reconcile/query_builder/hash_query.py | 8 +- .../reconcile/query_builder/sampling_query.py | 10 +- .../query_builder/threshold_query.py | 12 +- .../labs/remorph/reconcile/recon_capture.py | 12 +- .../labs/remorph/reconcile/schema_compare.py | 4 +- .../labs/remorph/reconcile/utils.py | 16 + .../labs/remorph/transpiler/execute.py | 40 - .../labs/remorph/transpiler/lsp/__init__.py | 0 .../transpiler/{lsp => }/lsp_engine.py | 4 + .../remorph/transpiler/sqlglot/__init__.py | 0 .../transpiler/sqlglot/dialect_utils.py | 30 - .../transpiler/sqlglot/generator/__init__.py | 0 .../sqlglot/generator/databricks.py | 771 ------------------ .../remorph/transpiler/sqlglot/lca_utils.py | 138 ---- .../transpiler/sqlglot/local_expression.py | 197 ----- .../transpiler/sqlglot/parsers/__init__.py | 0 .../transpiler/sqlglot/parsers/oracle.py | 23 - .../transpiler/sqlglot/parsers/presto.py | 202 ----- .../transpiler/sqlglot/parsers/snowflake.py | 535 ------------ .../transpiler/sqlglot/sqlglot_engine.py | 199 ----- .../remorph/transpiler/transpile_engine.py | 17 - .../reconcile/query_builder/test_execute.py | 2 +- .../query_builder/test_sampling_query.py | 2 +- .../test_aggregates_recon_capture.py | 2 +- .../reconcile/test_aggregates_reconcile.py | 2 +- .../reconcile/test_recon_capture.py | 2 +- .../reconcile/test_schema_compare.py | 2 +- .../test_long_datatype_1.sql | 6 - .../test_any_keys_match_1.sql | 15 - .../test_any_keys_match_2.sql | 25 - .../test_approx_percentile_1.sql | 6 - .../test_approx_percentile_2.sql | 6 - .../test_approx_percentile_3.sql | 6 - .../test_approx_percentile_4.sql | 6 - .../test_approx_percentile_6.sql | 7 - .../test_approx_percentile_8.sql | 7 - .../test_array_average_1.sql | 40 - .../test_cast_as_json/test_cast_as_json_1.sql | 6 - .../test_format_datetime_1.sql | 13 - .../functional/presto/test_if/test_if_1.sql | 6 - .../functional/presto/test_if/test_if_2.sql | 6 - .../test_json_extract/test_json_extract_1.sql | 16 - .../test_json_size/test_json_size_1.sql | 76 -- .../test_nested_json_with_cast_1.sql | 6 - .../presto/test_strpos/test_strpos_1.sql | 6 - .../presto/test_strpos/test_strpos_2.sql | 6 - .../presto/test_unnest/test_unnest_1.sql | 17 - .../presto/test_unnest/test_unnest_2.sql | 31 - .../test_approx_percentile_5.sql | 6 - .../test_approx_percentile_7.sql | 6 - .../snowflake/aggregates/least_1.sql | 6 - .../aggregates/listagg/test_listagg_1.sql | 10 - .../aggregates/listagg/test_listagg_2.sql | 8 - .../aggregates/listagg/test_listagg_3.sql | 11 - .../aggregates/listagg/test_listagg_4.sql | 28 - .../aggregates/test_booland_agg_1.sql | 6 - .../aggregates/test_booland_agg_2.sql | 6 - .../snowflake/aggregates/test_count_1.sql | 6 - .../snowflake/aggregates/test_count_if_1.sql | 6 - .../aggregates/test_dense_rank_1.sql | 19 - .../aggregates/test_dense_rank_2.sql | 21 - .../snowflake/aggregates/test_greatest_1.sql | 6 - .../snowflake/arrays/array_flatten_1.sql | 11 - .../snowflake/arrays/test_array_append_1.sql | 6 - .../snowflake/arrays/test_array_cat_1.sql | 6 - .../snowflake/arrays/test_array_cat_2.sql | 6 - .../snowflake/arrays/test_array_compact_1.sql | 6 - .../arrays/test_array_construct_1.sql | 32 - .../arrays/test_array_construct_2.sql | 40 - .../arrays/test_array_construct_compact_1.sql | 6 - .../arrays/test_array_construct_compact_2.sql | 6 - .../arrays/test_array_contains_1.sql | 6 - .../arrays/test_array_distinct_1.sql | 6 - .../snowflake/arrays/test_array_except_1.sql | 6 - .../arrays/test_array_intersection_1.sql | 6 - .../arrays/test_array_intersection_2.sql | 6 - .../arrays/test_array_position_1.sql | 6 - .../snowflake/arrays/test_array_prepend_1.sql | 6 - .../snowflake/arrays/test_array_remove_1.sql | 6 - .../snowflake/arrays/test_array_size_1.sql | 6 - .../snowflake/arrays/test_array_slice_1.sql | 6 - .../snowflake/arrays/test_array_slice_2.sql | 6 - .../arrays/test_array_to_string_1.sql | 6 - .../snowflake/arrays/test_arrayagg_1.sql | 5 - .../snowflake/arrays/test_arrayagg_2.sql | 11 - .../snowflake/arrays/test_arrayagg_3.sql | 12 - .../snowflake/arrays/test_arrayagg_4.sql | 30 - .../snowflake/arrays/test_arrayagg_5.sql | 30 - .../snowflake/arrays/test_arrayagg_6.sql | 7 - .../snowflake/arrays/test_arrayagg_7.sql | 38 - .../snowflake/arrays/test_arrayagg_8.sql | 32 - .../snowflake/arrays/test_arrayagg_9.sql | 32 - .../arrays/test_arrays_overlap_1.sql | 6 - .../snowflake/arrays/test_concat_ws_1.sql | 6 - .../snowflake/arrays/test_extract_1.sql | 6 - .../snowflake/arrays/test_flatten_1.sql | 6 - .../snowflake/arrays/test_get_1.sql | 6 - .../snowflake/cast/test_cast_date.sql | 7 - .../snowflake/cast/test_cast_decimal.sql | 13 - .../snowflake/cast/test_cast_double.sql | 17 - .../snowflake/cast/test_cast_int.sql | 17 - .../snowflake/cast/test_cast_strings.sql | 15 - .../snowflake/cast/test_cast_timestamp.sql | 15 - .../snowflake/cast/test_colon_cast.sql | 7 - .../snowflake/cast/test_typecasts.sql | 13 - .../core_engine/aggregates/last_value_1.sql | 20 - .../core_engine/aggregates/last_value_2.sql | 33 - .../core_engine/aggregates/last_value_3.sql | 11 - .../aggregates/test_first_value_1.sql | 11 - .../aggregates/test_first_value_2.sql | 20 - .../aggregates/test_first_value_3.sql | 35 - .../functions/conversion/test_to_time_1.sql | 6 - .../functions/conversion/test_to_time_2.sql | 6 - .../conversion/test_try_to_date_1.sql | 6 - .../conversion/test_try_to_date_3.sql | 7 - .../functions/conversion/to_timestamp_1.sql | 30 - .../to_timestamp_variable_format.sql | 179 ---- .../functions/dates/test_date_trunc_2.sql | 6 - .../functions/dates/test_date_trunc_3.sql | 6 - .../functions/dates/test_dayname_1.sql | 5 - .../functions/dates/test_monthname_1.sql | 6 - .../functions/strings/regexp_substr_3.sql | 7 - .../functions/strings/regexp_substr_4.sql | 7 - .../functions/strings/regexp_substr_5.sql | 7 - .../functions/strings/regexp_substr_6.sql | 22 - .../functions/strings/regexp_substr_7.sql | 7 - .../core_engine/lca/lca_function.sql | 12 - .../core_engine/lca/lca_homonym.sql.saved | 28 - .../snowflake/core_engine/sample.sql | 5 - .../core_engine/set-operations/except.sql | 14 - .../core_engine/set-operations/intersect.sql | 14 - .../core_engine/set-operations/minus.sql | 14 - .../core_engine/set-operations/precedence.sql | 119 --- .../core_engine/set-operations/union-all.sql | 14 - .../core_engine/set-operations/union.sql | 14 - .../set-operations/union_all_left_grouped.sql | 10 - .../set-operations/union_left_grouped.sql | 10 - .../test_command/test_command_1.sql | 10 - .../test_cte/cte_set_operation_precedence.sql | 17 - .../core_engine/test_cte/cte_simple.sql | 16 - .../core_engine/test_cte/multiple_cte.sql | 19 - .../test_cte/nested_set_operation.sql | 19 - .../test_invalid_syntax/syntax_error_1.sql | 30 - .../test_invalid_syntax/syntax_error_2.sql | 11 - .../test_invalid_syntax/syntax_error_3.sql | 19 - .../test_skip_unsupported_operations_1.sql | 10 - .../test_skip_unsupported_operations_5.sql | 10 - .../test_skip_unsupported_operations_6.sql | 10 - .../snowflake/cte/cte_with_column_list.sql | 11 - .../functional/snowflake/cte/simple_cte.sql | 11 - .../snowflake/ddl/alter/test_alter_1.sql | 5 - .../snowflake/ddl/alter/test_alter_2.sql | 5 - .../lateral_struct/test_lateral_struct_1.sql | 17 - .../lateral_struct/test_lateral_struct_10.sql | 19 - .../lateral_struct/test_lateral_struct_11.sql | 16 - .../lateral_struct/test_lateral_struct_12.sql | 19 - .../lateral_struct/test_lateral_struct_2.sql | 25 - .../lateral_struct/test_lateral_struct_3.sql | 35 - .../lateral_struct/test_lateral_struct_4.sql | 23 - .../lateral_struct/test_lateral_struct_5.sql | 23 - .../lateral_struct/test_lateral_struct_6.sql | 5 - .../lateral_struct/test_lateral_struct_7.sql | 18 - .../lateral_struct/test_lateral_struct_8.sql | 12 - .../lateral_struct/test_lateral_struct_9.sql | 44 - .../test_object_construct_1.sql | 6 - .../test_object_construct_2.sql | 6 - .../test_object_construct_3.sql | 6 - .../test_object_construct_4.sql | 5 - .../snowflake/ddl/test_cras_simple.sql | 5 - .../snowflake/ddl/test_create_ddl_1.sql | 22 - .../snowflake/ddl/test_create_ddl_2.sql | 13 - .../ddl/test_create_ddl_identity.sql | 20 - .../snowflake/ddl/test_ctas_complex.sql | 39 - .../snowflake/ddl/test_ctas_simple.sql | 5 - .../snowflake/ddl/test_current_database_1.sql | 6 - .../snowflake/dml/insert/test_insert_1.sql | 5 - .../snowflake/dml/insert/test_insert_2.sql | 8 - .../snowflake/dml/insert/test_insert_3.sql | 17 - .../dml/insert/test_insert_overwrite_1.sql | 8 - .../functional/snowflake/dml/test_delete.sql | 6 - .../snowflake/dml/test_delete_subquery.sql | 13 - .../snowflake/dml/test_delete_using.sql | 6 - .../snowflake/dml/test_delete_using_where.sql | 5 - .../snowflake/dml/test_delete_where.sql | 5 - .../dml/update/test_update_from_dml_1.sql | 10 - .../dml/update/test_update_from_dml_2.sql | 18 - .../dml/update/test_update_from_dml_3.sql | 16 - .../functions/conversion/is_integer_1.sql | 11 - .../test_to_number/test_to_number_1.sql | 6 - .../test_to_number/test_to_number_2.sql | 6 - .../test_to_number/test_to_number_3.sql | 6 - .../test_to_number/test_to_number_4.sql | 8 - .../test_to_number/test_to_number_5.sql | 6 - .../test_to_number/test_to_number_6.sql | 6 - .../test_to_number/test_to_number_7.sql | 8 - .../test_to_number/test_to_number_8.sql | 6 - .../test_to_number/test_to_number_9.sql | 6 - .../test_try_cast/test_try_cast_1.sql | 6 - .../test_try_cast/test_try_cast_2.sql | 6 - .../test_try_to_date/test_try_to_date_2.sql | 6 - .../test_try_to_number_1.sql | 6 - .../test_try_to_number_2.sql | 6 - .../test_try_to_number_3.sql | 6 - .../test_try_to_number_4.sql | 8 - .../test_try_to_number_5.sql | 6 - .../test_try_to_number_6.sql | 6 - .../test_try_to_number_7.sql | 8 - .../test_try_to_number_8.sql | 12 - .../test_try_to_timestamp_1.sql | 6 - .../test_try_to_timestamp_2.sql | 6 - .../functions/conversion/to_array_1.sql | 6 - .../functions/conversion/to_array_2.sql | 6 - .../to_boolean/test_to_boolean_1.sql | 24 - .../to_boolean/test_try_to_boolean_1.sql | 23 - .../functions/conversion/to_double_1.sql | 6 - .../functions/conversion/to_json_1.sql | 6 - .../functions/conversion/to_object_1.sql | 6 - .../functions/conversion/to_rlike_1.sql | 6 - .../functions/conversion/to_variant_1.sql | 6 - .../functions/conversion/tochar_1.sql | 7 - .../functions/conversion/zeroifnull_1.sql | 6 - .../dates/datediff/test_datediff_1.sql | 10 - .../dates/datediff/test_datediff_10.sql | 6 - .../dates/datediff/test_datediff_11.sql | 6 - .../dates/datediff/test_datediff_2.sql | 10 - .../dates/datediff/test_datediff_3.sql | 6 - .../dates/datediff/test_datediff_4.sql | 6 - .../dates/datediff/test_datediff_5.sql | 6 - .../dates/datediff/test_datediff_6.sql | 6 - .../dates/datediff/test_datediff_7.sql | 6 - .../dates/datediff/test_datediff_8.sql | 6 - .../dates/datediff/test_datediff_9.sql | 6 - .../dates/dayname/test_dayname_2.sql | 5 - .../dates/dayname/test_dayname_3.sql | 5 - .../snowflake/functions/dates/last_day_1.sql | 6 - .../snowflake/functions/dates/last_day_2.sql | 35 - .../dates/monthname/test_monthname_2.sql | 5 - .../dates/monthname/test_monthname_3.sql | 5 - .../dates/monthname/test_monthname_4.sql | 5 - .../dates/monthname/test_monthname_5.sql | 5 - .../dates/monthname/test_monthname_6.sql | 5 - .../dates/monthname/test_monthname_7.sql | 5 - .../snowflake/functions/dates/next_day_1.sql | 6 - .../functions/dates/test_add_months_1.sql | 6 - .../dates/test_convert_timezone_1.sql | 8 - .../dates/test_convert_timezone_2.sql | 7 - .../dates/test_convert_timezone_3.sql | 6 - .../dates/test_convert_timezone_4.sql | 12 - .../dates/test_convert_timezone_5.sql | 7 - .../dates/test_current_timestamp_1.sql | 6 - .../dates/test_date_from_parts_1.sql | 6 - .../dates/test_date_from_parts_2.sql | 6 - .../dates/test_date_from_parts_3.sql | 6 - .../functions/dates/test_date_part_1.sql | 6 - .../functions/dates/test_date_trunc_1.sql | 6 - .../functions/dates/test_date_trunc_4.sql | 6 - .../functions/dates/test_dateadd_1.sql | 6 - .../test_timestamp_from_parts_1.sql | 6 - .../test_timestamp_from_parts_2.sql | 7 - .../test_timestampadd/test_timestampadd_1.sql | 7 - .../test_timestampadd/test_timestampadd_2.sql | 6 - .../test_timestampadd/test_timestampadd_3.sql | 6 - .../test_timestampadd/test_timestampadd_4.sql | 6 - .../test_timestampadd/test_timestampadd_5.sql | 6 - .../test_timestampdiff_1.sql | 6 - .../test_timestampdiff_2.sql | 6 - .../test_timestampdiff_3.sql | 6 - .../snowflake/functions/initcap_1.sql | 6 - .../functional/snowflake/functions/left_1.sql | 6 - .../snowflake/functions/math/ln_1.sql | 6 - .../snowflake/functions/math/log_1.sql | 6 - .../snowflake/functions/math/mod_1.sql | 6 - .../snowflake/functions/math/mode_1.sql | 6 - .../snowflake/functions/math/pi_1.sql | 6 - .../snowflake/functions/math/radians_1.sql | 6 - .../snowflake/functions/math/random_1.sql | 9 - .../snowflake/functions/math/round_1.sql | 5 - .../snowflake/functions/math/sign_1.sql | 6 - .../snowflake/functions/math/sin_1.sql | 6 - .../snowflake/functions/math/sqrt_1.sql | 6 - .../functions/math/square/test_square_1.sql | 6 - .../functions/math/square/test_square_2.sql | 6 - .../functions/math/square/test_square_3.sql | 6 - .../functions/math/square/test_square_4.sql | 6 - .../snowflake/functions/math/sum_1.sql | 6 - .../snowflake/functions/math/test_abs_1.sql | 6 - .../snowflake/functions/math/test_asin_1.sql | 6 - .../snowflake/functions/math/test_atan2_1.sql | 6 - .../snowflake/functions/math/test_ceil_1.sql | 6 - .../snowflake/functions/math/test_cos_1.sql | 6 - .../snowflake/functions/math/test_div0_1.sql | 6 - .../functions/math/test_div0null_1.sql | 6 - .../snowflake/functions/math/test_exp_1.sql | 6 - .../snowflake/functions/math/test_floor_1.sql | 6 - .../test_parse_json_extract_path_text_1.sql | 6 - .../test_parse_json_extract_path_text_2.sql | 6 - .../test_parse_json_extract_path_text_3.sql | 6 - .../parse_json/test_parse_json_1.sql | 5 - .../parse_json/test_parse_json_2.sql | 8 - .../parse_json/test_parse_json_3.sql | 33 - .../snowflake/functions/stats/median_1.sql | 6 - .../snowflake/functions/stats/nvl_1.sql | 6 - .../functions/stats/regr_intercept_1.sql | 6 - .../snowflake/functions/stats/regr_r2_1.sql | 6 - .../functions/stats/regr_slope_1.sql | 6 - .../snowflake/functions/stats/stddev_1.sql | 6 - .../functions/stats/stddev_pop_1.sql | 6 - .../functions/stats/stddev_samp_1.sql | 6 - .../stats/test_approx_percentile_1.sql | 6 - .../functions/stats/test_approx_top_k_1.sql | 6 - .../snowflake/functions/stats/test_avg_1.sql | 6 - .../snowflake/functions/stats/test_corr_1.sql | 6 - .../functions/stats/test_cume_dist_1.sql | 6 - .../snowflake/functions/strings/lower_1.sql | 6 - .../snowflake/functions/strings/lpad_1.sql | 6 - .../snowflake/functions/strings/ltrim_1.sql | 5 - .../functions/strings/parse_url_1.sql | 6 - .../functions/strings/regexp_count_1.sql | 6 - .../functions/strings/regexp_instr_1.sql | 6 - .../functions/strings/regexp_like_1.sql | 6 - .../functions/strings/regexp_replace_1.sql | 6 - .../functions/strings/regexp_substr_1.sql | 6 - .../functions/strings/regexp_substr_2.sql | 10 - .../snowflake/functions/strings/repeat_1.sql | 6 - .../snowflake/functions/strings/replace_1.sql | 6 - .../snowflake/functions/strings/reverse_1.sql | 6 - .../snowflake/functions/strings/right_1.sql | 6 - .../snowflake/functions/strings/rpad_1.sql | 6 - .../snowflake/functions/strings/rtrim_1.sql | 5 - .../strings/split_part/test_split_part_1.sql | 6 - .../strings/split_part/test_split_part_2.sql | 6 - .../strings/split_part/test_split_part_3.sql | 6 - .../strings/split_part/test_split_part_4.sql | 6 - .../strings/split_part/test_split_part_5.sql | 6 - .../strings/split_part/test_split_part_6.sql | 6 - .../functions/strings/startswith_1.sql | 6 - .../strings/strtok/test_strtok_1.sql | 6 - .../strings/strtok/test_strtok_2.sql | 6 - .../strings/strtok/test_strtok_3.sql | 7 - .../strings/test_base64_decode_1.sql | 6 - .../strings/test_base64_encode_1.sql | 6 - .../functions/strings/test_charindex_1.sql | 7 - .../functions/strings/test_collate_1.sql | 6 - .../functions/strings/test_collate_2.sql | 6 - .../functions/strings/test_decode_1.sql | 6 - .../functions/strings/test_editdistance.sql | 5 - .../functions/strings/test_endswith_1.sql | 6 - .../snowflake/functions/strings/trim_1.sql | 6 - .../snowflake/functions/strings/trunc_1.sql | 6 - .../snowflake/functions/strings/upper_1.sql | 6 - .../snowflake/functions/struct_1.sql | 8 - .../snowflake/functions/sysdate_1.sql | 6 - .../functional/snowflake/functions/tan_1.sql | 6 - .../functions/test_nvl2/test_nvl2_1.sql | 6 - .../functions/test_nvl2/test_nvl2_2.sql | 6 - .../test_object_keys/test_object_keys_1.sql | 10 - .../test_object_keys/test_object_keys_2.sql | 11 - .../test_strtok_to_array_1.sql | 6 - .../test_strtok_to_array_2.sql | 6 - .../test_strtok_to_array_3.sql | 6 - .../functions/test_uuid_string_1.sql | 5 - .../snowflake/functions/tovarchar_1.sql | 7 - .../snowflake/functions/translate_1.sql | 6 - .../snowflake/functions/typeof_1.sql | 6 - .../snowflake/functions/window/lag_1.sql | 19 - .../snowflake/functions/window/lag_2.sql | 21 - .../snowflake/functions/window/lead_1.sql | 19 - .../snowflake/functions/window/lead_2.sql | 21 - .../functions/window/nth_value_1.sql | 11 - .../functions/window/nth_value_2.sql | 20 - .../functions/window/nth_value_3.sql | 35 - .../snowflake/functions/window/ntile_1.sql | 20 - .../snowflake/functions/window/ntile_2.sql | 21 - .../functions/window/percent_rank_1.sql | 6 - .../functions/window/percentile_cont_1.sql | 6 - .../functions/window/percentile_disc_1.sql | 6 - .../snowflake/functions/window/position_1.sql | 6 - .../snowflake/functions/window/rank_1.sql | 19 - .../snowflake/functions/window/rank_2.sql | 21 - .../functions/window/row_number_1.sql | 25 - .../functions/window/row_number_2.sql | 27 - .../snowflake/joins/test_join_1.sql | 6 - .../snowflake/joins/test_join_2.sql | 6 - .../functional/snowflake/lca/lca_cte.sql | 11 - .../functional/snowflake/lca/lca_derived.sql | 8 - .../functional/snowflake/lca/lca_in.sql | 5 - .../functional/snowflake/lca/lca_nested.sql | 13 - .../functional/snowflake/lca/lca_subquery.sql | 8 - .../functional/snowflake/lca/lca_where.sql | 5 - .../functional/snowflake/lca/lca_window.sql | 15 - .../snowflake/misc/test_any_value_1.sql | 6 - .../snowflake/misc/test_coalesce_1.sql | 6 - .../snowflake/misc/test_contains_1.sql | 6 - .../snowflake/misc/test_equal_null_1.sql | 6 - .../functional/snowflake/misc/test_hash_1.sql | 6 - .../functional/snowflake/misc/test_iff_1.sql | 6 - .../snowflake/misc/test_ifnull_1.sql | 6 - .../snowflake/misc/test_ifnull_2.sql | 6 - .../functional/snowflake/misc/test_sha2_1.sql | 9 - .../snowflake/nested_query_with_json_1.sql | 32 - .../snowflake/nulls/test_nullif_1.sql | 6 - .../snowflake/nulls/test_nullifzero_1.sql | 6 - .../snowflake/nulls/test_nullsafe_eq_1.sql | 14 - .../snowflake/operators/test_bitor_agg_1.sql | 6 - .../snowflake/operators/test_bitor_agg_2.sql | 6 - .../sqlglot-incorrect/test_current_date_1.sql | 5 - .../sqlglot-incorrect/test_uuid_string_2.sql | 6 - .../tablesample/test_tablesample_1.sql | 7 - .../tablesample/test_tablesample_2.sql | 7 - .../tablesample/test_tablesample_3.sql | 14 - .../snowflake/test_command/test_command_2.sql | 6 - .../snowflake/test_command/test_command_3.sql | 9 - .../test_skip_unsupported_operations_10.sql | 6 - .../test_skip_unsupported_operations_11.sql | 48 -- .../test_skip_unsupported_operations_2.sql | 5 - .../test_skip_unsupported_operations_3.sql | 5 - .../test_skip_unsupported_operations_4.sql | 5 - .../test_skip_unsupported_operations_7.sql | 6 - .../test_skip_unsupported_operations_8.sql | 6 - .../test_skip_unsupported_operations_9.sql | 13 - .../test_tokens_parameter_1.sql | 5 - .../test_tokens_parameter_2.sql | 5 - .../test_tokens_parameter_3.sql | 5 - .../test_tokens_parameter_4.sql | 11 - .../test_approx_percentile_2.sql | 6 - .../test_array_contains_2.sql | 6 - .../test_array_slice_3.sql | 6 - .../test_date_part_2.sql | 6 - .../test_date_trunc_5.sql | 6 - .../test_dayname_4.sql | 6 - .../test_extract_2.sql | 6 - .../test_iff_2.sql | 6 - .../test_left_2.sql | 6 - .../test_monthname_8.sql | 6 - .../test_monthname_9.sql | 6 - .../test_nullif_2.sql | 6 - .../test_nvl2_3.sql | 6 - .../test_parse_json_extract_path_text_4.sql | 6 - .../test_position_2.sql | 6 - .../test_regexp_like_2.sql | 6 - .../test_regexp_replace_2.sql | 6 - .../test_regexp_substr_2.sql | 6 - .../test_repeat_2.sql | 6 - .../test_right_2.sql | 6 - .../test_split_part_7.sql | 6 - .../test_split_part_8.sql | 6 - .../test_startswith_2.sql | 6 - .../test_timestampadd_6.sql | 6 - .../test_to_number_10.sql | 6 - .../test_trunc_2.sql | 6 - .../test_try_cast_3.sql | 6 - .../core_engine/dbt/nofmt_twisted_input.sql | 27 - .../test_invalid_syntax/syntax_error_1.sql | 19 - .../test_invalid_syntax/syntax_error_2.sql | 11 - .../test_invalid_syntax/syntax_error_3.sql | 23 - .../tsql/cte/cte_set_operation_precedence.sql | 17 - .../tsql/cte/cte_with_column_list.sql | 11 - .../functional/tsql/cte/multiple_cte.sql | 19 - .../tsql/cte/nested_set_operation.sql | 19 - .../functional/tsql/cte/simple_cte.sql | 11 - .../tsql/functions/test_aadbts_1.sql | 9 - .../tsql/functions/test_aalangid1.sql | 9 - .../tsql/functions/test_aalanguage_1.sql | 9 - .../tsql/functions/test_aalock_timeout_1.sql | 9 - .../functions/test_aamax_connections_1.sql | 9 - .../tsql/functions/test_aamax_precision_1.sql | 9 - .../tsql/functions/test_aaoptions_1.sql | 9 - .../tsql/functions/test_aaremserver_1.sql | 9 - .../tsql/functions/test_aaservername_1.sql | 9 - .../tsql/functions/test_aaservicename_1.sql | 9 - .../tsql/functions/test_aaspid_1.sql | 9 - .../tsql/functions/test_aatextsize_1.sql | 9 - .../tsql/functions/test_aaversion_1.sql | 9 - .../functional/tsql/functions/test_abs_1.sql | 9 - .../functions/test_approx_count_distinct.sql | 11 - .../test_approx_percentile_cont_1.sql | 12 - .../test_approx_percentile_disc_1.sql | 10 - .../functional/tsql/functions/test_avg_1.sql | 9 - .../functional/tsql/functions/test_avg_2.sql | 9 - .../functional/tsql/functions/test_avg_3.sql | 11 - .../functional/tsql/functions/test_avg_4.sql | 9 - .../functional/tsql/functions/test_avg_5.sql | 11 - .../tsql/functions/test_bit_count_1.sql | 9 - .../tsql/functions/test_checksum_agg_1.sql | 10 - .../functions/test_collationproperty_1.sql | 10 - .../tsql/functions/test_count_1.sql | 9 - .../tsql/functions/test_count_2.sql | 9 - .../tsql/functions/test_cume_dist_1.sql | 9 - .../tsql/functions/test_dateadd_day_1.sql | 10 - .../tsql/functions/test_dateadd_day_2.sql | 10 - .../tsql/functions/test_dateadd_day_3.sql | 10 - .../functions/test_dateadd_dayofyear_1.sql | 10 - .../functions/test_dateadd_dayofyear_2.sql | 10 - .../functions/test_dateadd_dayofyear_3.sql | 10 - .../tsql/functions/test_dateadd_hour_1.sql | 10 - .../tsql/functions/test_dateadd_hour_2.sql | 10 - .../functions/test_dateadd_microsecond_1.sql | 10 - .../functions/test_dateadd_microsecond_2.sql | 10 - .../functions/test_dateadd_millisecond_1.sql | 10 - .../functions/test_dateadd_millisecond_2.sql | 10 - .../tsql/functions/test_dateadd_minute_1.sql | 10 - .../tsql/functions/test_dateadd_minute_2.sql | 10 - .../tsql/functions/test_dateadd_minute_3.sql | 10 - .../tsql/functions/test_dateadd_month_1.sql | 11 - .../tsql/functions/test_dateadd_month_2.sql | 11 - .../tsql/functions/test_dateadd_month_3.sql | 11 - .../functions/test_dateadd_nanosecond_1.sql | 10 - .../functions/test_dateadd_nanosecond_2.sql | 10 - .../tsql/functions/test_dateadd_quarter_1.sql | 10 - .../tsql/functions/test_dateadd_quarter_2.sql | 10 - .../tsql/functions/test_dateadd_quarter_3.sql | 10 - .../tsql/functions/test_dateadd_second_1.sql | 10 - .../tsql/functions/test_dateadd_second_2.sql | 10 - .../tsql/functions/test_dateadd_second_3.sql | 10 - .../tsql/functions/test_dateadd_week_1.sql | 10 - .../tsql/functions/test_dateadd_week_2.sql | 10 - .../tsql/functions/test_dateadd_week_3.sql | 10 - .../tsql/functions/test_dateadd_weekday_1.sql | 10 - .../tsql/functions/test_dateadd_weekday_2.sql | 10 - .../tsql/functions/test_dateadd_weekday_3.sql | 10 - .../tsql/functions/test_dateadd_year_1.sql | 11 - .../tsql/functions/test_dateadd_year_2.sql | 11 - .../tsql/functions/test_dateadd_year_3.sql | 11 - .../tsql/functions/test_first_value_1.sql | 9 - .../tsql/functions/test_first_value_2.sql | 9 - .../tsql/functions/test_first_value_3.sql | 9 - .../tsql/functions/test_first_value_4.sql | 9 - .../tsql/functions/test_get_bit_1.sql | 10 - .../tsql/functions/test_grouping_1.sql | 15 - .../tsql/functions/test_grouping_id_1.sql | 9 - .../tsql/functions/test_grouping_id_2.sql | 9 - .../tsql/functions/test_isnull_1.sql | 13 - .../functional/tsql/functions/test_lag_1.sql | 9 - .../functional/tsql/functions/test_lag_2.sql | 9 - .../tsql/functions/test_last_value_1.sql | 9 - .../tsql/functions/test_last_value_2.sql | 9 - .../tsql/functions/test_last_value_3.sql | 9 - .../tsql/functions/test_last_value_4.sql | 10 - .../functional/tsql/functions/test_lead_1.sql | 9 - .../functional/tsql/functions/test_lead_2.sql | 9 - .../tsql/functions/test_left_shift_1.sql | 9 - .../functional/tsql/functions/test_max.2.sql | 10 - .../functional/tsql/functions/test_max_1.sql | 9 - .../functional/tsql/functions/test_min.1.sql | 9 - .../functional/tsql/functions/test_min.2.sql | 10 - .../tsql/functions/test_nestlevel_1.sql | 9 - .../tsql/functions/test_percent_rank_1.sql | 9 - .../tsql/functions/test_percentile_cont_1.sql | 12 - .../tsql/functions/test_percentile_disc_1.sql | 10 - .../tsql/functions/test_right_shift_1.sql | 9 - .../tsql/functions/test_set_bit_1.sql | 9 - .../tsql/functions/test_set_bit_2.sql | 9 - .../tsql/functions/test_stdev_1.sql | 9 - .../tsql/functions/test_stdev_2.sql | 9 - .../tsql/functions/test_stdevp_1.sql | 9 - .../tsql/functions/test_stdevp_2.sql | 9 - .../functional/tsql/functions/test_sum_1.sql | 9 - .../functional/tsql/functions/test_sum_2.sql | 9 - .../functional/tsql/functions/test_var_1.sql | 9 - .../functional/tsql/functions/test_var_2.sql | 10 - .../functional/tsql/functions/test_varp_1.sql | 9 - .../functional/tsql/functions/test_varp_2.sql | 10 - .../functional/tsql/select/limit.sql | 47 -- .../functional/tsql/select/order_by.sql | 11 - .../functional/tsql/select/order_by_asc.sql | 11 - .../functional/tsql/select/order_by_desc.sql | 11 - .../tsql/select/order_by_offset.sql | 15 - .../tsql/select/order_by_precedence.sql | 17 - .../functional/tsql/select/test_cte_1.sql | 10 - .../functional/tsql/select/test_cte_2.sql | 37 - .../functional/tsql/select/test_cte_xml.sql | 15 - .../functional/tsql/set-operations/except.sql | 14 - .../tsql/set-operations/intersect.sql | 14 - .../tsql/set-operations/precedence.sql | 78 -- .../tsql/set-operations/union-all.sql | 14 - .../functional/tsql/set-operations/union.sql | 14 - .../set-operations/union_all_left_grouped.sql | 10 - .../set-operations/union_left_grouped.sql | 10 - ...pile_errors_2025_02_18_08_59_22_117905.lst | 1 + ...pile_errors_2025_02_18_09_00_07_485225.lst | 1 + tests/unit/conftest.py | 178 ---- tests/unit/coverage/test_coverage_utils.py | 3 +- tests/unit/intermediate/test_root_tables.py | 5 +- .../reconcile/connectors/test_databricks.py | 2 +- .../unit/reconcile/connectors/test_oracle.py | 2 +- .../reconcile/connectors/test_snowflake.py | 2 +- .../reconcile/connectors/test_sql_server.py | 2 +- .../query_builder/test_count_query.py | 2 +- .../test_expression_generator.py | 2 +- .../query_builder/test_hash_query.py | 2 +- .../query_builder/test_threshold_query.py | 2 +- tests/unit/reconcile/test_source_adapter.py | 2 +- tests/unit/transpiler/test_databricks.py | 15 - .../test_databricks_expected_exceptions.py | 22 - tests/unit/transpiler/test_execute.py | 90 +- tests/unit/transpiler/test_lca_utils.py | 316 ------- tests/unit/transpiler/test_lsp_config.py | 2 +- tests/unit/transpiler/test_lsp_engine.py | 2 +- tests/unit/transpiler/test_oracle.py | 15 - tests/unit/transpiler/test_presto.py | 15 - .../test_presto_expected_exceptions.py | 22 - tests/unit/transpiler/test_snow.py | 71 -- tests/unit/transpiler/test_sqlglot_engine.py | 149 ---- 613 files changed, 128 insertions(+), 9010 deletions(-) create mode 100644 src/databricks/labs/remorph/reconcile/utils.py delete mode 100644 src/databricks/labs/remorph/transpiler/lsp/__init__.py rename src/databricks/labs/remorph/transpiler/{lsp => }/lsp_engine.py (98%) delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/__init__.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/dialect_utils.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/generator/__init__.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/generator/databricks.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/lca_utils.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/local_expression.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/parsers/__init__.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/parsers/oracle.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/parsers/presto.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/parsers/snowflake.py delete mode 100644 src/databricks/labs/remorph/transpiler/sqlglot/sqlglot_engine.py delete mode 100644 tests/resources/functional/oracle/test_long_datatype/test_long_datatype_1.sql delete mode 100644 tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_1.sql delete mode 100644 tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_2.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_1.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_2.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_3.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_4.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_6.sql delete mode 100644 tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_8.sql delete mode 100644 tests/resources/functional/presto/test_array_average/test_array_average_1.sql delete mode 100644 tests/resources/functional/presto/test_cast_as_json/test_cast_as_json_1.sql delete mode 100644 tests/resources/functional/presto/test_format_datetime/test_format_datetime_1.sql delete mode 100644 tests/resources/functional/presto/test_if/test_if_1.sql delete mode 100644 tests/resources/functional/presto/test_if/test_if_2.sql delete mode 100644 tests/resources/functional/presto/test_json_extract/test_json_extract_1.sql delete mode 100644 tests/resources/functional/presto/test_json_size/test_json_size_1.sql delete mode 100644 tests/resources/functional/presto/test_nested_json_with_cast/test_nested_json_with_cast_1.sql delete mode 100644 tests/resources/functional/presto/test_strpos/test_strpos_1.sql delete mode 100644 tests/resources/functional/presto/test_strpos/test_strpos_2.sql delete mode 100644 tests/resources/functional/presto/test_unnest/test_unnest_1.sql delete mode 100644 tests/resources/functional/presto/test_unnest/test_unnest_2.sql delete mode 100644 tests/resources/functional/presto_expected_exceptions/test_approx_percentile_5.sql delete mode 100644 tests/resources/functional/presto_expected_exceptions/test_approx_percentile_7.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/least_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/listagg/test_listagg_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/listagg/test_listagg_2.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/listagg/test_listagg_3.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/listagg/test_listagg_4.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_booland_agg_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_booland_agg_2.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_count_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_count_if_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_dense_rank_1.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_dense_rank_2.sql delete mode 100644 tests/resources/functional/snowflake/aggregates/test_greatest_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/array_flatten_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_append_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_cat_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_cat_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_compact_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_construct_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_construct_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_construct_compact_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_construct_compact_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_contains_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_distinct_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_except_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_intersection_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_intersection_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_position_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_prepend_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_remove_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_size_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_slice_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_slice_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_array_to_string_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_2.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_3.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_4.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_5.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_6.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_7.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_8.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrayagg_9.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_arrays_overlap_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_concat_ws_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_extract_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_flatten_1.sql delete mode 100644 tests/resources/functional/snowflake/arrays/test_get_1.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_date.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_decimal.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_double.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_int.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_strings.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_cast_timestamp.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_colon_cast.sql delete mode 100644 tests/resources/functional/snowflake/cast/test_typecasts.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/last_value_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/last_value_2.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/last_value_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_2.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_2.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_variable_format.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_2.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/dates/test_dayname_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/dates/test_monthname_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_4.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_5.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_6.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_7.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/lca/lca_function.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/lca/lca_homonym.sql.saved delete mode 100644 tests/resources/functional/snowflake/core_engine/sample.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/except.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/intersect.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/minus.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/precedence.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/union-all.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/union.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/union_all_left_grouped.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/set-operations/union_left_grouped.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_command/test_command_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/cte_set_operation_precedence.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/multiple_cte.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_cte/nested_set_operation.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_2.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_3.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_1.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_5.sql delete mode 100644 tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_6.sql delete mode 100644 tests/resources/functional/snowflake/cte/cte_with_column_list.sql delete mode 100644 tests/resources/functional/snowflake/cte/simple_cte.sql delete mode 100644 tests/resources/functional/snowflake/ddl/alter/test_alter_1.sql delete mode 100644 tests/resources/functional/snowflake/ddl/alter/test_alter_2.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_1.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_10.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_11.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_12.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_2.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_3.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_4.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_5.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_6.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_7.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_8.sql delete mode 100644 tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_9.sql delete mode 100644 tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_1.sql delete mode 100644 tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_2.sql delete mode 100644 tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_3.sql delete mode 100644 tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_4.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_cras_simple.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_create_ddl_1.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_create_ddl_2.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_create_ddl_identity.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_ctas_complex.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_ctas_simple.sql delete mode 100644 tests/resources/functional/snowflake/ddl/test_current_database_1.sql delete mode 100644 tests/resources/functional/snowflake/dml/insert/test_insert_1.sql delete mode 100644 tests/resources/functional/snowflake/dml/insert/test_insert_2.sql delete mode 100644 tests/resources/functional/snowflake/dml/insert/test_insert_3.sql delete mode 100644 tests/resources/functional/snowflake/dml/insert/test_insert_overwrite_1.sql delete mode 100644 tests/resources/functional/snowflake/dml/test_delete.sql delete mode 100644 tests/resources/functional/snowflake/dml/test_delete_subquery.sql delete mode 100644 tests/resources/functional/snowflake/dml/test_delete_using.sql delete mode 100644 tests/resources/functional/snowflake/dml/test_delete_using_where.sql delete mode 100644 tests/resources/functional/snowflake/dml/test_delete_where.sql delete mode 100644 tests/resources/functional/snowflake/dml/update/test_update_from_dml_1.sql delete mode 100644 tests/resources/functional/snowflake/dml/update/test_update_from_dml_2.sql delete mode 100644 tests/resources/functional/snowflake/dml/update/test_update_from_dml_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/is_integer_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_6.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_7.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_8.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_9.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_date/test_try_to_date_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_6.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_7.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_8.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_array_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_array_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_boolean/test_to_boolean_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_boolean/test_try_to_boolean_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_double_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_json_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_object_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_rlike_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/to_variant_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/tochar_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/conversion/zeroifnull_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_10.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_11.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_6.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_7.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_8.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_9.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/last_day_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/last_day_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_6.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_7.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/next_day_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_add_months_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_convert_timezone_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_convert_timezone_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_convert_timezone_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_convert_timezone_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_convert_timezone_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_current_timestamp_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_from_parts_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_from_parts_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_from_parts_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_part_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_trunc_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_date_trunc_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_dateadd_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/initcap_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/left_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/ln_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/log_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/mod_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/mode_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/pi_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/radians_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/random_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/round_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/sign_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/sin_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/sqrt_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/square/test_square_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/square/test_square_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/square/test_square_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/square/test_square_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/sum_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_abs_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_asin_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_atan2_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_ceil_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_cos_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_div0_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_div0null_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_exp_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/math/test_floor_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/test_parse_json_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/test_parse_json_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/parse_json/test_parse_json_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/median_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/nvl_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/regr_intercept_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/regr_r2_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/regr_slope_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/stddev_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/stddev_pop_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/stddev_samp_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/test_approx_percentile_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/test_approx_top_k_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/test_avg_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/test_corr_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/stats/test_cume_dist_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/lower_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/lpad_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/ltrim_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/parse_url_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_count_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_instr_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_like_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_replace_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_substr_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/regexp_substr_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/repeat_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/replace_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/reverse_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/right_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/rpad_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/rtrim_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_4.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_5.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_6.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/startswith_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_base64_decode_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_base64_encode_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_charindex_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_collate_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_collate_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_decode_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_editdistance.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/test_endswith_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/trim_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/trunc_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/strings/upper_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/struct_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/sysdate_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/tan_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/test_uuid_string_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/tovarchar_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/translate_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/typeof_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/lag_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/lag_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/lead_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/lead_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/nth_value_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/nth_value_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/nth_value_3.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/ntile_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/ntile_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/percent_rank_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/percentile_cont_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/percentile_disc_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/position_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/rank_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/rank_2.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/row_number_1.sql delete mode 100644 tests/resources/functional/snowflake/functions/window/row_number_2.sql delete mode 100644 tests/resources/functional/snowflake/joins/test_join_1.sql delete mode 100644 tests/resources/functional/snowflake/joins/test_join_2.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_cte.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_derived.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_in.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_nested.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_subquery.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_where.sql delete mode 100644 tests/resources/functional/snowflake/lca/lca_window.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_any_value_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_coalesce_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_contains_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_equal_null_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_hash_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_iff_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_ifnull_1.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_ifnull_2.sql delete mode 100644 tests/resources/functional/snowflake/misc/test_sha2_1.sql delete mode 100644 tests/resources/functional/snowflake/nested_query_with_json_1.sql delete mode 100644 tests/resources/functional/snowflake/nulls/test_nullif_1.sql delete mode 100644 tests/resources/functional/snowflake/nulls/test_nullifzero_1.sql delete mode 100644 tests/resources/functional/snowflake/nulls/test_nullsafe_eq_1.sql delete mode 100644 tests/resources/functional/snowflake/operators/test_bitor_agg_1.sql delete mode 100644 tests/resources/functional/snowflake/operators/test_bitor_agg_2.sql delete mode 100644 tests/resources/functional/snowflake/sqlglot-incorrect/test_current_date_1.sql delete mode 100644 tests/resources/functional/snowflake/sqlglot-incorrect/test_uuid_string_2.sql delete mode 100644 tests/resources/functional/snowflake/tablesample/test_tablesample_1.sql delete mode 100644 tests/resources/functional/snowflake/tablesample/test_tablesample_2.sql delete mode 100644 tests/resources/functional/snowflake/tablesample/test_tablesample_3.sql delete mode 100644 tests/resources/functional/snowflake/test_command/test_command_2.sql delete mode 100644 tests/resources/functional/snowflake/test_command/test_command_3.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_10.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_11.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_2.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_3.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_4.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_7.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_8.sql delete mode 100644 tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_9.sql delete mode 100644 tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_1.sql delete mode 100644 tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_2.sql delete mode 100644 tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_3.sql delete mode 100644 tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_4.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_approx_percentile_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_array_contains_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_array_slice_3.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_date_part_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_date_trunc_5.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_dayname_4.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_extract_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_iff_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_left_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_monthname_8.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_monthname_9.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_nullif_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_nvl2_3.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_parse_json_extract_path_text_4.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_position_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_regexp_like_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_regexp_replace_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_regexp_substr_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_repeat_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_right_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_split_part_7.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_split_part_8.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_startswith_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_timestampadd_6.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_to_number_10.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_trunc_2.sql delete mode 100644 tests/resources/functional/snowflake_expected_exceptions/test_try_cast_3.sql delete mode 100644 tests/resources/functional/tsql/core_engine/dbt/nofmt_twisted_input.sql delete mode 100644 tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_1.sql delete mode 100644 tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_2.sql delete mode 100644 tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_3.sql delete mode 100644 tests/resources/functional/tsql/cte/cte_set_operation_precedence.sql delete mode 100644 tests/resources/functional/tsql/cte/cte_with_column_list.sql delete mode 100644 tests/resources/functional/tsql/cte/multiple_cte.sql delete mode 100644 tests/resources/functional/tsql/cte/nested_set_operation.sql delete mode 100644 tests/resources/functional/tsql/cte/simple_cte.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aadbts_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aalangid1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aalanguage_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aalock_timeout_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aamax_connections_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aamax_precision_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaoptions_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaremserver_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaservername_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaservicename_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaspid_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aatextsize_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_aaversion_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_abs_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_approx_count_distinct.sql delete mode 100644 tests/resources/functional/tsql/functions/test_approx_percentile_cont_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_approx_percentile_disc_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_avg_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_avg_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_avg_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_avg_4.sql delete mode 100644 tests/resources/functional/tsql/functions/test_avg_5.sql delete mode 100644 tests/resources/functional/tsql/functions/test_bit_count_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_checksum_agg_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_collationproperty_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_count_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_count_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_cume_dist_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_day_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_day_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_day_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_dayofyear_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_dayofyear_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_dayofyear_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_hour_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_hour_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_microsecond_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_microsecond_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_millisecond_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_millisecond_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_minute_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_minute_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_minute_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_month_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_month_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_month_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_nanosecond_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_nanosecond_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_quarter_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_quarter_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_quarter_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_second_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_second_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_second_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_week_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_week_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_week_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_weekday_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_weekday_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_weekday_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_year_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_year_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_dateadd_year_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_first_value_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_first_value_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_first_value_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_first_value_4.sql delete mode 100644 tests/resources/functional/tsql/functions/test_get_bit_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_grouping_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_grouping_id_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_grouping_id_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_isnull_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_lag_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_lag_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_last_value_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_last_value_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_last_value_3.sql delete mode 100644 tests/resources/functional/tsql/functions/test_last_value_4.sql delete mode 100644 tests/resources/functional/tsql/functions/test_lead_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_lead_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_left_shift_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_max.2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_max_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_min.1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_min.2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_nestlevel_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_percent_rank_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_percentile_cont_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_percentile_disc_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_right_shift_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_set_bit_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_set_bit_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_stdev_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_stdev_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_stdevp_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_stdevp_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_sum_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_sum_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_var_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_var_2.sql delete mode 100644 tests/resources/functional/tsql/functions/test_varp_1.sql delete mode 100644 tests/resources/functional/tsql/functions/test_varp_2.sql delete mode 100644 tests/resources/functional/tsql/select/limit.sql delete mode 100644 tests/resources/functional/tsql/select/order_by.sql delete mode 100644 tests/resources/functional/tsql/select/order_by_asc.sql delete mode 100644 tests/resources/functional/tsql/select/order_by_desc.sql delete mode 100644 tests/resources/functional/tsql/select/order_by_offset.sql delete mode 100644 tests/resources/functional/tsql/select/order_by_precedence.sql delete mode 100644 tests/resources/functional/tsql/select/test_cte_1.sql delete mode 100644 tests/resources/functional/tsql/select/test_cte_2.sql delete mode 100644 tests/resources/functional/tsql/select/test_cte_xml.sql delete mode 100644 tests/resources/functional/tsql/set-operations/except.sql delete mode 100644 tests/resources/functional/tsql/set-operations/intersect.sql delete mode 100644 tests/resources/functional/tsql/set-operations/precedence.sql delete mode 100644 tests/resources/functional/tsql/set-operations/union-all.sql delete mode 100644 tests/resources/functional/tsql/set-operations/union.sql delete mode 100644 tests/resources/functional/tsql/set-operations/union_all_left_grouped.sql delete mode 100644 tests/resources/functional/tsql/set-operations/union_left_grouped.sql create mode 100644 tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst create mode 100644 tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst delete mode 100644 tests/unit/transpiler/test_databricks.py delete mode 100644 tests/unit/transpiler/test_databricks_expected_exceptions.py delete mode 100644 tests/unit/transpiler/test_lca_utils.py delete mode 100644 tests/unit/transpiler/test_oracle.py delete mode 100644 tests/unit/transpiler/test_presto.py delete mode 100644 tests/unit/transpiler/test_presto_expected_exceptions.py delete mode 100644 tests/unit/transpiler/test_snow.py delete mode 100644 tests/unit/transpiler/test_sqlglot_engine.py diff --git a/src/databricks/labs/remorph/cli.py b/src/databricks/labs/remorph/cli.py index cdf9409ed0..d6771d9640 100644 --- a/src/databricks/labs/remorph/cli.py +++ b/src/databricks/labs/remorph/cli.py @@ -15,13 +15,11 @@ from databricks.labs.remorph.transpiler.execute import transpile as do_transpile from databricks.labs.remorph.reconcile.execute import RECONCILE_OPERATION_NAME, AGG_RECONCILE_OPERATION_NAME from databricks.labs.remorph.jvmproxy import proxy_command +from databricks.labs.remorph.transpiler.lsp_engine import LSPEngine from databricks.sdk.core import with_user_agent_extra from databricks.sdk import WorkspaceClient -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine -from databricks.labs.remorph.transpiler.transpile_engine import TranspileEngine - remorph = App(__file__) logger = get_logger(__file__) @@ -83,7 +81,7 @@ def transpile( if not default_config: raise SystemExit("Installed transpile config not found. Please install Remorph transpile first.") _override_workspace_client_config(ctx, default_config.sdk_config) - engine = TranspileEngine.load_engine(Path(transpiler_config_path)) + engine = LSPEngine.from_config_path(Path(transpiler_config_path)) engine.check_source_dialect(source_dialect) if not input_source or not os.path.exists(input_source): raise_validation_exception(f"Invalid value for '--input-source': Path '{input_source}' does not exist.") @@ -173,14 +171,12 @@ def generate_lineage(w: WorkspaceClient, source_dialect: str, input_source: str, """[Experimental] Generates a lineage of source SQL files or folder""" ctx = ApplicationContext(w) logger.debug(f"User: {ctx.current_user}") - engine = SqlglotEngine() - engine.check_source_dialect(source_dialect) if not input_source or not os.path.exists(input_source): raise_validation_exception(f"Invalid value for '--input-source': Path '{input_source}' does not exist.") if not os.path.exists(output_folder) or output_folder in {None, ""}: raise_validation_exception(f"Invalid value for '--output-folder': Path '{output_folder}' does not exist.") - lineage_generator(engine, source_dialect, input_source, output_folder) + lineage_generator(source_dialect, input_source, output_folder) @remorph.command diff --git a/src/databricks/labs/remorph/coverage/remorph_snow_transpilation_coverage.py b/src/databricks/labs/remorph/coverage/remorph_snow_transpilation_coverage.py index ef1b56676a..9b2ca5e817 100644 --- a/src/databricks/labs/remorph/coverage/remorph_snow_transpilation_coverage.py +++ b/src/databricks/labs/remorph/coverage/remorph_snow_transpilation_coverage.py @@ -1,9 +1,9 @@ from pathlib import Path +from sqlglot.dialects import Snowflake, Databricks + from databricks.labs.blueprint.wheels import ProductInfo from databricks.labs.remorph.coverage import commons -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks -from databricks.labs.remorph.transpiler.sqlglot.parsers.snowflake import Snowflake if __name__ == "__main__": input_dir = commons.get_env_var("INPUT_DIR_PARENT", required=True) diff --git a/src/databricks/labs/remorph/install.py b/src/databricks/labs/remorph/install.py index aefe86dc74..1c7aa5e29c 100644 --- a/src/databricks/labs/remorph/install.py +++ b/src/databricks/labs/remorph/install.py @@ -32,7 +32,7 @@ from databricks.labs.remorph.deployment.configurator import ResourceConfigurator from databricks.labs.remorph.deployment.installation import WorkspaceInstallation from databricks.labs.remorph.reconcile.constants import ReconReportType, ReconSourceType -from databricks.labs.remorph.transpiler.lsp.lsp_engine import LSPConfig +from databricks.labs.remorph.transpiler.lsp_engine import LSPConfig logger = logging.getLogger(__name__) diff --git a/src/databricks/labs/remorph/intermediate/root_tables.py b/src/databricks/labs/remorph/intermediate/root_tables.py index fd888d1de6..b6e35a44c6 100644 --- a/src/databricks/labs/remorph/intermediate/root_tables.py +++ b/src/databricks/labs/remorph/intermediate/root_tables.py @@ -1,5 +1,8 @@ import logging +from collections.abc import Iterable from pathlib import Path +from sqlglot import parse, Expression, ErrorLevel +from sqlglot.expressions import Create, Insert, Merge, Join, Select, Table, With from databricks.labs.remorph.helpers.file_utils import ( get_sql_file, @@ -8,15 +11,12 @@ ) from databricks.labs.remorph.intermediate.dag import DAG -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine - logger = logging.getLogger(__name__) class RootTableAnalyzer: - def __init__(self, engine: SqlglotEngine, source_dialect: str, input_path: Path): - self.engine = engine + def __init__(self, source_dialect: str, input_path: Path): self.source_dialect = source_dialect self.input_path = input_path @@ -39,6 +39,26 @@ def generate_lineage_dag(self) -> DAG: return dag def _populate_dag(self, sql_content: str, path: Path, dag: DAG): - for root_table, child in self.engine.analyse_table_lineage(self.source_dialect, sql_content, path): + for root_table, child in self._analyse_table_lineage(sql_content, path): dag.add_node(child) dag.add_edge(root_table, child) + + def _analyse_table_lineage(self, source_code: str, file_path: Path) -> Iterable[tuple[str, str]]: + parsed_expression, _ = parse(source_code, read=self.source_dialect, error_level=ErrorLevel.IMMEDIATE) + if parsed_expression is not None: + for expr in parsed_expression: + child: str = str(file_path) + if expr is not None: + # TODO: fix possible issue where the file reference is lost (if we have a 'create') + for change in expr.find_all(Create, Insert, Merge, bfs=False): + child = self._find_root_table(change) + + for query in expr.find_all(Select, Join, With, bfs=False): + table = self._find_root_table(query) + if table: + yield table, child + + @staticmethod + def _find_root_table(exp: Expression) -> str: + table = exp.find(Table, bfs=False) + return table.name if table else "" diff --git a/src/databricks/labs/remorph/lineage.py b/src/databricks/labs/remorph/lineage.py index 307abc90aa..60acda9c38 100644 --- a/src/databricks/labs/remorph/lineage.py +++ b/src/databricks/labs/remorph/lineage.py @@ -4,7 +4,6 @@ from databricks.labs.remorph.intermediate.dag import DAG from databricks.labs.remorph.intermediate.root_tables import RootTableAnalyzer -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine logger = logging.getLogger(__name__) @@ -21,13 +20,13 @@ def _generate_dot_file_contents(dag: DAG) -> str: return _lineage_str -def lineage_generator(engine: SqlglotEngine, source_dialect: str, input_source: str, output_folder: str): +def lineage_generator(source_dialect: str, input_source: str, output_folder: str): input_sql_path = Path(input_source) output_folder = output_folder if output_folder.endswith('/') else output_folder + '/' msg = f"Processing for SQLs at this location: {input_sql_path}" logger.info(msg) - root_table_analyzer = RootTableAnalyzer(engine, source_dialect, input_sql_path) + root_table_analyzer = RootTableAnalyzer(source_dialect, input_sql_path) generated_dag = root_table_analyzer.generate_lineage_dag() lineage_file_content = _generate_dot_file_contents(generated_dag) diff --git a/src/databricks/labs/remorph/reconcile/connectors/source_adapter.py b/src/databricks/labs/remorph/reconcile/connectors/source_adapter.py index b8faa6d13e..5ae527d919 100644 --- a/src/databricks/labs/remorph/reconcile/connectors/source_adapter.py +++ b/src/databricks/labs/remorph/reconcile/connectors/source_adapter.py @@ -1,15 +1,12 @@ from pyspark.sql import SparkSession from sqlglot import Dialect -from sqlglot.dialects import TSQL +from sqlglot.dialects import TSQL, Snowflake, Oracle, Databricks from databricks.labs.remorph.reconcile.connectors.data_source import DataSource from databricks.labs.remorph.reconcile.connectors.databricks import DatabricksDataSource from databricks.labs.remorph.reconcile.connectors.oracle import OracleDataSource from databricks.labs.remorph.reconcile.connectors.snowflake import SnowflakeDataSource from databricks.labs.remorph.reconcile.connectors.sql_server import SQLServerDataSource -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks -from databricks.labs.remorph.transpiler.sqlglot.parsers.oracle import Oracle -from databricks.labs.remorph.transpiler.sqlglot.parsers.snowflake import Snowflake from databricks.sdk import WorkspaceClient diff --git a/src/databricks/labs/remorph/reconcile/execute.py b/src/databricks/labs/remorph/reconcile/execute.py index c2733207e2..5d12e8db59 100644 --- a/src/databricks/labs/remorph/reconcile/execute.py +++ b/src/databricks/labs/remorph/reconcile/execute.py @@ -8,13 +8,13 @@ from pyspark.sql import DataFrame, SparkSession from sqlglot import Dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.config import ( DatabaseConfig, TableRecon, ReconcileConfig, ReconcileMetadataConfig, ) -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.compare import ( capture_mismatch_data_and_columns, reconcile_data, diff --git a/src/databricks/labs/remorph/reconcile/query_builder/aggregate_query.py b/src/databricks/labs/remorph/reconcile/query_builder/aggregate_query.py index 4aed6128ad..172ba30cd7 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/aggregate_query.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/aggregate_query.py @@ -175,7 +175,7 @@ def _get_layer_query(self, group_list: list[Aggregate]) -> AggregateQueryRules: layer=self.layer, group_by_columns=group_list[0].group_by_columns, group_by_columns_as_str=group_list[0].group_by_columns_as_str, - query=query_exp.sql(dialect=self.engine), + query=query_exp.sql(dialect=self._dialect), rules=query_agg_rules, ) return agg_query_rules diff --git a/src/databricks/labs/remorph/reconcile/query_builder/base.py b/src/databricks/labs/remorph/reconcile/query_builder/base.py index c8c4f7475e..d62550d671 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/base.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/base.py @@ -4,13 +4,13 @@ import sqlglot.expressions as exp from sqlglot import Dialect, parse_one +from databricks.labs.remorph.reconcile.utils import get_dialect, get_dialect_name from databricks.labs.remorph.reconcile.exception import InvalidInputException from databricks.labs.remorph.reconcile.query_builder.expression_generator import ( DataType_transform_mapping, transform_expression, ) from databricks.labs.remorph.reconcile.recon_config import Schema, Table, Aggregate -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect, SQLGLOT_DIALECTS logger = logging.getLogger(__name__) @@ -21,16 +21,16 @@ def __init__( table_conf: Table, schema: list[Schema], layer: str, - engine: Dialect, + dialect: Dialect, ): self._table_conf = table_conf self._schema = schema self._layer = layer - self._engine = engine + self._dialect = dialect @property - def engine(self) -> Dialect: - return self._engine + def dialect(self) -> Dialect: + return self._dialect @property def layer(self) -> str: @@ -93,7 +93,7 @@ def _apply_user_transformation(self, aliases: list[exp.Expression]) -> list[exp. def _user_transformer(self, node: exp.Expression, user_transformations: dict[str, str]) -> exp.Expression: if isinstance(node, exp.Column) and user_transformations: - dialect = self.engine if self.layer == "source" else get_dialect("databricks") + dialect = self._dialect if self.layer == "source" else get_dialect("databricks") column_name = node.name if column_name in user_transformations.keys(): return parse_one(user_transformations.get(column_name, column_name), read=dialect) @@ -108,13 +108,11 @@ def _apply_default_transformation( return with_transform @staticmethod - def _default_transformer(node: exp.Expression, schema: list[Schema], source: Dialect) -> exp.Expression: + def _default_transformer(node: exp.Expression, schema: list[Schema], dialect: Dialect) -> exp.Expression: def _get_transform(datatype: str): - source_dialects = [source_key for source_key, dialect in SQLGLOT_DIALECTS.items() if dialect == source] - source_dialect = source_dialects[0] if source_dialects else "universal" - - source_mapping = DataType_transform_mapping.get(source_dialect, {}) + dialect_name = get_dialect_name(dialect) + source_mapping = DataType_transform_mapping.get(dialect_name, {}) if source_mapping.get(datatype.upper()) is not None: return source_mapping.get(datatype.upper()) diff --git a/src/databricks/labs/remorph/reconcile/query_builder/expression_generator.py b/src/databricks/labs/remorph/reconcile/query_builder/expression_generator.py index 3a66c68663..e2b862aebc 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/expression_generator.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/expression_generator.py @@ -5,7 +5,7 @@ from sqlglot import Dialect from sqlglot import expressions as exp -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.recon_config import HashAlgoMapping diff --git a/src/databricks/labs/remorph/reconcile/query_builder/hash_query.py b/src/databricks/labs/remorph/reconcile/query_builder/hash_query.py index e62a9e0573..5890a02311 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/hash_query.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/hash_query.py @@ -3,6 +3,7 @@ import sqlglot.expressions as exp from sqlglot import Dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.query_builder.base import QueryBuilder from databricks.labs.remorph.reconcile.query_builder.expression_generator import ( build_column, @@ -11,7 +12,6 @@ lower, transform_expression, ) -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect logger = logging.getLogger(__name__) @@ -59,7 +59,7 @@ def build_query(self, report_type: str) -> str: ) hash_col_with_transform = [self._generate_hash_algorithm(hashcols_sorted_as_src_seq, _HASH_COLUMN_NAME)] - dialect = self.engine if self.layer == "source" else get_dialect("databricks") + dialect = self._dialect if self.layer == "source" else get_dialect("databricks") res = ( exp.select(*hash_col_with_transform + key_cols_with_transform) .from_(":tbl") @@ -77,11 +77,11 @@ def _generate_hash_algorithm( ) -> exp.Expression: cols_with_alias = [build_column(this=col, alias=None) for col in cols] cols_with_transform = self.add_transformations( - cols_with_alias, self.engine if self.layer == "source" else get_dialect("databricks") + cols_with_alias, self._dialect if self.layer == "source" else get_dialect("databricks") ) col_exprs = exp.select(*cols_with_transform).iter_expressions() concat_expr = concat(list(col_exprs)) - hash_expr = concat_expr.transform(_hash_transform, self.engine, self.layer).transform(lower, is_expr=True) + hash_expr = concat_expr.transform(_hash_transform, self._dialect, self.layer).transform(lower, is_expr=True) return build_column(hash_expr, alias=column_alias) diff --git a/src/databricks/labs/remorph/reconcile/query_builder/sampling_query.py b/src/databricks/labs/remorph/reconcile/query_builder/sampling_query.py index f5d2c91343..d05cf6c1c3 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/sampling_query.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/sampling_query.py @@ -1,10 +1,10 @@ import logging import sqlglot.expressions as exp -from pyspark.sql import DataFrame from sqlglot import select +from pyspark.sql import DataFrame -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_key_from_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect_name from databricks.labs.remorph.reconcile.query_builder.base import QueryBuilder from databricks.labs.remorph.reconcile.query_builder.expression_generator import ( build_column, @@ -52,7 +52,7 @@ def build_query(self, df: DataFrame): for col in cols ] - sql_with_transforms = self.add_transformations(cols_with_alias, self.engine) + sql_with_transforms = self.add_transformations(cols_with_alias, self._dialect) query_sql = select(*sql_with_transforms).from_(":tbl").where(self.filter) if self.layer == "source": with_select = [build_column(this=col, table_name="src") for col in sorted(cols)] @@ -69,7 +69,7 @@ def build_query(self, df: DataFrame): .select(*with_select) .from_("src") .join(join_clause) - .sql(dialect=self.engine) + .sql(dialect=self._dialect) ) logger.info(f"Sampling Query for {self.layer}: {query}") return query @@ -97,7 +97,7 @@ def _get_with_clause(self, df: DataFrame) -> exp.Select: ) for col, value in zip(df.columns, row) ] - if get_key_from_dialect(self.engine) == "oracle": + if get_dialect_name(self._dialect) == "oracle": union_res.append(select(*row_select).from_("dual")) else: union_res.append(select(*row_select)) diff --git a/src/databricks/labs/remorph/reconcile/query_builder/threshold_query.py b/src/databricks/labs/remorph/reconcile/query_builder/threshold_query.py index 44bc155f9f..ef75e359ed 100644 --- a/src/databricks/labs/remorph/reconcile/query_builder/threshold_query.py +++ b/src/databricks/labs/remorph/reconcile/query_builder/threshold_query.py @@ -3,6 +3,7 @@ from sqlglot import expressions as exp from sqlglot import select +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.query_builder.base import QueryBuilder from databricks.labs.remorph.reconcile.query_builder.expression_generator import ( anonymous, @@ -17,7 +18,6 @@ coalesce, ) from databricks.labs.remorph.reconcile.recon_config import ColumnThresholds -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks logger = logging.getLogger(__name__) @@ -34,7 +34,13 @@ def build_comparison_query(self) -> str: select_clause, where = self._generate_select_where_clause(join_columns) from_clause, join_clause = self._generate_from_and_join_clause(join_columns) # for threshold comparison query the dialect is always Databricks - query = select(*select_clause).from_(from_clause).join(join_clause).where(where).sql(dialect=Databricks) + query = ( + select(*select_clause) + .from_(from_clause) + .join(join_clause) + .where(where) + .sql(dialect=get_dialect("databricks")) + ) logger.info(f"Threshold Comparison query: {query}") return query @@ -226,6 +232,6 @@ def build_threshold_query(self) -> str: if self.user_transformations: thresholds_expr = self._apply_user_transformation(threshold_alias) - query = (select(*keys_expr + thresholds_expr).from_(":tbl").where(self.filter)).sql(dialect=self.engine) + query = (select(*keys_expr + thresholds_expr).from_(":tbl").where(self.filter)).sql(dialect=self._dialect) logger.info(f"Threshold Query for {self.layer}: {query}") return query diff --git a/src/databricks/labs/remorph/reconcile/recon_capture.py b/src/databricks/labs/remorph/reconcile/recon_capture.py index 1d76ffe6e9..75e7566adb 100644 --- a/src/databricks/labs/remorph/reconcile/recon_capture.py +++ b/src/databricks/labs/remorph/reconcile/recon_capture.py @@ -8,8 +8,8 @@ from pyspark.errors import PySparkException from sqlglot import Dialect +from databricks.labs.remorph.reconcile.utils import get_dialect_name from databricks.labs.remorph.config import DatabaseConfig, Table, ReconcileMetadataConfig -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_key_from_dialect from databricks.labs.remorph.reconcile.exception import ( WriteToTableException, ReadAndWriteWithVolumeException, @@ -261,16 +261,16 @@ def _insert_into_main_table( recon_process_duration: ReconcileProcessDuration, operation_name: str = "reconcile", ) -> None: - source_dialect_key = get_key_from_dialect(self.source_dialect) + dialect_name = get_dialect_name(self.source_dialect) df = self.spark.sql( f""" select {recon_table_id} as recon_table_id, '{self.recon_id}' as recon_id, case - when '{source_dialect_key}' = 'databricks' then 'Databricks' - when '{source_dialect_key}' = 'snowflake' then 'Snowflake' - when '{source_dialect_key}' = 'oracle' then 'Oracle' - else '{source_dialect_key}' + when '{dialect_name}' = 'databricks' then 'Databricks' + when '{dialect_name}' = 'snowflake' then 'Snowflake' + when '{dialect_name}' = 'oracle' then 'Oracle' + else '{dialect_name}' end as source_type, named_struct( 'catalog', case when '{self.database_config.source_catalog}' = 'None' then null else '{self.database_config.source_catalog}' end, diff --git a/src/databricks/labs/remorph/reconcile/schema_compare.py b/src/databricks/labs/remorph/reconcile/schema_compare.py index 966ff406a1..161d605d93 100644 --- a/src/databricks/labs/remorph/reconcile/schema_compare.py +++ b/src/databricks/labs/remorph/reconcile/schema_compare.py @@ -4,15 +4,15 @@ from pyspark.sql import DataFrame, SparkSession from pyspark.sql.types import BooleanType, StringType, StructField, StructType from sqlglot import Dialect, parse_one +from sqlglot.dialects import Databricks -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.recon_config import ( Schema, SchemaMatchResult, SchemaReconcileOutput, Table, ) -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks logger = logging.getLogger(__name__) diff --git a/src/databricks/labs/remorph/reconcile/utils.py b/src/databricks/labs/remorph/reconcile/utils.py new file mode 100644 index 0000000000..88bbdc86df --- /dev/null +++ b/src/databricks/labs/remorph/reconcile/utils.py @@ -0,0 +1,16 @@ +from sqlglot import Dialect +from sqlglot.dialects import Dialects + + +def get_dialect(name: str) -> Dialect: + value = Dialect.get(name) + if isinstance(value, Dialect): + return value + if isinstance(value, type(Dialect)): + return value() + raise ValueError(f"Can't instantiate dialect from {name}") + + +def get_dialect_name(dialect: Dialect) -> str: + name = type(dialect).__name__ + return name if name in Dialects else "universal" diff --git a/src/databricks/labs/remorph/transpiler/execute.py b/src/databricks/labs/remorph/transpiler/execute.py index c168944b8c..e461b5afce 100644 --- a/src/databricks/labs/remorph/transpiler/execute.py +++ b/src/databricks/labs/remorph/transpiler/execute.py @@ -1,4 +1,3 @@ -import asyncio import datetime import logging from pathlib import Path @@ -27,7 +26,6 @@ ) from databricks.labs.remorph.helpers.string_utils import remove_bom from databricks.labs.remorph.helpers.validation import Validator -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine from databricks.sdk import WorkspaceClient logger = logging.getLogger(__name__) @@ -226,41 +224,3 @@ def _validation( sql: str, ) -> ValidationResult: return validator.validate_format_result(config, sql) - - -@timeit -def transpile_sql( - workspace_client: WorkspaceClient, - config: TranspileConfig, - source_sql: str, -) -> tuple[TranspileResult, ValidationResult | None]: - """[Experimental] Transpile a single SQL query from one dialect to another.""" - ws_client: WorkspaceClient = verify_workspace_client(workspace_client) - - engine: TranspileEngine = SqlglotEngine() - - transpiler_result = asyncio.run( - _transpile(engine, config.source_dialect, config.target_dialect, source_sql, Path("inline_sql")) - ) - - if config.skip_validation: - return transpiler_result, None - - sql_backend = db_sql.get_sql_backend(ws_client) - logger.info(f"SQL Backend used for query validation: {type(sql_backend).__name__}") - validator = Validator(sql_backend) - return transpiler_result, _validation(validator, config, transpiler_result.transpiled_code) - - -@timeit -def transpile_column_exp( - workspace_client: WorkspaceClient, - config: TranspileConfig, - expressions: list[str], -) -> list[tuple[TranspileResult, ValidationResult | None]]: - """[Experimental] Transpile a list of SQL expressions from one dialect to another.""" - config.skip_validation = True - result = [] - for sql in expressions: - result.append(transpile_sql(workspace_client, config, sql)) - return result diff --git a/src/databricks/labs/remorph/transpiler/lsp/__init__.py b/src/databricks/labs/remorph/transpiler/lsp/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/databricks/labs/remorph/transpiler/lsp/lsp_engine.py b/src/databricks/labs/remorph/transpiler/lsp_engine.py similarity index 98% rename from src/databricks/labs/remorph/transpiler/lsp/lsp_engine.py rename to src/databricks/labs/remorph/transpiler/lsp_engine.py index 083430209c..79d9c9dfa2 100644 --- a/src/databricks/labs/remorph/transpiler/lsp/lsp_engine.py +++ b/src/databricks/labs/remorph/transpiler/lsp_engine.py @@ -341,6 +341,10 @@ class LSPEngine(TranspileEngine): @classmethod def from_config_path(cls, config_path: Path) -> LSPEngine: + if not config_path.exists(): + raise ValueError( + f"Error: Invalid value for '--transpiler-config-path': '{str(config_path)}', file does not exist." + ) config = LSPConfig.load(config_path) return LSPEngine(config_path.parent, config) diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/__init__.py b/src/databricks/labs/remorph/transpiler/sqlglot/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/dialect_utils.py b/src/databricks/labs/remorph/transpiler/sqlglot/dialect_utils.py deleted file mode 100644 index 8622960980..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/dialect_utils.py +++ /dev/null @@ -1,30 +0,0 @@ -from sqlglot import Dialects, Dialect - -from databricks.labs.remorph.transpiler.sqlglot.parsers import oracle, presto, snowflake -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks - -SQLGLOT_DIALECTS: dict[str, type[Dialect] | str] = { - "athena": Dialects.ATHENA, - "bigquery": Dialects.BIGQUERY, - "databricks": Databricks, - "mysql": Dialects.MYSQL, - "netezza": Dialects.POSTGRES, - "oracle": oracle.Oracle, - "postgresql": Dialects.POSTGRES, - "presto": presto.Presto, - "redshift": Dialects.REDSHIFT, - "snowflake": snowflake.Snowflake, - "sqlite": Dialects.SQLITE, - "teradata": Dialects.TERADATA, - "trino": Dialects.TRINO, - "tsql": Dialects.TSQL, - "vertica": Dialects.POSTGRES, -} - - -def get_dialect(dialect: str) -> Dialect: - return Dialect.get_or_raise(SQLGLOT_DIALECTS.get(dialect)) - - -def get_key_from_dialect(input_dialect: Dialect) -> str: - return [source_key for source_key, dialect in SQLGLOT_DIALECTS.items() if dialect == input_dialect][0] diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/generator/__init__.py b/src/databricks/labs/remorph/transpiler/sqlglot/generator/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/generator/databricks.py b/src/databricks/labs/remorph/transpiler/sqlglot/generator/databricks.py deleted file mode 100644 index 8d97c1f13d..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/generator/databricks.py +++ /dev/null @@ -1,771 +0,0 @@ -import logging -import re - -from sqlglot import expressions as exp -from sqlglot.dialects.databricks import Databricks as SqlglotDatabricks -from sqlglot.dialects.hive import Hive -from sqlglot.dialects.dialect import if_sql -from sqlglot.dialects.dialect import rename_func -from sqlglot.errors import UnsupportedError -from sqlglot.helper import apply_index_offset, csv - -from databricks.labs.remorph.transpiler.sqlglot import local_expression -from databricks.labs.remorph.transpiler.sqlglot.lca_utils import unalias_lca_in_select - -# pylint: disable=too-many-public-methods - -logger = logging.getLogger(__name__) - -VALID_DATABRICKS_TYPES = { - "BIGINT", - "BINARY", - "BOOLEAN", - "DATE", - "DECIMAL", - "DOUBLE", - "FLOAT", - "INT", - "INTERVAL", - "VOID", - "SMALLINT", - "STRING", - "TIMESTAMP", - "TINYINT", - "ARRAY", - "MAP", - "STRUCT", -} - -PRECISION_CONST = 38 -SCALE_CONST = 0 - - -def timestamptrunc_sql(self, expression: exp.TimestampTrunc) -> str: - return self.func("DATE_TRUNC", exp.Literal.string(expression.text("unit").upper()), self.sql(expression.this)) - - -def _parm_sfx(self, expression: local_expression.Parameter) -> str: - this = self.sql(expression, "this") - this = f"{{{this}}}" if expression.args.get("wrapped") else f"{this}" - suffix = self.sql(expression, "suffix") - PARAMETER_TOKEN = "$" # noqa: N806 pylint: disable=invalid-name - return f"{PARAMETER_TOKEN}{this}{suffix}" - - -def _lateral_bracket_sql(self, expression: local_expression.Bracket) -> str: - """Overwrites `sqlglot/generator.py` `bracket_sql()` function - to convert `[COL_NAME]` to `.COL_NAME`. - Example: c[val] ==> c.val - """ - expressions = apply_index_offset(expression.this, expression.expressions, self.dialect.INDEX_OFFSET) - expressions = [self.sql(e.alias_or_name.strip("'")) for e in expressions] - # If expression contains space in between encode it in backticks(``): - # e.g. ref."ID Number" -> ref.`ID Number`. - expressions_sql = ", ".join(f"`{e}`" if " " in e else e for e in expressions) - return f"{self.sql(expression, 'this')}:{expressions_sql}" - - -def _format_create_sql(self, expression: exp.Create) -> str: - expression = expression.copy() - - # Remove modifiers in order to simplify the schema. For example, this removes things like "IF NOT EXISTS" - # from "CREATE TABLE foo IF NOT EXISTS". - args_to_delete = ["temporary", "transient", "external", "exists", "unique", "materialized", "properties"] - for arg_to_delete in args_to_delete: - if expression.args.get(arg_to_delete): - del expression.args[arg_to_delete] - - return self.create_sql(expression) - - -def _curr_time(): - return "date_format(current_timestamp(), 'HH:mm:ss')" - - -def _select_contains_index(expression: exp.Select) -> bool: - for expr in expression.expressions: - column = expr.unalias() if isinstance(expr, exp.Alias) else expr - if column.name == "index": - return True - return False - - -def _has_parse_json(expression): - if expression.find(exp.ParseJSON): - return True - _select = expression.find_ancestor(exp.Select) - if _select: - _from = _select.find(exp.From) - if _from: - _parse_json = _from.find(exp.ParseJSON) - if _parse_json: - return True - return False - - -def _generate_function_str(select_contains_index, has_parse_json, generator_expr, alias, is_outer, alias_str): - if select_contains_index: - generator_function_str = f"POSEXPLODE({generator_expr})" - alias_str = f"{' ' + alias.name if isinstance(alias, exp.TableAlias) else ''} AS index, value" - elif has_parse_json and is_outer: - generator_function_str = f"VARIANT_EXPLODE_OUTER({generator_expr})" - elif has_parse_json: - generator_function_str = f"VARIANT_EXPLODE({generator_expr})" - else: - generator_function_str = f"VIEW EXPLODE({generator_expr})" - - return generator_function_str, alias_str - - -def _generate_lateral_statement(self, select_contains_index, has_parse_json, generator_function_str, alias_str): - if select_contains_index: - lateral_statement = self.sql(f"LATERAL VIEW OUTER {generator_function_str}{alias_str}") - elif has_parse_json: - lateral_statement = self.sql(f", LATERAL {generator_function_str}{alias_str}") - else: - lateral_statement = self.sql(f" LATERAL {generator_function_str}{alias_str}") - - return lateral_statement - - -def _lateral_view(self: SqlglotDatabricks.Generator, expression: exp.Lateral) -> str: - has_parse_json = _has_parse_json(expression) - this = expression.args['this'] - alias = expression.args['alias'] - alias_str = f" AS {alias.name}" if isinstance(alias, exp.TableAlias) else "" - generator_function_str = self.sql(this) - is_outer = False - select_contains_index = False - - if isinstance(this, exp.Explode): - explode_expr = this - parent_select = explode_expr.parent_select - select_contains_index = _select_contains_index(parent_select) if parent_select else False - generator_expr = "" - if isinstance(explode_expr.this, exp.Kwarg): - generator_expr = self.sql(explode_expr.this, 'expression') - if not isinstance(explode_expr.this.expression, exp.ParseJSON): - generator_expr = generator_expr.replace("{", "").replace("}", "") - for expr in explode_expr.expressions: - node = str(expr.this).upper() - if node == "PATH": - generator_expr += "." + self.sql(expr, 'expression').replace("'", "") - if node == "OUTER": - is_outer = True - - if not generator_expr: - generator_expr = expression.this.this - - generator_function_str, alias_str = _generate_function_str( - select_contains_index, has_parse_json, generator_expr, alias, is_outer, alias_str - ) - - alias_cols = alias.columns if alias else [] - if len(alias_cols) <= 2: - alias_str = f" As {', '.join([item.this for item in alias_cols])}" - - lateral_statement = _generate_lateral_statement( - self, select_contains_index, has_parse_json, generator_function_str, alias_str - ) - return lateral_statement - - -# [TODO] Add more datatype coverage https://docs.databricks.com/sql/language-manual/sql-ref-datatypes.html -def _datatype_map(self, expression) -> str: - if expression.this in [exp.DataType.Type.VARCHAR, exp.DataType.Type.NVARCHAR, exp.DataType.Type.CHAR]: - return "STRING" - if expression.this in [exp.DataType.Type.TIMESTAMP, exp.DataType.Type.TIMESTAMPLTZ]: - return "TIMESTAMP" - if expression.this == exp.DataType.Type.BINARY: - return "BINARY" - if expression.this == exp.DataType.Type.NCHAR: - return "STRING" - return self.datatype_sql(expression) - - -def try_to_date(self, expression: local_expression.TryToDate): - func = "TRY_TO_TIMESTAMP" - time_format = self.sql(expression, "format") - if not time_format: - time_format = Hive.DATE_FORMAT - - ts_result = self.func(func, expression.this, time_format) - return exp.Date(this=ts_result) - - -def try_to_number(self, expression: local_expression.TryToNumber): - func = "TRY_TO_NUMBER" - precision = self.sql(expression, "precision") - scale = self.sql(expression, "scale") - - if not precision: - precision = 38 - - if not scale: - scale = 0 - - func_expr = self.func(func, expression.this) - if expression.expression: - func_expr = self.func(func, expression.this, expression.expression) - else: - func_expr = expression.this - - return f"CAST({func_expr} AS DECIMAL({precision}, {scale}))" - - -def _to_boolean(self: SqlglotDatabricks.Generator, expression: local_expression.ToBoolean) -> str: - this = self.sql(expression, "this") - logger.debug(f"Converting {this} to Boolean") - raise_error = self.sql(expression, "raise_error") - raise_error_str = "RAISE_ERROR('Invalid parameter type for TO_BOOLEAN')" if bool(int(raise_error)) else "NULL" - transformed = f""" - CASE - WHEN {this} IS NULL THEN NULL - WHEN TYPEOF({this}) = 'boolean' THEN BOOLEAN({this}) - WHEN TYPEOF({this}) = 'string' THEN - CASE - WHEN LOWER({this}) IN ('true', 't', 'yes', 'y', 'on', '1') THEN TRUE - WHEN LOWER({this}) IN ('false', 'f', 'no', 'n', 'off', '0') THEN FALSE - ELSE RAISE_ERROR('Boolean value of x is not recognized by TO_BOOLEAN') - END - WHEN TRY_CAST({this} AS DOUBLE) IS NOT NULL THEN - CASE - WHEN ISNAN(CAST({this} AS DOUBLE)) OR CAST({this} AS DOUBLE) = DOUBLE('infinity') THEN - RAISE_ERROR('Invalid parameter type for TO_BOOLEAN') - ELSE CAST({this} AS DOUBLE) != 0.0 - END - ELSE {raise_error_str} - END - """ - return transformed - - -def _is_integer(self: SqlglotDatabricks.Generator, expression: local_expression.IsInteger) -> str: - this = self.sql(expression, "this") - transformed = f""" - CASE - WHEN {this} IS NULL THEN NULL - WHEN {this} RLIKE '^-?[0-9]+$' AND TRY_CAST({this} AS INT) IS NOT NULL THEN TRUE - ELSE FALSE - END - """ - return transformed - - -def _parse_json_extract_path_text( - self: SqlglotDatabricks.Generator, expression: local_expression.JsonExtractPathText -) -> str: - this = self.sql(expression, "this") - path_name = expression.args["path_name"] - if path_name.is_string: - path = f"{self.dialect.QUOTE_START}$.{expression.text('path_name')}{self.dialect.QUOTE_END}" - else: - path = f"CONCAT('$.', {self.sql(expression, 'path_name')})" - return f"GET_JSON_OBJECT({this}, {path})" - - -def _array_construct_compact( - self: SqlglotDatabricks.Generator, expression: local_expression.ArrayConstructCompact -) -> str: - exclude = "ARRAY(NULL)" - array_expr = f"ARRAY({self.expressions(expression, flat=True)})" - return f"ARRAY_EXCEPT({array_expr}, {exclude})" - - -def _array_slice(self: SqlglotDatabricks.Generator, expression: local_expression.ArraySlice) -> str: - from_expr = self.sql(expression, "from") - # In Databricks: array indices start at 1 in function `slice(array, start, length)` - parsed_from_expr = 1 if from_expr == "0" else from_expr - - to_expr = self.sql(expression, "to") - # Convert string expression to number and check if it is negative number - if int(to_expr) < 0: - err_message = "In Databricks: function `slice` length must be greater than or equal to 0" - raise UnsupportedError(err_message) - - func = "SLICE" - func_expr = self.func(func, expression.this, exp.Literal.number(parsed_from_expr), expression.args["to"]) - return func_expr - - -def _to_command(self, expr: exp.Command): - this_sql = self.sql(expr, 'this') - expression = self.sql(expr.expression, 'this') - prefix = f"-- {this_sql}" - if this_sql == "!": - return f"{prefix}{expression}" - return f"{prefix} {expression}" - - -def _parse_json(self, expression: exp.ParseJSON) -> str: - return self.func("PARSE_JSON", expression.this, expression.expression) - - -def _to_number(self, expression: local_expression.ToNumber): - func = "TO_NUMBER" - precision = self.sql(expression, "precision") - scale = self.sql(expression, "scale") - - func_expr = expression.this - # if format is provided, else it will be vanilla cast to decimal - if expression.expression: - func_expr = self.func(func, expression.this, expression.expression) - if precision: - return f"CAST({func_expr} AS DECIMAL({precision}, {scale}))" - return func_expr - if not precision: - precision = 38 - if not scale: - scale = 0 - if not expression.expression and not precision: - exception_msg = f"""Error Parsing expression {expression}: - * `format`: is required in Databricks [mandatory] - * `precision` and `scale`: are considered as (38, 0) if not specified. - """ - raise UnsupportedError(exception_msg) - - precision = PRECISION_CONST if not precision else precision - scale = SCALE_CONST if not scale else scale - return f"CAST({func_expr} AS DECIMAL({precision}, {scale}))" - - -def _uuid(self: SqlglotDatabricks.Generator, expression: local_expression.UUID) -> str: - namespace = self.sql(expression, "this") - name = self.sql(expression, "name") - - if namespace and name: - logger.warning("UUID version 5 is not supported currently. Needs manual intervention.") - return f"UUID({namespace}, {name})" - - return "UUID()" - - -def _parse_date_trunc(self: SqlglotDatabricks.Generator, expression: local_expression.DateTrunc) -> str: - if not expression.args.get("unit"): - error_message = f"Required keyword: 'unit' missing for {exp.DateTrunc}" - raise UnsupportedError(error_message) - return self.func("TRUNC", expression.this, expression.args.get("unit")) - - -def _get_within_group_params( - expr: exp.ArrayAgg | exp.GroupConcat, - within_group: exp.WithinGroup, -) -> local_expression.WithinGroupParams: - has_distinct = isinstance(expr.this, exp.Distinct) - agg_col = expr.this.expressions[0] if has_distinct else expr.this - order_clause = within_group.expression - order_cols = [] - for e in order_clause.expressions: - desc = e.args.get("desc") - is_order_a = not desc or exp.false() == desc - order_cols.append((e.this, is_order_a)) - return local_expression.WithinGroupParams( - agg_col=agg_col, - order_cols=order_cols, - ) - - -def _create_named_struct_for_cmp(wg_params: local_expression.WithinGroupParams) -> exp.Expression: - agg_col = wg_params.agg_col - order_kv = [] - for i, (col, _) in enumerate(wg_params.order_cols): - order_kv.extend([exp.Literal(this=f"sort_by_{i}", is_string=True), col]) - - named_struct_func = exp.Anonymous( - this="named_struct", - expressions=[ - exp.Literal(this="value", is_string=True), - agg_col, - *order_kv, - ], - ) - return named_struct_func - - -def _current_date(self, expression: exp.CurrentDate) -> str: - zone = self.sql(expression, "this") - return f"CURRENT_DATE({zone})" if zone else "CURRENT_DATE()" - - -def _not_sql(self, expression: exp.Not) -> str: - if isinstance(expression.this, exp.Is): - return f"{self.sql(expression.this, 'this')} IS NOT {self.sql(expression.this, 'expression')}" - return f"NOT {self.sql(expression, 'this')}" - - -def to_array(self, expression: exp.ToArray) -> str: - return f"IF({self.sql(expression.this)} IS NULL, NULL, {self.func('ARRAY', expression.this)})" - - -class Databricks(SqlglotDatabricks): # - # Instantiate Databricks Dialect - databricks = SqlglotDatabricks() - NULL_ORDERING = "nulls_are_small" - - class Generator(SqlglotDatabricks.Generator): - INVERSE_TIME_MAPPING: dict[str, str] = { - **{v: k for k, v in SqlglotDatabricks.TIME_MAPPING.items()}, - "%-d": "dd", - } - - COLLATE_IS_FUNC = True - # [TODO]: Variant needs to be transformed better, for now parsing to string was deemed as the choice. - TYPE_MAPPING = { - **SqlglotDatabricks.Generator.TYPE_MAPPING, - exp.DataType.Type.TINYINT: "TINYINT", - exp.DataType.Type.SMALLINT: "SMALLINT", - exp.DataType.Type.INT: "INT", - exp.DataType.Type.BIGINT: "BIGINT", - exp.DataType.Type.DATETIME: "TIMESTAMP", - exp.DataType.Type.VARCHAR: "STRING", - exp.DataType.Type.VARIANT: "VARIANT", - exp.DataType.Type.FLOAT: "DOUBLE", - exp.DataType.Type.OBJECT: "STRING", - exp.DataType.Type.GEOGRAPHY: "STRING", - } - - TRANSFORMS = { - **SqlglotDatabricks.Generator.TRANSFORMS, - exp.Create: _format_create_sql, - exp.DataType: _datatype_map, - exp.CurrentTime: _curr_time(), - exp.Lateral: _lateral_view, - exp.FromBase64: rename_func("UNBASE64"), - exp.AutoIncrementColumnConstraint: lambda *_: "GENERATED ALWAYS AS IDENTITY", - local_expression.Parameter: _parm_sfx, - local_expression.ToBoolean: _to_boolean, - local_expression.Bracket: _lateral_bracket_sql, - local_expression.MakeDate: rename_func("MAKE_DATE"), - local_expression.TryToDate: try_to_date, - local_expression.TryToNumber: try_to_number, - local_expression.IsInteger: _is_integer, - local_expression.JsonExtractPathText: _parse_json_extract_path_text, - local_expression.BitOr: rename_func("BIT_OR"), - local_expression.ArrayConstructCompact: _array_construct_compact, - local_expression.ArrayIntersection: rename_func("ARRAY_INTERSECT"), - local_expression.ArraySlice: _array_slice, - local_expression.ObjectKeys: rename_func("JSON_OBJECT_KEYS"), - exp.ParseJSON: _parse_json, - local_expression.TimestampFromParts: rename_func("MAKE_TIMESTAMP"), - local_expression.ToDouble: rename_func("DOUBLE"), - exp.Rand: rename_func("RANDOM"), - local_expression.ToVariant: rename_func("TO_JSON"), - local_expression.ToObject: rename_func("TO_JSON"), - exp.ToBase64: rename_func("BASE64"), - local_expression.ToNumber: _to_number, - local_expression.UUID: _uuid, - local_expression.DateTrunc: _parse_date_trunc, - exp.ApproxQuantile: rename_func("APPROX_PERCENTILE"), - exp.TimestampTrunc: timestamptrunc_sql, - exp.Mod: rename_func("MOD"), - exp.NullSafeEQ: lambda self, e: self.binary(e, "<=>"), - exp.If: if_sql(false_value="NULL"), - exp.Command: _to_command, - exp.CurrentDate: _current_date, - exp.Not: _not_sql, - local_expression.ToArray: to_array, - local_expression.ArrayExists: rename_func("EXISTS"), - } - - def preprocess(self, expression: exp.Expression) -> exp.Expression: - fixed_ast = expression.transform(unalias_lca_in_select, copy=False) - return super().preprocess(fixed_ast) - - def format_time(self, expression: exp.Expression, inverse_time_mapping=None, inverse_time_trie=None): - return super().format_time(expression, self.INVERSE_TIME_MAPPING) - - def join_sql(self, expression: exp.Join) -> str: - """Overwrites `join_sql()` in `sqlglot/generator.py` - Added logic to handle Lateral View - """ - op_list = [ - expression.method, - "GLOBAL" if expression.args.get("global") else None, - expression.side, - expression.kind, - expression.hint if self.JOIN_HINTS else None, - ] - - op_sql = " ".join(op for op in op_list if op) - on_sql = self.sql(expression, "on") - using = expression.args.get("using") - - if not on_sql and using: - on_sql = csv(*(self.sql(column) for column in using)) - - this_sql = self.sql(expression, "this") - - if on_sql: - on_sql = self.indent(on_sql, skip_first=True) - space = self.seg(" " * self.pad) if self.pretty else " " - if using: - on_sql = f"{space}USING ({on_sql})" - else: - on_sql = f"{space}ON {on_sql}" - # Added the below elif block to handle Lateral View clause - elif not op_sql and isinstance(expression.this, exp.Lateral): - return f"\n {this_sql}" - elif not op_sql: - return f", {this_sql}" - - op_sql = f"{op_sql} JOIN" if op_sql else "JOIN" - return f"{self.seg(op_sql)} {this_sql}{on_sql}" - - def arrayagg_sql(self, expression: exp.ArrayAgg) -> str: - sql = self.func("ARRAY_AGG", expression.this) - within_group = expression.parent if isinstance(expression.parent, exp.WithinGroup) else None - if not within_group: - return sql - - wg_params = _get_within_group_params(expression, within_group) - if len(wg_params.order_cols) == 1: - order_col, is_order_asc = wg_params.order_cols[0] - if wg_params.agg_col == order_col: - return f"SORT_ARRAY({sql}{'' if is_order_asc else ', FALSE'})" - - named_struct_func = _create_named_struct_for_cmp(wg_params) - comparisons = [] - for i, (_, is_order_asc) in enumerate(wg_params.order_cols): - comparisons.append( - f"WHEN left.sort_by_{i} < right.sort_by_{i} THEN {'-1' if is_order_asc else '1'} " - f"WHEN left.sort_by_{i} > right.sort_by_{i} THEN {'1' if is_order_asc else '-1'}" - ) - - array_sort = self.func( - "ARRAY_SORT", - self.func("ARRAY_AGG", named_struct_func), - f"""(left, right) -> CASE - {' '.join(comparisons)} - ELSE 0 - END""", - ) - return self.func("TRANSFORM", array_sort, "s -> s.value") - - def groupconcat_sql(self, expr: exp.GroupConcat) -> str: - arr_agg = exp.ArrayAgg(this=expr.this) - within_group = expr.parent.copy() if isinstance(expr.parent, exp.WithinGroup) else None - if within_group: - arr_agg.parent = within_group - - return self.func( - "ARRAY_JOIN", - arr_agg, - expr.args.get("separator") or exp.Literal(this="", is_string=True), - ) - - def withingroup_sql(self, expression: exp.WithinGroup) -> str: - agg_expr = expression.this - if isinstance(agg_expr, (exp.ArrayAgg, exp.GroupConcat)): - return self.sql(agg_expr) - - return super().withingroup_sql(expression) - - def split_sql(self, expression: local_expression.Split) -> str: - """ - :param expression: local_expression.Split expression to be parsed - :return: Converted expression (SPLIT) compatible with Databricks - """ - delimiter = " " - # To handle default delimiter - if expression.expression: - delimiter = expression.expression.name - - # Parsing logic to handle String and Table columns - if expression.name and isinstance(expression.name, str): - expr_name = f"'{expression.name}'" - else: - expr_name = expression.args["this"] - return f"""SPLIT({expr_name},'[{delimiter}]')""" - - def delete_sql(self, expression: exp.Delete) -> str: - this = self.sql(expression, "this") - using = self.sql(expression, "using") - where = self.sql(expression, "where") - returning = self.sql(expression, "returning") - limit = self.sql(expression, "limit") - tables = self.expressions(expression, key="tables") - tables = f" {tables}" if tables else "" - - if using: - using = f" USING {using}" if using else "" - where = where.replace("WHERE", "ON") - else: - this = f"FROM {this}" if this else "" - - if self.RETURNING_END: - expression_sql = f" {this}{using}{where}{returning}{limit}" - else: - expression_sql = f"{returning}{this}{where}{limit}" - - if using: - return self.prepend_ctes(expression, f"MERGE INTO {tables}{expression_sql} WHEN MATCHED THEN DELETE;") - - return self.prepend_ctes(expression, f"DELETE{tables}{expression_sql};") - - def converttimezone_sql(self, expression: exp.ConvertTimezone): - func = "CONVERT_TIMEZONE" - expr = expression.args["tgtTZ"] - if len(expression.args) == 3 and expression.args.get("this"): - expr = expression.args["this"] - - result = self.func(func, expression.args["srcTZ"], expr) - if len(expression.args) == 3: - result = self.func(func, expression.args["srcTZ"], expression.args["tgtTZ"], expr) - - return result - - def strtok_sql(self, expression: local_expression.StrTok) -> str: - """ - :param expression: local_expression.StrTok expression to be parsed - :return: Converted expression (SPLIT_PART) compatible with Databricks - """ - # To handle default delimiter - if expression.expression: - delimiter = expression.expression.name - else: - delimiter = " " - - # Handle String and Table columns - if expression.name and isinstance(expression.name, str): - expr_name = f"'{expression.name}'" - else: - expr_name = expression.args["this"] - - # Handle Partition Number - if len(expression.args) == 3 and expression.args.get("partNum"): - part_num = expression.args["partNum"] - else: - part_num = 1 - - return f"SPLIT_PART({expr_name}, '{delimiter}', {part_num})" - - def splitpart_sql(self, expression: local_expression.SplitPart) -> str: - """ - :param expression: local_expression.SplitPart expression to be parsed - :return: Converted expression (SPLIT_PART) compatible with Databricks - """ - expr_name = self.sql(expression.this) - delimiter = self.sql(expression.expression) - part_num = self.sql(expression.args["partNum"]) - return f"SPLIT_PART({expr_name}, {delimiter}, {part_num})" - - def transaction_sql(self, expression: exp.Transaction) -> str: - """ - Skip begin command - :param expression: - :return: Empty string for unsupported operation - """ - return "" - - def rollback_sql(self, expression: exp.Rollback) -> str: - """ - Skip rollback command - :param expression: - :return: Empty string for unsupported operation - """ - return "" - - def commit_sql(self, expression: exp.Commit) -> str: - """ - Skip commit command - :param expression: - :return: Empty string for unsupported operation - """ - return "" - - def command_sql(self, expression: exp.Command) -> str: - """ - Skip any session, stream, task related commands - :param expression: - :return: Empty string for unsupported operations or objects - """ - filtered_commands = [ - "CREATE", - "ALTER", - "DESCRIBE", - "DROP", - "SHOW", - "EXECUTE", - ] - ignored_objects = [ - "STREAM", - "TASK", - "STREAMS", - "TASKS", - "SESSION", - ] - - command = self.sql(expression, "this").upper() - expr = expression.text("expression").strip() - obj = re.split(r"\s+", expr, maxsplit=2)[0].upper() if expr else "" - if command in filtered_commands and obj in ignored_objects: - return "" - return f"{command} {expr}" - - def currenttimestamp_sql(self, _: exp.CurrentTimestamp) -> str: - return self.func("CURRENT_TIMESTAMP") - - def update_sql(self, expression: exp.Update) -> str: - this = self.sql(expression, "this") - set_sql = self.expressions(expression, flat=True) - from_sql = self.sql(expression, "from") - where_sql = self.sql(expression, "where") - returning = self.sql(expression, "returning") - order = self.sql(expression, "order") - limit = self.sql(expression, "limit") - - if from_sql: - from_sql = from_sql.replace("FROM", "USING", 1) - where_sql = where_sql.replace("WHERE", "ON") - - if self.RETURNING_END: - expression_sql = f"{from_sql}{where_sql}{returning}" - else: - expression_sql = f"{returning}{from_sql}{where_sql}" - - if from_sql: - sql = f"MERGE INTO {this}{expression_sql} WHEN MATCHED THEN UPDATE SET {set_sql}{order}{limit}" - else: - sql = f"UPDATE {this} SET {set_sql}{expression_sql}{order}{limit}" - - return self.prepend_ctes(expression, sql) - - def struct_sql(self, expression: exp.Struct) -> str: - expression.set( - "expressions", - [ - ( - exp.alias_( - e.expression, e.name if hasattr(e.this, "is_string") and e.this.is_string else e.this - ) - if isinstance(e, exp.PropertyEQ) - else e - ) - for e in expression.expressions - ], - ) - - return self.function_fallback_sql(expression) - - def anonymous_sql(self: SqlglotDatabricks.Generator, expression: exp.Anonymous) -> str: - if expression.this == "EDITDISTANCE": - return self.func("LEVENSHTEIN", *expression.expressions) - if expression.this == "TO_TIMESTAMP": - return self.sql( - exp.Cast(this=expression.expressions[0], to=exp.DataType(this=exp.DataType.Type.TIMESTAMP)) - ) - - return self.func(self.sql(expression, "this"), *expression.expressions) - - def order_sql(self, expression: exp.Order, flat: bool = False) -> str: - if isinstance(expression.parent, exp.Window): - for ordered_expression in expression.expressions: - if isinstance(ordered_expression, exp.Ordered) and ordered_expression.args.get('desc') is None: - ordered_expression.args['desc'] = False - return super().order_sql(expression, flat) - - def add_column_sql(self, expression: exp.Alter) -> str: - # Final output contains ADD COLUMN before each column - # This function will handle this issue and return the final output - columns = self.expressions(expression, key="actions", flat=True) - return f"ADD COLUMN {columns}" diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/lca_utils.py b/src/databricks/labs/remorph/transpiler/sqlglot/lca_utils.py deleted file mode 100644 index 43eef71a71..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/lca_utils.py +++ /dev/null @@ -1,138 +0,0 @@ -import logging -from collections.abc import Iterable -from pathlib import Path - -from sqlglot import expressions as exp, Dialect -from sqlglot import parse -from sqlglot.errors import ErrorLevel, ParseError, TokenError, UnsupportedError -from sqlglot.expressions import Expression, Select -from sqlglot.optimizer.scope import Scope, build_scope - -from databricks.labs.remorph.transpiler.transpile_status import TranspileError, ErrorKind, ErrorSeverity -from databricks.labs.remorph.transpiler.sqlglot.local_expression import AliasInfo - -logger = logging.getLogger(__name__) - - -def check_for_unsupported_lca( - from_dialect: Dialect, - source_sql: str, - file_path: Path, -) -> TranspileError | None: - """ - Check for presence of unsupported lateral column aliases in window expressions and where clauses - :return: An error if found - """ - try: - all_parsed_expressions: Iterable[Expression | None] = parse( - source_sql, read=from_dialect, error_level=ErrorLevel.RAISE - ) - root_expressions: Iterable[Expression] = [pe for pe in all_parsed_expressions if pe is not None] - except (ParseError, TokenError, UnsupportedError) as e: - logger.warning(f"Error while preprocessing {file_path}: {e}") - return None - - aliases_in_where = set() - aliases_in_window = set() - - for expr in root_expressions: - for select in expr.find_all(exp.Select, bfs=False): - alias_info = _find_aliases_in_select(select) - aliases_in_where.update(_find_invalid_lca_in_where(select, alias_info)) - aliases_in_window.update(_find_invalid_lca_in_window(select, alias_info)) - - if not (aliases_in_where or aliases_in_window): - return None - - err_messages = [f"Unsupported operation found in file {file_path}. Needs manual review of transpiled query."] - if aliases_in_where: - err_messages.append(f"Lateral column aliases `{', '.join(aliases_in_where)}` found in where clause.") - - if aliases_in_window: - err_messages.append(f"Lateral column aliases `{', '.join(aliases_in_window)}` found in window expressions.") - - return TranspileError("UNSUPPORTED_LCA", ErrorKind.ANALYSIS, ErrorSeverity.ERROR, file_path, " ".join(err_messages)) - - -def unalias_lca_in_select(expr: exp.Expression) -> exp.Expression: - if not isinstance(expr, exp.Select): - return expr - - root_select: Scope | None = build_scope(expr) - if not root_select: - return expr - - # We won't search inside nested selects, they will be visited separately - nested_selects = {*root_select.derived_tables, *root_select.subqueries} - alias_info = _find_aliases_in_select(expr) - where_ast: Expression | None = expr.args.get("where") - if where_ast: - for column in where_ast.walk(prune=lambda n: n in nested_selects): - _replace_aliases(column, alias_info) - for window in _find_windows_in_select(expr): - for column in window.walk(): - _replace_aliases(column, alias_info) - return expr - - -def _replace_aliases(column: Expression, alias_info: dict[str, AliasInfo]): - if ( - isinstance(column, exp.Column) - and column.name in alias_info - and not alias_info[column.name].is_same_name_as_column - ): - unaliased_expr = alias_info[column.name].expression - column.replace(unaliased_expr) - for col in unaliased_expr.walk(): - _replace_aliases(col, alias_info) - - -def _find_windows_in_select(select: Select) -> list[exp.Window]: - window_expressions = [] - for expr in select.expressions: - window_expr = expr.find(exp.Window) - if window_expr: - window_expressions.append(window_expr) - return window_expressions - - -def _find_aliases_in_select(select_expr: Select) -> dict[str, AliasInfo]: - aliases = {} - for expr in select_expr.expressions: - if isinstance(expr, exp.Alias): - alias_name = expr.output_name - is_same_name_as_column = False - for column in expr.find_all(exp.Column): - if column.name == alias_name: - is_same_name_as_column = True - break - aliases[alias_name] = AliasInfo(alias_name, expr.unalias().copy(), is_same_name_as_column) - return aliases - - -def _find_invalid_lca_in_where( - select_expr: Select, - aliases: dict[str, AliasInfo], -) -> set[str]: - aliases_in_where = set() - where_ast: Expression | None = select_expr.args.get("where") - if where_ast: - for column in where_ast.find_all(exp.Column): - if column.name in aliases and not aliases[column.name].is_same_name_as_column: - aliases_in_where.add(column.name) - - return aliases_in_where - - -def _find_invalid_lca_in_window( - select_expr: Select, - aliases: dict[str, AliasInfo], -) -> set[str]: - aliases_in_window = set() - windows = _find_windows_in_select(select_expr) - for window in windows: - for column in window.find_all(exp.Column): - if column.name in aliases and not aliases[column.name].is_same_name_as_column: - aliases_in_window.add(column.name) - - return aliases_in_window diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/local_expression.py b/src/databricks/labs/remorph/transpiler/sqlglot/local_expression.py deleted file mode 100644 index e61e97cbdd..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/local_expression.py +++ /dev/null @@ -1,197 +0,0 @@ -from dataclasses import dataclass - -from sqlglot import expressions as exp -from sqlglot.expressions import AggFunc, Condition, Expression, Func - - -class NthValue(AggFunc): - arg_types = {"this": True, "offset": False} - - -class Parameter(Expression): - arg_types = {"this": True, "wrapped": False, "suffix": False} - - -class Collate(Func): - arg_types = {"this": True, "expressions": True} - - -class Bracket(Condition): - arg_types = {"this": True, "expressions": True} - - -class Split(Func): - """ - Redefined Split(sqlglot/expression) class with expression: False to handle default delimiter - Please refer the test case `test_strtok_to_array` -> `select STRTOK_TO_ARRAY('my text is divided')` - """ - - arg_types = {"this": True, "expression": False, "limit": False} - - -class MakeDate(Func): - arg_types = {"this": True, "expression": False, "zone": False} - - -class ConvertTimeZone(Func): - arg_types = {"srcTZ": True, "tgtTZ": True, "this": False} - - -class TryToDate(Func): - arg_types = {"this": True, "format": False} - - -class TryToTimestamp(Func): - arg_types = {"this": True, "format": False} - - -class SplitPart(Func): - arg_types = {"this": True, "expression": False, "partNum": False} - - -class StrTok(Func): - arg_types = {"this": True, "expression": False, "partNum": False} - - -class TryToNumber(Func): - arg_types = {"this": True, "expression": False, "precision": False, "scale": False} - - _sql_names = ["TRY_TO_DECIMAL", "TRY_TO_NUMBER", "TRY_TO_NUMERIC"] - - -class DateFormat(Func): - arg_types = {"this": True, "expression": False} - - -class IsInteger(Func): - pass - - -class JsonExtractPathText(Func): - arg_types = {"this": True, "path_name": True} - - -class BitOr(AggFunc): - pass - - -class ArrayConstructCompact(Func): - arg_types = {"expressions": False} - - is_var_len_args = True - - -class ArrayIntersection(Func): - arg_types = {"this": True, "expression": True} - - -class ArraySlice(Func): - arg_types = {"this": True, "from": True, "to": True} - - -class ObjectKeys(Func): - arg_types = {"this": True} - - -class ToBoolean(Func): - arg_types = {"this": True, "raise_error": False} - - -class ToDouble(Func): - pass - - -class ToObject(Func): - pass - - -class ToNumber(Func): - arg_types = {"this": True, "expression": False, "precision": False, "scale": False} - - _sql_names = ["TO_DECIMAL", "TO_NUMBER", "TO_NUMERIC"] - - -class TimestampFromParts(Func): - arg_types = { - "this": True, - "expression": True, - "day": True, - "hour": True, - "min": True, - "sec": True, - "nanosec": False, - "Zone": False, - } - - -class ToVariant(Func): - pass - - -class UUID(Func): - arg_types = {"this": False, "name": False} - - -class DateTrunc(Func): - arg_types = {"unit": False, "this": True, "zone": False} - - -class Median(Func): - arg_types = {"this": True} - - -class CumeDist(Func): - arg_types = {"this": False} - - -class DenseRank(Func): - arg_types = {"this": False} - - -class Rank(Func): - arg_types = {"this": False} - - -class PercentRank(Func): - arg_types = {"this": False} - - -class Ntile(Func): - arg_types = {"this": True, "is_string": False} - - -class ToArray(Func): - arg_types = {"this": True, "expression": False} - - -@dataclass -class WithinGroupParams: - agg_col: exp.Column - order_cols: list[tuple[exp.Column, bool]] # List of (column, is ascending) - - -@dataclass -class AliasInfo: - name: str - expression: exp.Expression - is_same_name_as_column: bool - - -class MapKeys(Func): - arg_types = {"this": True} - - -class ArrayExists(Func): - arg_types = {"this": True, "expression": True} - - -class Locate(Func): - arg_types = {"substring": True, "this": True, "position": False} - - -class NamedStruct(Func): - arg_types = {"expressions": True} - - -class GetJsonObject(Func): - arg_types = {"this": True, "path": True} diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/__init__.py b/src/databricks/labs/remorph/transpiler/sqlglot/parsers/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/oracle.py b/src/databricks/labs/remorph/transpiler/sqlglot/parsers/oracle.py deleted file mode 100644 index 8922f17ca8..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/oracle.py +++ /dev/null @@ -1,23 +0,0 @@ -from sqlglot.dialects.oracle import Oracle as Orc -from sqlglot.tokens import TokenType - - -class Oracle(Orc): - # Instantiate Oracle Dialect - oracle = Orc() - - class Tokenizer(Orc.Tokenizer): - KEYWORDS = { - **Orc.Tokenizer.KEYWORDS, - 'LONG': TokenType.TEXT, - 'NCLOB': TokenType.TEXT, - 'ROWID': TokenType.TEXT, - 'UROWID': TokenType.TEXT, - 'ANYTYPE': TokenType.TEXT, - 'ANYDATA': TokenType.TEXT, - 'ANYDATASET': TokenType.TEXT, - 'XMLTYPE': TokenType.TEXT, - 'SDO_GEOMETRY': TokenType.TEXT, - 'SDO_TOPO_GEOMETRY': TokenType.TEXT, - 'SDO_GEORASTER': TokenType.TEXT, - } diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/presto.py b/src/databricks/labs/remorph/transpiler/sqlglot/parsers/presto.py deleted file mode 100644 index a0f1e19801..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/presto.py +++ /dev/null @@ -1,202 +0,0 @@ -import logging -from sqlglot.dialects.presto import Presto as presto -from sqlglot import exp -from sqlglot.helper import seq_get -from sqlglot.errors import ParseError -from sqlglot.tokens import TokenType - -from databricks.labs.remorph.transpiler.sqlglot import local_expression - - -logger = logging.getLogger(__name__) - - -def _build_approx_percentile(args: list) -> exp.Expression: - if len(args) == 4: - arg3 = seq_get(args, 3) - try: - number = float(arg3.this) if arg3 is not None else 0 - return exp.ApproxQuantile( - this=seq_get(args, 0), - weight=seq_get(args, 1), - quantile=seq_get(args, 2), - accuracy=exp.Literal(this=f'{int((1/number) * 100)} ', is_string=False), - ) - except ValueError as exc: - raise ParseError(f"Expected a string representation of a number for argument 2, but got {arg3}") from exc - if len(args) == 3: - arg2 = seq_get(args, 2) - try: - number = float(arg2.this) if arg2 is not None else 0 - return exp.ApproxQuantile( - this=seq_get(args, 0), - quantile=seq_get(args, 1), - accuracy=exp.Literal(this=f'{int((1/number) * 100)}', is_string=False), - ) - except ValueError as exc: - raise ParseError(f"Expected a string representation of a number for argument 2, but got {arg2}") from exc - return exp.ApproxQuantile.from_arg_list(args) - - -def _build_any_keys_match(args: list) -> local_expression.ArrayExists: - return local_expression.ArrayExists( - this=local_expression.MapKeys(this=seq_get(args, 0)), expression=seq_get(args, 1) - ) - - -def _build_str_position(args: list) -> local_expression.Locate: - # TODO the 3rd param in presto strpos and databricks locate has different implementation. - # For now we haven't implemented the logic same as presto for 3rd param. - # Users should be vigilant when using 3 param function in presto strpos. - if len(args) == 3: - msg = ( - "*Warning:: The third parameter in Presto's `strpos` function and Databricks' `locate` function " - "have different implementations. Please exercise caution when using the three-parameter version " - "of the `strpos` function in Presto." - ) - logger.warning(msg) - return local_expression.Locate(substring=seq_get(args, 1), this=seq_get(args, 0), position=seq_get(args, 2)) - return local_expression.Locate(substring=seq_get(args, 1), this=seq_get(args, 0)) - - -def _build_array_average(args: list) -> exp.Reduce: - return exp.Reduce( - this=exp.ArrayFilter( - this=seq_get(args, 0), - expression=exp.Lambda( - this=exp.Not(this=exp.Is(this=exp.Identifier(this="x", quoted=False), expression=exp.Null())), - expressions=[exp.Identifier(this="x", quoted=False)], - ), - ), - initial=local_expression.NamedStruct( - expressions=[ - exp.Literal(this="sum", is_string=True), - exp.Cast(this=exp.Literal(this="0", is_string=False), to=exp.DataType(this="DOUBLE")), - exp.Literal(this="cnt", is_string=True), - exp.Literal(this="0", is_string=False), - ], - ), - merge=exp.Lambda( - this=local_expression.NamedStruct( - expressions=[ - exp.Literal(this="sum", is_string=True), - exp.Add( - this=exp.Dot( - this=exp.Identifier(this="acc", quoted=False), - expression=exp.Identifier(this="sum", quoted=False), - ), - expression=exp.Identifier(this="x", quoted=False), - ), - exp.Literal(this="cnt", is_string=True), - exp.Add( - this=exp.Dot( - this=exp.Identifier(this="acc", quoted=False), - expression=exp.Identifier(this="cnt", quoted=False), - ), - expression=exp.Literal(this="1", is_string=False), - ), - ], - ), - expressions=[exp.Identifier(this="acc", quoted=False), exp.Identifier(this="x", quoted=False)], - ), - finish=exp.Lambda( - this=exp.Anonymous( - this="try_divide", - expressions=[ - exp.Dot( - this=exp.Identifier(this="acc", quoted=False), - expression=exp.Identifier(this="sum", quoted=False), - ), - exp.Dot( - this=exp.Identifier(this="acc", quoted=False), - expression=exp.Identifier(this="cnt", quoted=False), - ), - ], - ), - expressions=[exp.Identifier(this="acc", quoted=False)], - ), - ) - - -def _build_json_size(args: list): - return exp.Case( - ifs=[ - exp.If( - this=exp.Like( - this=local_expression.GetJsonObject( - this=exp.Column(this=seq_get(args, 0)), - path=exp.Column(this=seq_get(args, 1)), - ), - expression=exp.Literal(this="{%", is_string=True), - ), - true=exp.ArraySize( - this=exp.Anonymous( - this="from_json", - expressions=[ - local_expression.GetJsonObject( - this=exp.Column(this=seq_get(args, 0)), - path=exp.Column(this=seq_get(args, 1)), - ), - exp.Literal(this="map", is_string=True), - ], - ) - ), - ), - exp.If( - this=exp.Like( - this=local_expression.GetJsonObject( - this=exp.Column(this=seq_get(args, 0)), - path=exp.Column(this=seq_get(args, 1)), - ), - expression=exp.Literal(this="[%", is_string=True), - ), - true=exp.ArraySize( - this=exp.Anonymous( - this="from_json", - expressions=[ - local_expression.GetJsonObject( - this=exp.Column(this=seq_get(args, 0)), - path=exp.Column(this=seq_get(args, 1)), - ), - exp.Literal(this="array", is_string=True), - ], - ) - ), - ), - exp.If( - this=exp.Not( - this=exp.Is( - this=local_expression.GetJsonObject( - this=exp.Column(this=seq_get(args, 0)), - path=exp.Column(this=seq_get(args, 1)), - ), - expression=exp.Null(), - ) - ), - true=exp.Literal(this="0", is_string=False), - ), - ], - default=exp.Null(), - ) - - -class Presto(presto): - - class Parser(presto.Parser): - VALUES_FOLLOWED_BY_PAREN = False - - FUNCTIONS = { - **presto.Parser.FUNCTIONS, - "APPROX_PERCENTILE": _build_approx_percentile, - "STRPOS": _build_str_position, - "ANY_KEYS_MATCH": _build_any_keys_match, - "ARRAY_AVERAGE": _build_array_average, - "JSON_SIZE": _build_json_size, - "FORMAT_DATETIME": local_expression.DateFormat.from_arg_list, - } - - class Tokenizer(presto.Tokenizer): - KEYWORDS = { - **presto.Tokenizer.KEYWORDS, - "JSON": TokenType.TEXT, - } diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/snowflake.py b/src/databricks/labs/remorph/transpiler/sqlglot/parsers/snowflake.py deleted file mode 100644 index 81e5604806..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/parsers/snowflake.py +++ /dev/null @@ -1,535 +0,0 @@ -import logging -import re - -from sqlglot import expressions as exp -from sqlglot.dialects.dialect import build_date_delta as parse_date_delta, build_formatted_time -from sqlglot.dialects.snowflake import Snowflake as SqlglotSnowflake -from sqlglot.errors import TokenError, ParseError -from sqlglot.helper import is_int, seq_get -from sqlglot.optimizer.simplify import simplify_literals -from sqlglot.parser import build_var_map as parse_var_map -from sqlglot.tokens import Token, TokenType -from sqlglot.trie import new_trie - -from databricks.labs.remorph.transpiler.sqlglot import local_expression - -logger = logging.getLogger(__name__) -# pylint: disable=protected-access -""" SF Supported Date and Time Parts: - https://docs.snowflake.com/en/sql-reference/functions-date-time#label-supported-date-time-parts - Covers DATEADD, DATEDIFF, DATE_TRUNC, LAST_DAY -""" -DATE_DELTA_INTERVAL = { - "years": "year", - "year": "year", - "yrs": "year", - "yr": "year", - "yyyy": "year", - "yyy": "year", - "yy": "year", - "y": "year", - "quarters": "quarter", - "quarter": "quarter", - "qtrs": "quarter", - "qtr": "quarter", - "q": "quarter", - "months": "month", - "month": "month", - "mons": "month", - "mon": "month", - "mm": "month", - "weekofyear": "week", - "week": "week", - "woy": "week", - "wy": "week", - "wk": "week", - "w": "week", - "dayofmonth": "day", - "days": "day", - "day": "day", - "dd": "day", - "d": "day", -} - -rank_functions = ( - local_expression.CumeDist, - exp.FirstValue, - exp.LastValue, - local_expression.NthValue, - local_expression.Ntile, -) - - -def _parse_to_timestamp(args: list) -> exp.StrToTime | exp.UnixToTime | exp.TimeStrToTime: - if len(args) == 2: - first_arg, second_arg = args - if second_arg.is_string: - # case: [ , ] - return build_formatted_time(exp.StrToTime, "snowflake", default=True)(args) - return exp.UnixToTime(this=first_arg, scale=second_arg) - - # The first argument might be an expression like 40 * 365 * 86400, so we try to - # reduce it using `simplify_literals` first and then check if it's a Literal. - first_arg = seq_get(args, 0) - if not isinstance(simplify_literals(first_arg, root=True), exp.Literal): - # case: or other expressions such as columns - return exp.TimeStrToTime.from_arg_list(args) - - if first_arg.is_string: - if is_int(first_arg.this): - # case: - return exp.UnixToTime.from_arg_list(args) - - # case: - return build_formatted_time(exp.StrToTime, "snowflake", default=True)(args) - - # case: - return exp.UnixToTime.from_arg_list(args) - - -def _parse_date_add(args: list) -> exp.DateAdd: - return exp.DateAdd(this=seq_get(args, 2), expression=seq_get(args, 1), unit=seq_get(args, 0)) - - -def _parse_split_part(args: list) -> local_expression.SplitPart: - if len(args) != 3: - err_msg = f"Error Parsing args `{args}`. Number of args must be 3, given {len(args)}" - raise ParseError(err_msg) - part_num_literal = seq_get(args, 2) - part_num_if = None - if isinstance(part_num_literal, exp.Literal): - # In Snowflake if the partNumber is 0, it is treated as 1. - # Please refer to https://docs.snowflake.com/en/sql-reference/functions/split_part - if part_num_literal.is_int and int(part_num_literal.name) == 0: - part_num_literal = exp.Literal.number(1) - else: - cond = exp.EQ(this=part_num_literal, expression=exp.Literal.number(0)) - part_num_if = exp.If(this=cond, true=exp.Literal.number(1), false=part_num_literal) - - part_num = part_num_if if part_num_if is not None else part_num_literal - return local_expression.SplitPart(this=seq_get(args, 0), expression=seq_get(args, 1), partNum=part_num) - - -def _div0_to_if(args: list) -> exp.If: - cond = exp.EQ(this=seq_get(args, 1), expression=exp.Literal.number(0)) - true = exp.Literal.number(0) - false = exp.Div(this=seq_get(args, 0), expression=seq_get(args, 1)) - return exp.If(this=cond, true=true, false=false) - - -def _div0null_to_if(args: list) -> exp.If: - cond = exp.Or( - this=exp.EQ(this=seq_get(args, 1), expression=exp.Literal.number(0)), - expression=exp.Is(this=seq_get(args, 1), expression=exp.Null()), - ) - true = exp.Literal.number(0) - false = exp.Div(this=seq_get(args, 0), expression=seq_get(args, 1)) - return exp.If(this=cond, true=true, false=false) - - -def _parse_json_extract_path_text(args: list) -> local_expression.JsonExtractPathText: - if len(args) != 2: - err_message = f"Error Parsing args `{args}`. Number of args must be 2, given {len(args)}" - raise ParseError(err_message) - return local_expression.JsonExtractPathText(this=seq_get(args, 0), path_name=seq_get(args, 1)) - - -def _parse_array_contains(args: list) -> exp.ArrayContains: - if len(args) != 2: - err_message = f"Error Parsing args `{args}`. Number of args must be 2, given {len(args)}" - raise ParseError(err_message) - return exp.ArrayContains(this=seq_get(args, 1), expression=seq_get(args, 0)) - - -def _parse_dayname(args: list) -> local_expression.DateFormat: - """ - * E, EE, EEE, returns short day name (Mon) - * EEEE, returns full day name (Monday) - :param args: node expression - :return: DateFormat with `E` format - """ - if len(args) != 1: - err_message = f"Error Parsing args `{args}`. Number of args must be 1, given {len(args)}" - raise ParseError(err_message) - return local_expression.DateFormat(this=seq_get(args, 0), expression=exp.Literal.string("E")) - - -def _parse_trytonumber(args: list) -> local_expression.TryToNumber: - if len(args) == 1: - msg = f"""*Warning:: Parsing args `{args}`: - * `format` is missing - * assuming defaults `precision`[38] and `scale`[0] - """ - logger.warning(msg) - elif len(args) == 3: - msg = f"""Error Parsing args `{args}`: - * `format` is required - * `precision` and `scale` both are required [if specified] - """ - raise ParseError(msg) - - if len(args) == 4: - return local_expression.TryToNumber( - this=seq_get(args, 0), expression=seq_get(args, 1), precision=seq_get(args, 2), scale=seq_get(args, 3) - ) - - return local_expression.TryToNumber(this=seq_get(args, 0), expression=seq_get(args, 1)) - - -def _parse_monthname(args: list) -> local_expression.DateFormat: - if len(args) != 1: - err_message = f"Error Parsing args `{args}`. Number of args must be 1, given {len(args)}" - raise ParseError(err_message) - return local_expression.DateFormat(this=seq_get(args, 0), expression=exp.Literal.string("MMM")) - - -def _parse_object_construct(args: list) -> exp.StarMap | exp.Struct: - expression = parse_var_map(args) - - if isinstance(expression, exp.StarMap): - return exp.Struct(expressions=[expression.this]) - - return exp.Struct( - expressions=[ - exp.PropertyEQ(this=k.this, expression=v) for k, v in zip(expression.keys, expression.values, strict=False) - ] - ) - - -def _parse_to_boolean(args: list, *, error=False) -> local_expression.ToBoolean: - this_arg = seq_get(args, 0) - return local_expression.ToBoolean(this=this_arg, raise_error=exp.Literal.number(1 if error else 0)) - - -def _parse_tonumber(args: list) -> local_expression.ToNumber: - if len(args) > 4: - error_msg = f"""Error Parsing args args: - * Number of args cannot be more than `4`, given `{len(args)}` - """ - raise ParseError(error_msg) - - match len(args): - case 1: - msg = ( - "Precision and Scale are not specified, assuming defaults `precision`[38] and `scale`[0]. " - "If Format is not specified, it will be inferred as simple cast as decimal" - ) - logger.warning(msg) - return local_expression.ToNumber(this=seq_get(args, 0)) - case 3: - msg = "If Format is not specified, it will be inferred as simple cast as decimal" - logger.warning(msg) - return local_expression.ToNumber(this=seq_get(args, 0), precision=seq_get(args, 1), scale=seq_get(args, 2)) - case 4: - return local_expression.ToNumber( - this=seq_get(args, 0), expression=seq_get(args, 1), precision=seq_get(args, 2), scale=seq_get(args, 3) - ) - - return local_expression.ToNumber(this=seq_get(args, 0), expression=seq_get(args, 1)) - - -def contains_expression(expr, target_type): - if isinstance(expr, target_type): - return True - if hasattr(expr, 'this') and contains_expression(expr.this, target_type): - return True - if hasattr(expr, 'expressions'): - for sub_expr in expr.expressions: - if contains_expression(sub_expr, target_type): - return True - return False - - -def _parse_sha2(args: list) -> exp.SHA2: - if len(args) == 1: - return exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)) - return exp.SHA2(this=seq_get(args, 0), length=seq_get(args, 1)) - - -def _parse_last_day(args: list) -> exp.LastDay | exp.DateSub: - if len(args) == 1: - return exp.LastDay.from_arg_list(args) - - date_part = seq_get(args, 1) - if isinstance(date_part, exp.Literal): - date_part = DATE_DELTA_INTERVAL.get(date_part.this.lower(), None) - elif isinstance(date_part, exp.Column): - date_part = DATE_DELTA_INTERVAL.get(date_part.name.lower(), None) - - if date_part is None or date_part.lower() not in ('year', 'quarter', 'month', 'week'): - raise ParseError(f'Invalid date part {date_part} for last_day') - - date_trunc_expr = local_expression.DateTrunc(this=seq_get(args, 0), unit=exp.Literal.string(date_part)) - # Add one date part - date_add_expr = parse_date_delta(exp.DateAdd, unit_mapping=DATE_DELTA_INTERVAL)( - [exp.Literal.string(date_part), exp.Literal.number(1), date_trunc_expr] - ) - - # Subtract one day - date_sub_expr = parse_date_delta(exp.DateSub, unit_mapping=DATE_DELTA_INTERVAL)( - [exp.Literal.string('DAY'), exp.Literal.number(1), date_add_expr] - ) - - return date_sub_expr - - -class Snowflake(SqlglotSnowflake): - # Instantiate Snowflake Dialect - snowflake = SqlglotSnowflake() - - class Tokenizer(SqlglotSnowflake.Tokenizer): - - COMMENTS = ["--", "//", ("/*", "*/")] - STRING_ESCAPES = ["\\", "'"] - - CUSTOM_TOKEN_MAP = { - r"(?i)CREATE\s+OR\s+REPLACE\s+PROCEDURE": TokenType.PROCEDURE, - r"(?i)var\s+\w+\s+=\s+\w+?": TokenType.VAR, - } - - SINGLE_TOKENS = { - **SqlglotSnowflake.Tokenizer.SINGLE_TOKENS, - "&": TokenType.PARAMETER, # https://docs.snowflake.com/en/user-guide/snowsql-use#substituting-variables-in-a-session - "!": TokenType.COMMAND, - } - - KEYWORDS = {**SqlglotSnowflake.Tokenizer.KEYWORDS} - # DEC is not a reserved keyword in Snowflake it can be used as table alias - KEYWORDS.pop("DEC") - - @classmethod - def update_keywords(cls, new_key_word_dict): - cls.KEYWORDS = new_key_word_dict | cls.KEYWORDS - - @classmethod - def merge_trie(cls, parent_trie, curr_trie): - merged_trie = {} - logger.debug(f"The Parent Trie is {parent_trie}") - logger.debug(f"The Input Trie is {curr_trie}") - for key in set(parent_trie.keys()) | set(curr_trie.keys()): # Get all unique keys from both tries - if key in parent_trie and key in curr_trie: # If the key is in both tries, merge the subtries - if isinstance(parent_trie[key], dict) and isinstance(curr_trie[key], dict): - logger.debug(f"New trie inside the key is {curr_trie}") - logger.debug(f"Parent trie inside the key is {parent_trie}") - merged_trie[key] = cls.merge_trie(parent_trie[key], curr_trie[key]) - logger.debug(f"Merged Trie is {merged_trie}") - elif isinstance(parent_trie[key], dict): - merged_trie[key] = parent_trie[key] - else: - merged_trie[key] = curr_trie[key] - elif key in parent_trie: # If the key is only in trie1, add it to the merged trie - merged_trie[key] = parent_trie[key] - else: # If the key is only in trie2, add it to the merged trie - merged_trie[key] = curr_trie[key] - return merged_trie - - @classmethod - def update_keyword_trie( - cls, - curr_trie, - parent_trie=None, - ): - if parent_trie is None: - parent_trie = cls._KEYWORD_TRIE - cls.KEYWORD_TRIE = cls.merge_trie(parent_trie, curr_trie) - - def match_strings_token_dict(self, string, pattern_dict): - result_dict = {} - for pattern in pattern_dict: - matches = re.finditer(pattern, string, re.MULTILINE | re.IGNORECASE | re.DOTALL) - for _, match in enumerate(matches, start=1): - result_dict[match.group().upper()] = pattern_dict[pattern] - return result_dict - - def match_strings_list(self, string, pattern_dict): - result = [] - for pattern in pattern_dict: - matches = re.finditer(pattern, string, re.MULTILINE | re.IGNORECASE | re.DOTALL) - for _, match in enumerate(matches, start=1): - result.append(match.group().upper()) - return result - - def tokenize(self, sql: str) -> list[Token]: - """Returns a list of tokens corresponding to the SQL string `sql`.""" - self.reset() - self.sql = sql - # Update Keywords - ref_dict = self.match_strings_token_dict(sql, self.CUSTOM_TOKEN_MAP) - self.update_keywords(ref_dict) - # Update Keyword Trie - custom_trie = new_trie(self.match_strings_list(sql, self.CUSTOM_TOKEN_MAP)) - logger.debug( - f"The New Trie after adding the REF, VAR and IF ELSE blocks " - f"based on {self.CUSTOM_TOKEN_MAP}, is \n\n {custom_trie}" - ) - self.update_keyword_trie(custom_trie) - logger.debug(f"Updated New Trie is {custom_trie}") - # Parent Code - self.size = len(sql) - try: - self._scan() - except Exception as e: - start = self._current - 50 - end = self._current + 50 - start = start if start > 0 else 0 - end = end if end < self.size else self.size - 1 - context = self.sql[start:end] - msg = f"Error tokenizing '{context}'" - raise TokenError(msg) from e - return self.tokens - - class Parser(SqlglotSnowflake.Parser): - FUNCTIONS = { - **SqlglotSnowflake.Parser.FUNCTIONS, - "ARRAY_AGG": exp.ArrayAgg.from_arg_list, - "STRTOK_TO_ARRAY": local_expression.Split.from_arg_list, - "DATE_FROM_PARTS": local_expression.MakeDate.from_arg_list, - "CONVERT_TIMEZONE": local_expression.ConvertTimeZone.from_arg_list, - "TRY_TO_DATE": local_expression.TryToDate.from_arg_list, - "TRY_TO_TIMESTAMP": local_expression.TryToTimestamp.from_arg_list, - "STRTOK": local_expression.StrTok.from_arg_list, - "SPLIT_PART": _parse_split_part, - "TIMESTAMPADD": _parse_date_add, - "TRY_TO_DECIMAL": _parse_trytonumber, - "TRY_TO_NUMBER": _parse_trytonumber, - "TRY_TO_NUMERIC": _parse_trytonumber, - "DATEADD": parse_date_delta(exp.DateAdd, unit_mapping=DATE_DELTA_INTERVAL), - "DATEDIFF": parse_date_delta(exp.DateDiff, unit_mapping=DATE_DELTA_INTERVAL), - "IS_INTEGER": local_expression.IsInteger.from_arg_list, - "DIV0": _div0_to_if, - "DIV0NULL": _div0null_to_if, - "JSON_EXTRACT_PATH_TEXT": _parse_json_extract_path_text, - "BITOR_AGG": local_expression.BitOr.from_arg_list, - "ARRAY_CONTAINS": _parse_array_contains, - "DAYNAME": _parse_dayname, - "BASE64_ENCODE": exp.ToBase64.from_arg_list, - "BASE64_DECODE_STRING": exp.FromBase64.from_arg_list, - "TRY_BASE64_DECODE_STRING": exp.FromBase64.from_arg_list, - "ARRAY_CONSTRUCT_COMPACT": local_expression.ArrayConstructCompact.from_arg_list, - "ARRAY_INTERSECTION": local_expression.ArrayIntersection.from_arg_list, - "ARRAY_SLICE": local_expression.ArraySlice.from_arg_list, - "MONTHNAME": _parse_monthname, - "MONTH_NAME": _parse_monthname, - "OBJECT_CONSTRUCT": _parse_object_construct, - "OBJECT_KEYS": local_expression.ObjectKeys.from_arg_list, - "TRY_PARSE_JSON": exp.ParseJSON.from_arg_list, - "TIMEDIFF": parse_date_delta(exp.DateDiff, unit_mapping=DATE_DELTA_INTERVAL), - "TIMESTAMPDIFF": parse_date_delta(exp.DateDiff, unit_mapping=DATE_DELTA_INTERVAL), - "TIMEADD": _parse_date_add, - "TO_BOOLEAN": lambda args: _parse_to_boolean(args, error=True), - "TO_DECIMAL": _parse_tonumber, - "TO_DOUBLE": local_expression.ToDouble.from_arg_list, - "TO_NUMBER": _parse_tonumber, - "TO_NUMERIC": _parse_tonumber, - "TO_OBJECT": local_expression.ToObject.from_arg_list, - "TO_TIME": _parse_to_timestamp, - "TIMESTAMP_FROM_PARTS": local_expression.TimestampFromParts.from_arg_list, - "TO_VARIANT": local_expression.ToVariant.from_arg_list, - "TRY_TO_BOOLEAN": lambda args: _parse_to_boolean(args, error=False), - "UUID_STRING": local_expression.UUID.from_arg_list, - "SYSDATE": exp.CurrentTimestamp.from_arg_list, - "TRUNC": lambda args: local_expression.DateTrunc(unit=seq_get(args, 1), this=seq_get(args, 0)), - "APPROX_PERCENTILE": exp.ApproxQuantile.from_arg_list, - "NTH_VALUE": local_expression.NthValue.from_arg_list, - "MEDIAN": local_expression.Median.from_arg_list, - "CUME_DIST": local_expression.CumeDist.from_arg_list, - "DENSE_RANK": local_expression.DenseRank.from_arg_list, - "RANK": local_expression.Rank.from_arg_list, - "PERCENT_RANK": local_expression.PercentRank.from_arg_list, - "NTILE": local_expression.Ntile.from_arg_list, - "TO_ARRAY": local_expression.ToArray.from_arg_list, - "SHA2": _parse_sha2, - "LAST_DAY": _parse_last_day, - "ARRAY_FLATTEN": exp.Flatten.from_arg_list, - } - - FUNCTION_PARSERS = { - **SqlglotSnowflake.Parser.FUNCTION_PARSERS, - "LISTAGG": lambda self: self._parse_list_agg(), - } - - PLACEHOLDER_PARSERS = { - **SqlglotSnowflake.Parser.PLACEHOLDER_PARSERS, - TokenType.PARAMETER: lambda self: self._parse_parameter(), - } - - FUNC_TOKENS = {*SqlglotSnowflake.Parser.FUNC_TOKENS, TokenType.COLLATE} - - COLUMN_OPERATORS = { - **SqlglotSnowflake.Parser.COLUMN_OPERATORS, - } - - TIMESTAMPS: set[TokenType] = SqlglotSnowflake.Parser.TIMESTAMPS.copy() - {TokenType.TIME} - - RANGE_PARSERS = { - **SqlglotSnowflake.Parser.RANGE_PARSERS, - } - - ALTER_PARSERS = {**SqlglotSnowflake.Parser.ALTER_PARSERS} - - def _parse_list_agg(self) -> exp.GroupConcat: - if self._match(TokenType.DISTINCT): - args: list[exp.Expression] = [self.expression(exp.Distinct, expressions=[self._parse_conjunction()])] - if self._match(TokenType.COMMA): - args.extend(self._parse_csv(self._parse_conjunction)) - else: - args = self._parse_csv(self._parse_conjunction) - - return self.expression(exp.GroupConcat, this=args[0], separator=seq_get(args, 1)) - - def _parse_types( - self, check_func: bool = False, schema: bool = False, allow_identifiers: bool = True - ) -> exp.Expression | None: - this = super()._parse_types(check_func=check_func, schema=schema, allow_identifiers=allow_identifiers) - # https://docs.snowflake.com/en/sql-reference/data-types-numeric Numeric datatype alias - if ( - isinstance(this, exp.DataType) - and this.is_type("numeric", "decimal", "number", "integer", "int", "smallint", "bigint") - and not this.expressions - ): - return exp.DataType.build("DECIMAL(38,0)") - return this - - def _parse_parameter(self): - wrapped = self._match(TokenType.L_BRACE) - this = self._parse_var() or self._parse_identifier() or self._parse_primary() - self._match(TokenType.R_BRACE) - suffix: exp.Expression | None = None - if not self._match(TokenType.SPACE) or self._match(TokenType.DOT): - suffix = self._parse_var() or self._parse_identifier() or self._parse_primary() - - return self.expression(local_expression.Parameter, this=this, wrapped=wrapped, suffix=suffix) - - def _parse_window(self, this: exp.Expression | None, alias: bool = False) -> exp.Expression | None: - window = super()._parse_window(this=this, alias=alias) - # Adding default window frame for the rank-related functions in snowflake - if window and contains_expression(window.this, rank_functions) and window.args.get('spec') is None: - window.args['spec'] = self.expression( - exp.WindowSpec, - kind="ROWS", - start="UNBOUNDED", - start_side="PRECEDING", - end="UNBOUNDED", - end_side="FOLLOWING", - ) - return window - - def _parse_alter_table_add(self) -> list[exp.Expression]: - index = self._index - 1 - if self._match_set(self.ADD_CONSTRAINT_TOKENS, advance=False): - return self._parse_csv( - lambda: self.expression(exp.AddConstraint, expressions=self._parse_csv(self._parse_constraint)) - ) - - self._retreat(index) - if not self.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN and self._match_text_seq("ADD"): - return self._parse_wrapped_csv(self._parse_field_def, optional=True) - - if self._match_text_seq("ADD", "COLUMN"): - schema = self._parse_schema() - if schema: - return [schema] - # return self._parse_csv in case of COLUMNS are not enclosed in brackets () - return self._parse_csv(self._parse_field_def) - - return self._parse_wrapped_csv(self._parse_add_column, optional=True) diff --git a/src/databricks/labs/remorph/transpiler/sqlglot/sqlglot_engine.py b/src/databricks/labs/remorph/transpiler/sqlglot/sqlglot_engine.py deleted file mode 100644 index 13787aa8e2..0000000000 --- a/src/databricks/labs/remorph/transpiler/sqlglot/sqlglot_engine.py +++ /dev/null @@ -1,199 +0,0 @@ -import logging -import typing as t -from collections.abc import Iterable -from dataclasses import dataclass -from pathlib import Path - -from sqlglot import expressions as exp, parse, transpile, Dialect -from sqlglot.errors import ErrorLevel, ParseError, TokenError, UnsupportedError -from sqlglot.expressions import Expression -from sqlglot.tokens import Token, TokenType - -from databricks.labs.remorph.config import TranspileResult, TranspileConfig -from databricks.labs.remorph.helpers.string_utils import format_error_message -from databricks.labs.remorph.transpiler.sqlglot import lca_utils -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import SQLGLOT_DIALECTS -from databricks.labs.remorph.transpiler.transpile_status import TranspileError, ErrorKind, ErrorSeverity -from databricks.labs.remorph.transpiler.transpile_engine import TranspileEngine - -logger = logging.getLogger(__name__) - - -@dataclass -class ParsedExpression: - original_sql: str - parsed_expression: Expression - - -@dataclass -class ParserProblem: - original_sql: str - transpile_error: TranspileError - - -class SqlglotEngine(TranspileEngine): - - @property - def supported_dialects(self) -> list[str]: - return sorted(SQLGLOT_DIALECTS.keys()) - - def _partial_transpile( - self, - read_dialect: Dialect, - write_dialect: Dialect, - source_code: str, - file_path: Path, - ) -> tuple[list[str], list[ParserProblem]]: - transpiled_sqls: list[str] = [] - parsed_expressions, problem_list = self.safe_parse(read_dialect, source_code, file_path) - for parsed_expression in parsed_expressions: - try: - transpiled_sql = write_dialect.generate(parsed_expression.parsed_expression, pretty=True) - # Checking if the transpiled SQL is a comment and raise an error - if transpiled_sql.startswith("--"): - raise UnsupportedError("Unsupported SQL") - transpiled_sqls.append(transpiled_sql) - except TokenError as e: - error_msg = format_error_message("Token Error", e, parsed_expression.original_sql) - error = TranspileError("TOKEN_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problem_list.append(ParserProblem(parsed_expression.original_sql, error)) - except ParseError as e: - error_msg = format_error_message("Parsing Error", e, parsed_expression.original_sql) - error = TranspileError("PARSE_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problem_list.append(ParserProblem(parsed_expression.original_sql, error)) - except UnsupportedError as e: - error_msg = format_error_message("Unsupported SQL Error", e, parsed_expression.original_sql) - error = TranspileError("UNSUPPORTED_SQL", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problem_list.append(ParserProblem(parsed_expression.original_sql, error)) - return transpiled_sqls, problem_list - - async def initialize(self, config: TranspileConfig) -> None: - pass - - async def shutdown(self) -> None: - pass - - async def transpile( - self, source_dialect: str, target_dialect: str, source_code: str, file_path: Path - ) -> TranspileResult: - read_dialect = get_dialect(source_dialect) - error: TranspileError | None = self._check_supported(read_dialect, source_code, file_path) - if error: - return TranspileResult(source_code, 1, [error]) - write_dialect = get_dialect(target_dialect) - try: - transpiled_expressions = transpile( - source_code, read=read_dialect, write=write_dialect, pretty=True, error_level=ErrorLevel.RAISE - ) - transpiled_code = "\n".join(transpiled_expressions) - return TranspileResult(transpiled_code, len(transpiled_expressions), []) - except (ParseError, TokenError, UnsupportedError) as e: - logger.error(f"Exception caught for file {file_path!s}: {e}") - transpiled_expressions, problems = self._partial_transpile( - read_dialect, write_dialect, source_code, file_path - ) - transpiled_code = "\n".join(transpiled_expressions) - return TranspileResult(transpiled_code, 1, [problem.transpile_error for problem in problems]) - - def parse( - self, source_dialect: str, source_sql: str, file_path: Path - ) -> tuple[list[Expression | None] | None, TranspileError | None]: - expression = None - error = None - try: - expression = parse(source_sql, read=source_dialect, error_level=ErrorLevel.IMMEDIATE) - except TokenError as e: - error_msg = format_error_message("Token Error", e, source_sql) - error = TranspileError("TOKEN_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - except ParseError as e: - error_msg = format_error_message("Parsing Error", e, source_sql) - error = TranspileError("PARSE_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - except UnsupportedError as e: - error_msg = format_error_message("Unsupported SQL Error", e, source_sql) - error = TranspileError("UNSUPPORTED_SQL", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - return expression, error - - def analyse_table_lineage( - self, source_dialect: str, source_code: str, file_path: Path - ) -> Iterable[tuple[str, str]]: - parsed_expression, _ = self.parse(source_dialect, source_code, file_path) - if parsed_expression is not None: - for expr in parsed_expression: - child: str = str(file_path) - if expr is not None: - # TODO: fix possible issue where the file reference is lost (if we have a 'create') - for change in expr.find_all(exp.Create, exp.Insert, exp.Merge, bfs=False): - child = self._find_root_table(change) - - for query in expr.find_all(exp.Select, exp.Join, exp.With, bfs=False): - table = self._find_root_table(query) - if table: - yield table, child - - def safe_parse( - self, read_dialect: Dialect, source_code: str, file_path: Path - ) -> tuple[list[ParsedExpression], list[ParserProblem]]: - try: - tokens = read_dialect.tokenize(sql=source_code) - return self._safe_parse(read_dialect, tokens, file_path) - except TokenError as e: - error_msg = format_error_message("Token error", e, source_code) - error = TranspileError("TOKEN_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - return [], [ParserProblem(source_code, error)] - - def _safe_parse( - self, read_dialect: Dialect, all_tokens: list[Token], file_path: Path - ) -> tuple[list[ParsedExpression], list[ParserProblem]]: - chunks = self._make_chunks(all_tokens) - parsed_expressions: list[ParsedExpression] = [] - problems: list[ParserProblem] = [] - parser_opts = {"error_level": ErrorLevel.RAISE} - parser = read_dialect.parser(**parser_opts) - for sql, tokens in chunks: - try: - expressions = parser.parse(tokens) - expression = t.cast(Expression, expressions[0]) - parsed_expressions.append(ParsedExpression(sql, expression)) - except TokenError as e: - error_msg = format_error_message("Token error", e, sql) - error = TranspileError("TOKEN_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problems.append(ParserProblem(sql, error)) - except ParseError as e: - error_msg = format_error_message("Parsing error", e, sql) - error = TranspileError("PARSE_ERROR", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problems.append(ParserProblem(sql, error)) - except UnsupportedError as e: - error_msg = format_error_message("Unsupported SQL error", e, sql) - error = TranspileError("UNSUPPORTED_SQL", ErrorKind.PARSING, ErrorSeverity.ERROR, file_path, error_msg) - problems.append(ParserProblem(sql, error)) - finally: - parser.reset() - return parsed_expressions, problems - - @staticmethod - def _make_chunks(tokens: list[Token]) -> list[tuple[str, list[Token]]]: - chunks: list[tuple[str, list[Token]]] = [] - current_chunk: list[Token] = [] - # Split tokens into chunks based on semicolons(or other separators) - # Need to define the separator in Class Tokenizer - for token in tokens: - current_chunk.append(token) - if token.token_type in {TokenType.SEMICOLON}: - original_sql = " ".join([token.text for token in current_chunk]).strip() - chunks.append((original_sql, current_chunk)) - # reset - current_chunk = [] - # don't forget the last chunk - if current_chunk: - original_sql = " ".join([token.text for token in current_chunk]).strip() - chunks.append((original_sql, current_chunk)) - return chunks - - @staticmethod - def _find_root_table(expression) -> str: - table = expression.find(exp.Table, bfs=False) - return table.name if table else "" - - def _check_supported(self, source_dialect: Dialect, source_code: str, file_path: Path) -> TranspileError | None: - return lca_utils.check_for_unsupported_lca(source_dialect, source_code, file_path) diff --git a/src/databricks/labs/remorph/transpiler/transpile_engine.py b/src/databricks/labs/remorph/transpiler/transpile_engine.py index 9c801fa660..284f9874c3 100644 --- a/src/databricks/labs/remorph/transpiler/transpile_engine.py +++ b/src/databricks/labs/remorph/transpiler/transpile_engine.py @@ -7,23 +7,6 @@ class TranspileEngine(abc.ABC): - @classmethod - def load_engine(cls, transpiler_config_path: Path) -> TranspileEngine: - # TODO remove this once sqlglot transpiler is pluggable - if str(transpiler_config_path) == "sqlglot": - # pylint: disable=import-outside-toplevel, cyclic-import - from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine - - return SqlglotEngine() - if not transpiler_config_path.exists(): - raise ValueError( - f"Error: Invalid value for '--transpiler-config-path': '{str(transpiler_config_path)}', file does not exist." - ) - # pylint: disable=import-outside-toplevel, cyclic-import - from databricks.labs.remorph.transpiler.lsp.lsp_engine import LSPEngine - - return LSPEngine.from_config_path(transpiler_config_path) - @abc.abstractmethod async def initialize(self, config: TranspileConfig) -> None: ... diff --git a/tests/integration/reconcile/query_builder/test_execute.py b/tests/integration/reconcile/query_builder/test_execute.py index 80f294746d..3374245559 100644 --- a/tests/integration/reconcile/query_builder/test_execute.py +++ b/tests/integration/reconcile/query_builder/test_execute.py @@ -14,7 +14,7 @@ ReconcileMetadataConfig, ReconcileConfig, ) -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.connectors.data_source import MockDataSource from databricks.labs.remorph.reconcile.connectors.databricks import DatabricksDataSource from databricks.labs.remorph.reconcile.connectors.snowflake import SnowflakeDataSource diff --git a/tests/integration/reconcile/query_builder/test_sampling_query.py b/tests/integration/reconcile/query_builder/test_sampling_query.py index d650494878..a010331d58 100644 --- a/tests/integration/reconcile/query_builder/test_sampling_query.py +++ b/tests/integration/reconcile/query_builder/test_sampling_query.py @@ -1,6 +1,6 @@ from pyspark.sql.types import IntegerType, StringType, StructField, StructType -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.query_builder.sampling_query import ( SamplingQueryBuilder, ) diff --git a/tests/integration/reconcile/test_aggregates_recon_capture.py b/tests/integration/reconcile/test_aggregates_recon_capture.py index 5bb40e5f6c..a07b1761c3 100644 --- a/tests/integration/reconcile/test_aggregates_recon_capture.py +++ b/tests/integration/reconcile/test_aggregates_recon_capture.py @@ -3,6 +3,7 @@ from pyspark.sql import Row, SparkSession +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.config import DatabaseConfig, ReconcileMetadataConfig from databricks.labs.remorph.reconcile.recon_capture import ( ReconCapture, @@ -14,7 +15,6 @@ ) from databricks.labs.remorph.reconcile.recon_capture import generate_final_reconcile_aggregate_output from tests.integration.reconcile.test_aggregates_reconcile import expected_reconcile_output_dict, expected_rule_output -from tests.unit.conftest import get_dialect def remove_directory_recursively(directory_path): diff --git a/tests/integration/reconcile/test_aggregates_reconcile.py b/tests/integration/reconcile/test_aggregates_reconcile.py index 4b907e5af9..639871f76e 100644 --- a/tests/integration/reconcile/test_aggregates_reconcile.py +++ b/tests/integration/reconcile/test_aggregates_reconcile.py @@ -9,8 +9,8 @@ from pyspark.testing import assertDataFrameEqual from pyspark.sql import Row +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.config import DatabaseConfig, ReconcileMetadataConfig -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.data_source import MockDataSource from databricks.labs.remorph.reconcile.execute import Reconciliation, main from databricks.labs.remorph.reconcile.recon_config import ( diff --git a/tests/integration/reconcile/test_recon_capture.py b/tests/integration/reconcile/test_recon_capture.py index c33ebf11ad..14daebcd5b 100644 --- a/tests/integration/reconcile/test_recon_capture.py +++ b/tests/integration/reconcile/test_recon_capture.py @@ -7,8 +7,8 @@ from pyspark.sql.functions import countDistinct from pyspark.sql.types import BooleanType, StringType, StructField, StructType +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.config import DatabaseConfig, ReconcileMetadataConfig -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.exception import WriteToTableException, ReadAndWriteWithVolumeException from databricks.labs.remorph.reconcile.recon_capture import ( ReconCapture, diff --git a/tests/integration/reconcile/test_schema_compare.py b/tests/integration/reconcile/test_schema_compare.py index ce1537e808..eb8673c000 100644 --- a/tests/integration/reconcile/test_schema_compare.py +++ b/tests/integration/reconcile/test_schema_compare.py @@ -1,8 +1,8 @@ import pytest -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.recon_config import ColumnMapping, Schema, Table from databricks.labs.remorph.reconcile.schema_compare import SchemaCompare +from databricks.labs.remorph.reconcile.utils import get_dialect def snowflake_databricks_schema(): diff --git a/tests/resources/functional/oracle/test_long_datatype/test_long_datatype_1.sql b/tests/resources/functional/oracle/test_long_datatype/test_long_datatype_1.sql deleted file mode 100644 index 9ff4e4d587..0000000000 --- a/tests/resources/functional/oracle/test_long_datatype/test_long_datatype_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- oracle sql: -SELECT cast(col1 as long) AS col1 FROM dual; - --- databricks sql: -SELECT CAST(COL1 AS STRING) AS COL1 FROM DUAL; diff --git a/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_1.sql b/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_1.sql deleted file mode 100644 index 439e2a252a..0000000000 --- a/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_1.sql +++ /dev/null @@ -1,15 +0,0 @@ --- presto sql: -SELECT - any_keys_match( - map(array ['a', 'b', 'c'], array [1, 2, 3]), - x -> x = 'a' - ) as col; - --- databricks sql: -SELECT - EXISTS( - MAP_KEYS( - MAP_FROM_ARRAYS(ARRAY('a', 'b', 'c'), ARRAY(1, 2, 3)) - ), - x -> x = 'a' - ) AS col; diff --git a/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_2.sql b/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_2.sql deleted file mode 100644 index a7afbe212a..0000000000 --- a/tests/resources/functional/presto/test_any_keys_match/test_any_keys_match_2.sql +++ /dev/null @@ -1,25 +0,0 @@ --- presto sql: -SELECT - *, - any_keys_match( - metadata, - k -> ( - k LIKE 'config_%' - OR k = 'active' - ) - ) AS has_config_or_active -FROM - your_table; - --- databricks sql: -SELECT - *, - EXISTS( - MAP_KEYS(metadata), - k -> ( - k LIKE 'config_%' - OR k = 'active' - ) - ) AS has_config_or_active -FROM - your_table; diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_1.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_1.sql deleted file mode 100644 index a123ba3288..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, 0.5) FROM people; - --- databricks sql: -SELECT approx_percentile(height, 0.5) FROM people; diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_2.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_2.sql deleted file mode 100644 index e0e9b94e01..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, 0.5, 0.01) FROM people; - --- databricks sql: -SELECT approx_percentile(height, 0.5, 10000) FROM people; diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_3.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_3.sql deleted file mode 100644 index 5b6981dd1a..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, ARRAY[0.25, 0.5, 0.75]) FROM people; - --- databricks sql: -SELECT approx_percentile(height, ARRAY(0.25, 0.5, 0.75)) FROM people; diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_4.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_4.sql deleted file mode 100644 index 8b156243d1..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, ARRAY[0.25, 0.5, 0.75], 0.5) FROM people; - --- databricks sql: -SELECT approx_percentile(height, ARRAY(0.25, 0.5, 0.75), 200) FROM people; diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_6.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_6.sql deleted file mode 100644 index eae5642aab..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_6.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, weight, 0.5, 0.09) FROM people; - --- databricks sql: -SELECT approx_percentile(height, weight, 0.5, 1111 ) FROM people; - diff --git a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_8.sql b/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_8.sql deleted file mode 100644 index 81f9335ce1..0000000000 --- a/tests/resources/functional/presto/test_approx_percentile/test_approx_percentile_8.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, weight, ARRAY[0.25, 0.5, 0.75], 0.9) FROM people; - --- databricks sql: -SELECT approx_percentile(height, weight, ARRAY(0.25, 0.5, 0.75), 111 ) FROM people; - diff --git a/tests/resources/functional/presto/test_array_average/test_array_average_1.sql b/tests/resources/functional/presto/test_array_average/test_array_average_1.sql deleted file mode 100644 index 38db44d6ec..0000000000 --- a/tests/resources/functional/presto/test_array_average/test_array_average_1.sql +++ /dev/null @@ -1,40 +0,0 @@ --- presto sql: -select - id, - sum(array_average(arr)) as sum_arr -FROM - ( - SELECT - 1 as id, - ARRAY [1,2,3] AS arr - UNION - SELECT - 2 as id, - ARRAY [10.20,20.108,30.4,40.0] as arr - ) AS t -group by - id; - --- databricks sql: -SELECT - id, - SUM( - AGGREGATE( - FILTER(arr, x -> x IS NOT NULL), - NAMED_STRUCT('sum', CAST(0 AS DOUBLE), 'cnt', 0), - (acc, x) -> NAMED_STRUCT('sum', acc.sum + x, 'cnt', acc.cnt + 1), - acc -> TRY_DIVIDE(acc.sum, acc.cnt) - ) - ) AS sum_arr -FROM - ( - SELECT - 1 AS id, - ARRAY(1, 2, 3) AS arr - UNION - SELECT - 2 AS id, - ARRAY(10.20, 20.108, 30.4, 40.0) AS arr - ) AS t -GROUP BY - id; diff --git a/tests/resources/functional/presto/test_cast_as_json/test_cast_as_json_1.sql b/tests/resources/functional/presto/test_cast_as_json/test_cast_as_json_1.sql deleted file mode 100644 index 5b80cab642..0000000000 --- a/tests/resources/functional/presto/test_cast_as_json/test_cast_as_json_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT CAST(extra AS JSON) FROM dual; - --- databricks sql: -SELECT CAST(extra AS STRING) FROM dual; diff --git a/tests/resources/functional/presto/test_format_datetime/test_format_datetime_1.sql b/tests/resources/functional/presto/test_format_datetime/test_format_datetime_1.sql deleted file mode 100644 index f4a175724e..0000000000 --- a/tests/resources/functional/presto/test_format_datetime/test_format_datetime_1.sql +++ /dev/null @@ -1,13 +0,0 @@ --- presto sql: -select - format_datetime(current_timestamp,'EEEE') as col1 -, format_datetime(current_date,'EEEE') as col2 -, format_datetime(from_unixtime(1732723200), 'hh:mm:ss a') as col3 -, format_datetime(from_unixtime(1732723200), 'yyyy-MM-dd HH:mm:ss EEEE') as col4; - --- databricks sql: -SELECT - DATE_FORMAT(CURRENT_TIMESTAMP(), 'EEEE') AS col1, - DATE_FORMAT(CURRENT_DATE(), 'EEEE') AS col2, - DATE_FORMAT(CAST(FROM_UNIXTIME(1732723200) AS TIMESTAMP), 'hh:mm:ss a') AS col3, - DATE_FORMAT(CAST(FROM_UNIXTIME(1732723200) AS TIMESTAMP), 'yyyy-MM-dd HH:mm:ss EEEE') AS col4 diff --git a/tests/resources/functional/presto/test_if/test_if_1.sql b/tests/resources/functional/presto/test_if/test_if_1.sql deleted file mode 100644 index 2b811329ad..0000000000 --- a/tests/resources/functional/presto/test_if/test_if_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT if(cond, 1, 0) FROM dual; - --- databricks sql: -SELECT IF(cond, 1, 0) FROM dual; diff --git a/tests/resources/functional/presto/test_if/test_if_2.sql b/tests/resources/functional/presto/test_if/test_if_2.sql deleted file mode 100644 index 11d5e49fde..0000000000 --- a/tests/resources/functional/presto/test_if/test_if_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT if(cond, 1) FROM dual; - --- databricks sql: -SELECT IF(cond, 1, NULL) FROM dual; diff --git a/tests/resources/functional/presto/test_json_extract/test_json_extract_1.sql b/tests/resources/functional/presto/test_json_extract/test_json_extract_1.sql deleted file mode 100644 index a3cc18fb73..0000000000 --- a/tests/resources/functional/presto/test_json_extract/test_json_extract_1.sql +++ /dev/null @@ -1,16 +0,0 @@ --- presto sql: -select - "json_extract"(params, '$.query') query, - "json_extract"(params, '$.dependencies') IS NOT NULL AS TEST, - "json_extract"(params, '$.dependencies') IS NULL AS TEST1, - "json_extract"(params, '$.dependencies') AS TEST2 -FROM - drone_job_manager dm; - --- databricks sql: -SELECT - params:query AS query, - params:dependencies IS NOT NULL AS TEST, - params:dependencies IS NULL AS TEST1, - params:dependencies AS TEST2 -FROM drone_job_manager AS dm diff --git a/tests/resources/functional/presto/test_json_size/test_json_size_1.sql b/tests/resources/functional/presto/test_json_size/test_json_size_1.sql deleted file mode 100644 index b2aecb0019..0000000000 --- a/tests/resources/functional/presto/test_json_size/test_json_size_1.sql +++ /dev/null @@ -1,76 +0,0 @@ --- presto sql: -SELECT - json_size(col, path) as j_size, - id -from - ( - select - '{"x": {"a": 1, "b": 2}}' as col, - '$.x' as path, - 1 as id - union - select - '{"x": [1, 2, 3]}' as col, - '$.x' as path, - 2 as id - union - select - '{"x": {"a": 1, "b": 2}}' as col, - '$.x.a' as path, - 3 as id - union - select - '42' as col, - '$' as path, - 4 as id - union - select - 'invalid json' as col, - '$' as path, - 5 as id - ) tmp -order by - id; - --- databricks sql: -SELECT - CASE - WHEN GET_JSON_OBJECT(col, path) LIKE '{%' THEN SIZE( - FROM_JSON(GET_JSON_OBJECT(col, path), 'map') - ) - WHEN GET_JSON_OBJECT(col, path) LIKE '[%' THEN SIZE( - FROM_JSON(GET_JSON_OBJECT(col, path), 'array') - ) - WHEN GET_JSON_OBJECT(col, path) IS NOT NULL THEN 0 - ELSE NULL - END AS j_size, - id -from - ( - select - '{"x": {"a": 1, "b": 2}}' as col, - '$.x' as path, - 1 as id - union - select - '{"x": [1, 2, 3]}' as col, - '$.x' as path, - 2 as id - union - select - '{"x": {"a": 1, "b": 2}}' as col, - '$.x.a' as path, - 3 as id - union - select - '42' as col, - '$' as path, - 4 as id - union - select - 'invalid json' as col, - '$' as path, - 5 as id - ) as tmp -order by - id nulls last; diff --git a/tests/resources/functional/presto/test_nested_json_with_cast/test_nested_json_with_cast_1.sql b/tests/resources/functional/presto/test_nested_json_with_cast/test_nested_json_with_cast_1.sql deleted file mode 100644 index 13c61e8a74..0000000000 --- a/tests/resources/functional/presto/test_nested_json_with_cast/test_nested_json_with_cast_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT AVG(CAST(json_extract_scalar(CAST(extra AS JSON), '$.satisfaction_rating') AS INT)) FROM dual; - --- databricks sql: -SELECT AVG(CAST(CAST(extra AS STRING):satisfaction_rating AS INT)) FROM dual; diff --git a/tests/resources/functional/presto/test_strpos/test_strpos_1.sql b/tests/resources/functional/presto/test_strpos/test_strpos_1.sql deleted file mode 100644 index c6203b34d0..0000000000 --- a/tests/resources/functional/presto/test_strpos/test_strpos_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT strpos('Hello world', 'l', 2); - --- databricks sql: -SELECT LOCATE('l', 'Hello world', 2); diff --git a/tests/resources/functional/presto/test_strpos/test_strpos_2.sql b/tests/resources/functional/presto/test_strpos/test_strpos_2.sql deleted file mode 100644 index d950825b19..0000000000 --- a/tests/resources/functional/presto/test_strpos/test_strpos_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT CASE WHEN strpos(greeting_message, 'hello') > 0 THEN 'Contains hello' ELSE 'Does not contain hello' END FROM greetings_table; - --- databricks sql: -SELECT CASE WHEN LOCATE('hello', greeting_message) > 0 THEN 'Contains hello' ELSE 'Does not contain hello' END FROM greetings_table; diff --git a/tests/resources/functional/presto/test_unnest/test_unnest_1.sql b/tests/resources/functional/presto/test_unnest/test_unnest_1.sql deleted file mode 100644 index d9ce67baa2..0000000000 --- a/tests/resources/functional/presto/test_unnest/test_unnest_1.sql +++ /dev/null @@ -1,17 +0,0 @@ --- presto sql: -SELECT - * -FROM - default.sync_gold - CROSS JOIN UNNEST(engine_waits) t (col1, col2) -WHERE - ("cardinality"(engine_waits) > 0); - --- databricks sql: -SELECT - * -FROM - default.sync_gold LATERAL VIEW EXPLODE(engine_waits) As col1, - col2 -WHERE - (SIZE(engine_waits) > 0); diff --git a/tests/resources/functional/presto/test_unnest/test_unnest_2.sql b/tests/resources/functional/presto/test_unnest/test_unnest_2.sql deleted file mode 100644 index d8a8707a2d..0000000000 --- a/tests/resources/functional/presto/test_unnest/test_unnest_2.sql +++ /dev/null @@ -1,31 +0,0 @@ --- presto sql: -SELECT - day, - build_number, - error, - error_count -FROM - sch.tab - CROSS JOIN UNNEST(CAST(extra AS map(varchar, integer))) e (error, error_count) -WHERE - ( - (event_type = 'fp_daemon_crit_errors_v2') - AND (error_count > 0) - ); - --- databricks sql: -SELECT - day, - build_number, - error, - error_count -FROM - sch.tab LATERAL VIEW EXPLODE(CAST(extra AS MAP)) As error, - error_count -WHERE - ( - ( - event_type = 'fp_daemon_crit_errors_v2' - ) - AND (error_count > 0) - ); diff --git a/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_5.sql b/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_5.sql deleted file mode 100644 index 8d0116f423..0000000000 --- a/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, 0.5, 'non_integer') FROM people; - --- databricks sql: -SELECT approx_percentile(height, 0.5, 0.01) FROM people; diff --git a/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_7.sql b/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_7.sql deleted file mode 100644 index 65016293a1..0000000000 --- a/tests/resources/functional/presto_expected_exceptions/test_approx_percentile_7.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- presto sql: -SELECT approx_percentile(height, weight, 0.5, 'non_integer') FROM people; - --- databricks sql: -SELECT approx_percentile(height, weight, 0.5, 0.01) FROM people; diff --git a/tests/resources/functional/snowflake/aggregates/least_1.sql b/tests/resources/functional/snowflake/aggregates/least_1.sql deleted file mode 100644 index 9247a0dfdd..0000000000 --- a/tests/resources/functional/snowflake/aggregates/least_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT least(col1) AS least_col1 FROM tabl; - --- databricks sql: -SELECT LEAST(col1) AS least_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_1.sql b/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_1.sql deleted file mode 100644 index fcac4173b6..0000000000 --- a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- snowflake sql: -SELECT LISTAGG(col1, ' ') FROM test_table WHERE col2 > 10000; - --- databricks sql: -SELECT - ARRAY_JOIN(ARRAY_AGG(col1), ' ') -FROM test_table -WHERE - col2 > 10000 -; diff --git a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_2.sql b/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_2.sql deleted file mode 100644 index 5211f6c608..0000000000 --- a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_2.sql +++ /dev/null @@ -1,8 +0,0 @@ --- snowflake sql: -SELECT LISTAGG(col1) FROM test_table; - --- databricks sql: -SELECT - ARRAY_JOIN(ARRAY_AGG(col1), '') -FROM test_table -; diff --git a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_3.sql b/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_3.sql deleted file mode 100644 index a06d19a6e2..0000000000 --- a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_3.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT LISTAGG(DISTINCT col3, '|') - FROM test_table WHERE col2 > 10000; - --- databricks sql: -SELECT - ARRAY_JOIN(ARRAY_AGG(DISTINCT col3), '|') -FROM test_table -WHERE - col2 > 10000 -; diff --git a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_4.sql b/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_4.sql deleted file mode 100644 index 11e80f1e60..0000000000 --- a/tests/resources/functional/snowflake/aggregates/listagg/test_listagg_4.sql +++ /dev/null @@ -1,28 +0,0 @@ --- snowflake sql: -SELECT col3, listagg(col4, ', ') WITHIN GROUP (ORDER BY col2 DESC) -FROM -test_table -WHERE col2 > 10000 GROUP BY col3; - --- databricks sql: -SELECT - col3, - ARRAY_JOIN( - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', col4, 'sort_by_0', col2)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN 1 - WHEN left.sort_by_0 > right.sort_by_0 THEN -1 - ELSE 0 - END - ), - s -> s.value - ), - ', ' - ) -FROM test_table -WHERE - col2 > 10000 -GROUP BY - col3; diff --git a/tests/resources/functional/snowflake/aggregates/test_booland_agg_1.sql b/tests/resources/functional/snowflake/aggregates/test_booland_agg_1.sql deleted file mode 100644 index c63cc79423..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_booland_agg_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select booland_agg(k) from bool_example; - --- databricks sql: -SELECT BOOL_AND(k) FROM bool_example; diff --git a/tests/resources/functional/snowflake/aggregates/test_booland_agg_2.sql b/tests/resources/functional/snowflake/aggregates/test_booland_agg_2.sql deleted file mode 100644 index feeae02ea5..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_booland_agg_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select s2, booland_agg(k) from bool_example group by s2; - --- databricks sql: -SELECT s2, BOOL_AND(k) FROM bool_example GROUP BY s2; diff --git a/tests/resources/functional/snowflake/aggregates/test_count_1.sql b/tests/resources/functional/snowflake/aggregates/test_count_1.sql deleted file mode 100644 index bce3802eb9..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_count_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT count(col1) AS count_col1 FROM tabl; - --- databricks sql: -SELECT COUNT(col1) AS count_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/aggregates/test_count_if_1.sql b/tests/resources/functional/snowflake/aggregates/test_count_if_1.sql deleted file mode 100644 index 1644f13324..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_count_if_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT COUNT_IF(j_col > i_col) FROM basic_example; - --- databricks sql: -SELECT COUNT_IF(j_col > i_col) FROM basic_example; diff --git a/tests/resources/functional/snowflake/aggregates/test_dense_rank_1.sql b/tests/resources/functional/snowflake/aggregates/test_dense_rank_1.sql deleted file mode 100644 index 7558c9545c..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_dense_rank_1.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - dense_rank() OVER ( - PARTITION BY col1 - ORDER BY - col2 - ) AS dense_rank_col1 -FROM - tabl; - --- databricks sql: -SELECT - DENSE_RANK() OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST - ) AS dense_rank_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/aggregates/test_dense_rank_2.sql b/tests/resources/functional/snowflake/aggregates/test_dense_rank_2.sql deleted file mode 100644 index 8614ba97f0..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_dense_rank_2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- snowflake sql: -SELECT - dense_rank() OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS dense_rank_col1 -FROM - tabl; - --- databricks sql: -SELECT - DENSE_RANK() OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS dense_rank_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/aggregates/test_greatest_1.sql b/tests/resources/functional/snowflake/aggregates/test_greatest_1.sql deleted file mode 100644 index 691a41eec0..0000000000 --- a/tests/resources/functional/snowflake/aggregates/test_greatest_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT greatest(col_1, col_2, col_3) AS greatest_col1 FROM tabl; - --- databricks sql: -SELECT GREATEST(col_1, col_2, col_3) AS greatest_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/array_flatten_1.sql b/tests/resources/functional/snowflake/arrays/array_flatten_1.sql deleted file mode 100644 index 1f911ee6bc..0000000000 --- a/tests/resources/functional/snowflake/arrays/array_flatten_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT - ARRAY_FLATTEN([[1, 2, 3], [4], [5, 6]]) AS COL -, ARRAY_FLATTEN([[[1, 2], [3]], [[4], [5]]]) AS COL1 -, ARRAY_FLATTEN([[1, 2, 3], NULL, [5, 6]]) AS COL3; - --- databricks sql: -SELECT - FLATTEN(ARRAY(ARRAY(1, 2, 3) , ARRAY(4) , ARRAY(5, 6))) AS COL, - FLATTEN(ARRAY(ARRAY(ARRAY(1, 2) , ARRAY(3)) , ARRAY(ARRAY(4) , ARRAY(5)))) AS COL1, - FLATTEN(ARRAY(ARRAY(1, 2, 3) , NULL, ARRAY(5, 6))) AS COL3; diff --git a/tests/resources/functional/snowflake/arrays/test_array_append_1.sql b/tests/resources/functional/snowflake/arrays/test_array_append_1.sql deleted file mode 100644 index 251e0d4317..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_append_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_append(array, elem) AS array_append_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_APPEND(array, elem) AS array_append_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_cat_1.sql b/tests/resources/functional/snowflake/arrays/test_array_cat_1.sql deleted file mode 100644 index 7b768b7b7a..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_cat_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select array_cat(col1, col2) FROM tbl; - --- databricks sql: -SELECT CONCAT(col1, col2) FROM tbl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_cat_2.sql b/tests/resources/functional/snowflake/arrays/test_array_cat_2.sql deleted file mode 100644 index a9d268be86..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_cat_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select array_cat([1, 3], [2, 4]); - --- databricks sql: -SELECT CONCAT(ARRAY(1, 3), ARRAY(2, 4)); diff --git a/tests/resources/functional/snowflake/arrays/test_array_compact_1.sql b/tests/resources/functional/snowflake/arrays/test_array_compact_1.sql deleted file mode 100644 index 268c85f022..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_compact_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_compact(col1) AS array_compact_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_COMPACT(col1) AS array_compact_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_construct_1.sql b/tests/resources/functional/snowflake/arrays/test_array_construct_1.sql deleted file mode 100644 index 60d29e13e7..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_construct_1.sql +++ /dev/null @@ -1,32 +0,0 @@ --- snowflake sql: -WITH users AS ( - SELECT - 1 AS user_id, - ARRAY_CONSTRUCT('item1', 'item2', 'item3') AS items - UNION ALL - SELECT - 2 AS user_id, - ARRAY_CONSTRUCT('itemA', 'itemB') AS items -) -SELECT - user_id, - value AS item -FROM - users, - LATERAL FLATTEN(input => items) as value; - --- databricks sql: -WITH users AS ( - SELECT - 1 AS user_id, - ARRAY('item1', 'item2', 'item3') AS items - UNION ALL - SELECT - 2 AS user_id, - ARRAY('itemA', 'itemB') AS items -) -SELECT - user_id, - value AS item -FROM users - LATERAL VIEW EXPLODE(items) AS value; diff --git a/tests/resources/functional/snowflake/arrays/test_array_construct_2.sql b/tests/resources/functional/snowflake/arrays/test_array_construct_2.sql deleted file mode 100644 index e712cfeb4a..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_construct_2.sql +++ /dev/null @@ -1,40 +0,0 @@ --- snowflake sql: -WITH orders AS ( - SELECT - 101 AS order_id, - ARRAY_CONSTRUCT( - OBJECT_CONSTRUCT('product_id', 1, 'name', 'ProductA'), - OBJECT_CONSTRUCT('product_id', 2, 'name', 'ProductB') - ) AS order_details - UNION ALL - SELECT - 102 AS order_id, - ARRAY_CONSTRUCT( - OBJECT_CONSTRUCT('product_id', 3, 'name', 'ProductC') - ) AS order_details -) -SELECT - order_id, - value AS product -FROM - orders, - LATERAL FLATTEN(input => order_details) as value; - --- databricks sql: -WITH orders AS ( - SELECT - 101 AS order_id, - ARRAY( - STRUCT(1 AS product_id, 'ProductA' AS name), - STRUCT(2 AS product_id, 'ProductB' AS name) - ) AS order_details - UNION ALL - SELECT - 102 AS order_id, - ARRAY(STRUCT(3 AS product_id, 'ProductC' AS name)) AS order_details -) -SELECT - order_id, - value AS product -FROM - orders LATERAL VIEW EXPLODE(order_details) AS value diff --git a/tests/resources/functional/snowflake/arrays/test_array_construct_compact_1.sql b/tests/resources/functional/snowflake/arrays/test_array_construct_compact_1.sql deleted file mode 100644 index 2f6359b3e6..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_construct_compact_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAY_CONSTRUCT(null, 'hello', 3::double, 4, 5); - --- databricks sql: -SELECT ARRAY(NULL, 'hello', CAST(3 AS DOUBLE), 4, 5); diff --git a/tests/resources/functional/snowflake/arrays/test_array_construct_compact_2.sql b/tests/resources/functional/snowflake/arrays/test_array_construct_compact_2.sql deleted file mode 100644 index c465c2421d..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_construct_compact_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAY_CONSTRUCT_COMPACT(null, 'hello', 3::double, 4, 5); - --- databricks sql: -SELECT ARRAY_EXCEPT(ARRAY(NULL, 'hello', CAST(3 AS DOUBLE), 4, 5), ARRAY(NULL)); diff --git a/tests/resources/functional/snowflake/arrays/test_array_contains_1.sql b/tests/resources/functional/snowflake/arrays/test_array_contains_1.sql deleted file mode 100644 index 1a0ca8201a..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_contains_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_contains(33, arr_col) AS array_contains_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_CONTAINS(arr_col, 33) AS array_contains_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_distinct_1.sql b/tests/resources/functional/snowflake/arrays/test_array_distinct_1.sql deleted file mode 100644 index be46d7a68c..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_distinct_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_distinct(col1) AS array_distinct_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_DISTINCT(col1) AS array_distinct_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_except_1.sql b/tests/resources/functional/snowflake/arrays/test_array_except_1.sql deleted file mode 100644 index a261e1eb51..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_except_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_except(a, b) AS array_except_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_EXCEPT(a, b) AS array_except_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_intersection_1.sql b/tests/resources/functional/snowflake/arrays/test_array_intersection_1.sql deleted file mode 100644 index 40a141a07f..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_intersection_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAY_INTERSECTION(col1, col2); - --- databricks sql: -SELECT ARRAY_INTERSECT(col1, col2); diff --git a/tests/resources/functional/snowflake/arrays/test_array_intersection_2.sql b/tests/resources/functional/snowflake/arrays/test_array_intersection_2.sql deleted file mode 100644 index 1a9337259d..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_intersection_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAY_INTERSECTION(ARRAY_CONSTRUCT(1, 2, 3), ARRAY_CONSTRUCT(1, 2)); - --- databricks sql: -SELECT ARRAY_INTERSECT(ARRAY(1, 2, 3), ARRAY(1, 2)); diff --git a/tests/resources/functional/snowflake/arrays/test_array_position_1.sql b/tests/resources/functional/snowflake/arrays/test_array_position_1.sql deleted file mode 100644 index 9dd59bb912..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_position_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_position(col1, array1) AS array_position_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_POSITION(col1, array1) AS array_position_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_prepend_1.sql b/tests/resources/functional/snowflake/arrays/test_array_prepend_1.sql deleted file mode 100644 index 11422346d4..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_prepend_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_prepend(array, elem) AS array_prepend_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_PREPEND(array, elem) AS array_prepend_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_remove_1.sql b/tests/resources/functional/snowflake/arrays/test_array_remove_1.sql deleted file mode 100644 index 0b8d79004b..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_remove_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_remove(array, element) AS array_remove_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_REMOVE(array, element) AS array_remove_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_size_1.sql b/tests/resources/functional/snowflake/arrays/test_array_size_1.sql deleted file mode 100644 index 2f93088cf6..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_size_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_size(col1) AS array_size_col1 FROM tabl; - --- databricks sql: -SELECT SIZE(col1) AS array_size_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_array_slice_1.sql b/tests/resources/functional/snowflake/arrays/test_array_slice_1.sql deleted file mode 100644 index ffe27227d7..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_slice_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_slice(array_construct(0,1,2,3,4,5,6), 0, 2); - --- databricks sql: -SELECT SLICE(ARRAY(0, 1, 2, 3, 4, 5, 6), 1, 2); diff --git a/tests/resources/functional/snowflake/arrays/test_array_slice_2.sql b/tests/resources/functional/snowflake/arrays/test_array_slice_2.sql deleted file mode 100644 index ed34df96de..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_slice_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_slice(array_construct(90,91,92,93,94,95,96), -5, 3); - --- databricks sql: -SELECT SLICE(ARRAY(90, 91, 92, 93, 94, 95, 96), -5, 3); diff --git a/tests/resources/functional/snowflake/arrays/test_array_to_string_1.sql b/tests/resources/functional/snowflake/arrays/test_array_to_string_1.sql deleted file mode 100644 index 98b6576bcd..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_array_to_string_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAY_TO_STRING(ary_column1, '') AS no_separation FROM tbl; - --- databricks sql: -SELECT ARRAY_JOIN(ary_column1, '') AS no_separation FROM tbl; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_1.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_1.sql deleted file mode 100644 index 194c2dae10..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -select array_agg(col1) FROM test_table; - --- databricks sql: -SELECT ARRAY_AGG(col1) FROM test_table; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_2.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_2.sql deleted file mode 100644 index 64f3b4c523..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT ARRAY_AGG(DISTINCT col2) WITHIN GROUP (ORDER BY col2 ASC) -FROM test_table -WHERE col3 > 10000; - --- databricks sql: -SELECT - SORT_ARRAY(ARRAY_AGG(DISTINCT col2)) -FROM test_table -WHERE - col3 > 10000; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_3.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_3.sql deleted file mode 100644 index 7e0969f194..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_3.sql +++ /dev/null @@ -1,12 +0,0 @@ --- snowflake sql: - -SELECT ARRAY_AGG(col2) WITHIN GROUP (ORDER BY col2 ASC) -FROM test_table -WHERE col3 > 10000; - --- databricks sql: -SELECT - SORT_ARRAY(ARRAY_AGG(col2)) -FROM test_table -WHERE - col3 > 10000; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_4.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_4.sql deleted file mode 100644 index 794d5218aa..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_4.sql +++ /dev/null @@ -1,30 +0,0 @@ --- snowflake sql: -SELECT - col2, - ARRAYAGG(col4) WITHIN GROUP (ORDER BY col3 DESC) -FROM test_table -WHERE col3 > 450000 -GROUP BY col2 -ORDER BY col2 DESC; - --- databricks sql: -SELECT - col2, - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', col4, 'sort_by_0', col3)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN 1 - WHEN left.sort_by_0 > right.sort_by_0 THEN -1 - ELSE 0 - END - ), - s -> s.value - ) -FROM test_table -WHERE - col3 > 450000 -GROUP BY - col2 -ORDER BY - col2 DESC NULLS FIRST; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_5.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_5.sql deleted file mode 100644 index ac19c9730c..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_5.sql +++ /dev/null @@ -1,30 +0,0 @@ --- snowflake sql: -SELECT - col2, - ARRAYAGG(col4) WITHIN GROUP (ORDER BY col3) -FROM test_table -WHERE col3 > 450000 -GROUP BY col2 -ORDER BY col2 DESC; - --- databricks sql: - SELECT - col2, - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', col4, 'sort_by_0', col3)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN -1 - WHEN left.sort_by_0 > right.sort_by_0 THEN 1 - ELSE 0 - END - ), - s -> s.value - ) - FROM test_table - WHERE - col3 > 450000 - GROUP BY - col2 - ORDER BY - col2 DESC NULLS FIRST; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_6.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_6.sql deleted file mode 100644 index 0c433015a3..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_6.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: -SELECT ARRAY_AGG(col2) WITHIN GROUP (ORDER BY col2 DESC) FROM test_table; - --- databricks sql: -SELECT - SORT_ARRAY(ARRAY_AGG(col2), false) -FROM test_table; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_7.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_7.sql deleted file mode 100644 index 138a23dbad..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_7.sql +++ /dev/null @@ -1,38 +0,0 @@ --- snowflake sql: -WITH cte AS ( - SELECT - id, - tag, - SUM(tag:count) AS item_count - FROM another_table -) -SELECT -id -, ARRAY_AGG(tag) WITHIN GROUP(ORDER BY item_count DESC) AS agg_tags -FROM cte -GROUP BY 1; - --- databricks sql: -WITH cte AS ( - SELECT - id, - tag, - SUM(tag:count) AS item_count - FROM another_table - ) - SELECT - id, - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', tag, 'sort_by_0', item_count)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN 1 - WHEN left.sort_by_0 > right.sort_by_0 THEN -1 - ELSE 0 - END - ), - s -> s.value - ) AS agg_tags - FROM cte - GROUP BY - 1; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_8.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_8.sql deleted file mode 100644 index 7ad991ff7f..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_8.sql +++ /dev/null @@ -1,32 +0,0 @@ --- snowflake sql: -SELECT - col2, - ARRAYAGG(col4) WITHIN GROUP (ORDER BY col3, col5) -FROM test_table -WHERE col3 > 450000 -GROUP BY col2 -ORDER BY col2 DESC; - --- databricks sql: - SELECT - col2, - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', col4, 'sort_by_0', col3, 'sort_by_1', col5)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN -1 - WHEN left.sort_by_0 > right.sort_by_0 THEN 1 - WHEN left.sort_by_1 < right.sort_by_1 THEN -1 - WHEN left.sort_by_1 > right.sort_by_1 THEN 1 - ELSE 0 - END - ), - s -> s.value - ) - FROM test_table - WHERE - col3 > 450000 - GROUP BY - col2 - ORDER BY - col2 DESC NULLS FIRST; diff --git a/tests/resources/functional/snowflake/arrays/test_arrayagg_9.sql b/tests/resources/functional/snowflake/arrays/test_arrayagg_9.sql deleted file mode 100644 index d0440b9077..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrayagg_9.sql +++ /dev/null @@ -1,32 +0,0 @@ --- snowflake sql: -SELECT - col2, - ARRAYAGG(col4) WITHIN GROUP (ORDER BY col3, col5 DESC) -FROM test_table -WHERE col3 > 450000 -GROUP BY col2 -ORDER BY col2 DESC; - --- databricks sql: -SELECT - col2, - TRANSFORM( - ARRAY_SORT( - ARRAY_AGG(NAMED_STRUCT('value', col4, 'sort_by_0', col3, 'sort_by_1', col5)), - (left, right) -> CASE - WHEN left.sort_by_0 < right.sort_by_0 THEN -1 - WHEN left.sort_by_0 > right.sort_by_0 THEN 1 - WHEN left.sort_by_1 < right.sort_by_1 THEN 1 - WHEN left.sort_by_1 > right.sort_by_1 THEN -1 - ELSE 0 - END - ), - s -> s.value - ) -FROM test_table -WHERE - col3 > 450000 -GROUP BY - col2 -ORDER BY - col2 DESC NULLS FIRST; diff --git a/tests/resources/functional/snowflake/arrays/test_arrays_overlap_1.sql b/tests/resources/functional/snowflake/arrays/test_arrays_overlap_1.sql deleted file mode 100644 index b1e2b09dac..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_arrays_overlap_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ARRAYS_OVERLAP(ARRAY_CONSTRUCT(1, 2, NULL), ARRAY_CONSTRUCT(3, NULL, 5)); - --- databricks sql: -SELECT ARRAYS_OVERLAP(ARRAY(1, 2, NULL), ARRAY(3, NULL, 5)); diff --git a/tests/resources/functional/snowflake/arrays/test_concat_ws_1.sql b/tests/resources/functional/snowflake/arrays/test_concat_ws_1.sql deleted file mode 100644 index 02a09b1b2f..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_concat_ws_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT CONCAT_WS(',', 'one', 'two', 'three'); - --- databricks sql: -SELECT CONCAT_WS(',', 'one', 'two', 'three'); diff --git a/tests/resources/functional/snowflake/arrays/test_extract_1.sql b/tests/resources/functional/snowflake/arrays/test_extract_1.sql deleted file mode 100644 index 70faafe8ef..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_extract_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT extract(week FROM col1) AS extract_col1 FROM tabl; - --- databricks sql: -SELECT EXTRACT(week FROM col1) AS extract_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_flatten_1.sql b/tests/resources/functional/snowflake/arrays/test_flatten_1.sql deleted file mode 100644 index 3f263f9492..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_flatten_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT flatten(col1) AS flatten_col1 FROM tabl; - --- databricks sql: -SELECT EXPLODE(col1) AS flatten_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/arrays/test_get_1.sql b/tests/resources/functional/snowflake/arrays/test_get_1.sql deleted file mode 100644 index b242ea5777..0000000000 --- a/tests/resources/functional/snowflake/arrays/test_get_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT get(col1, idx1) AS get_col1 FROM tabl; - --- databricks sql: -SELECT GET(col1, idx1) AS get_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/cast/test_cast_date.sql b/tests/resources/functional/snowflake/cast/test_cast_date.sql deleted file mode 100644 index 74dfc054dd..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_date.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: -SELECT - '2024-01-01'::DATE AS date_val - --- databricks sql: -SELECT - CAST('2024-01-01' AS DATE) AS date_val; diff --git a/tests/resources/functional/snowflake/cast/test_cast_decimal.sql b/tests/resources/functional/snowflake/cast/test_cast_decimal.sql deleted file mode 100644 index 74560062e7..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_decimal.sql +++ /dev/null @@ -1,13 +0,0 @@ --- snowflake sql: -SELECT - 12345::DECIMAL(10, 2) AS decimal_val, - 12345::NUMBER(10, 2) AS number_val, - 12345::NUMERIC(10, 2) AS numeric_val, - 12345::BIGINT AS bigint_val - --- databricks sql: -SELECT - CAST(12345 AS DECIMAL(10, 2)) AS decimal_val, - CAST(12345 AS DECIMAL(10, 2)) AS number_val, - CAST(12345 AS DECIMAL(10, 2)) AS numeric_val, - CAST(12345 AS DECIMAL(38, 0)) AS bigint_val; diff --git a/tests/resources/functional/snowflake/cast/test_cast_double.sql b/tests/resources/functional/snowflake/cast/test_cast_double.sql deleted file mode 100644 index 06e777612f..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_double.sql +++ /dev/null @@ -1,17 +0,0 @@ --- snowflake sql: -SELECT - 12345.678::DOUBLE AS double_val, - 12345.678::DOUBLE PRECISION AS double_precision_val, - 12345.678::FLOAT AS float_val, - 12345.678::FLOAT4 AS float4_val, - 12345.678::FLOAT8 AS float8_val, - 12345.678::REAL AS real_val - --- databricks sql: -SELECT - CAST(12345.678 AS DOUBLE) AS double_val, - CAST(12345.678 AS DOUBLE) AS double_precision_val, - CAST(12345.678 AS DOUBLE) AS float_val, - CAST(12345.678 AS DOUBLE) AS float4_val, - CAST(12345.678 AS DOUBLE) AS float8_val, - CAST(12345.678 AS DOUBLE) AS real_val; diff --git a/tests/resources/functional/snowflake/cast/test_cast_int.sql b/tests/resources/functional/snowflake/cast/test_cast_int.sql deleted file mode 100644 index 4ff05cec0b..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_int.sql +++ /dev/null @@ -1,17 +0,0 @@ --- snowflake sql: -SELECT - 123::BYTEINT AS byteint_val, - 123::SMALLINT AS smallint_val, - 123::INT AS int_val, - 123::INTEGER AS integer_val, - 123::BIGINT AS bigint_val, - 123::TINYINT AS tinyint_val - --- databricks sql: -SELECT - CAST(123 AS DECIMAL(38, 0)) AS byteint_val, - CAST(123 AS DECIMAL(38, 0)) AS smallint_val, - CAST(123 AS DECIMAL(38, 0)) AS int_val, - CAST(123 AS DECIMAL(38, 0)) AS integer_val, - CAST(123 AS DECIMAL(38, 0)) AS bigint_val, - CAST(123 AS TINYINT) AS tinyint_val; diff --git a/tests/resources/functional/snowflake/cast/test_cast_strings.sql b/tests/resources/functional/snowflake/cast/test_cast_strings.sql deleted file mode 100644 index 05fe1e0973..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_strings.sql +++ /dev/null @@ -1,15 +0,0 @@ --- snowflake sql: -SELECT - '12345'::VARCHAR(10) AS varchar_val, - '12345'::STRING AS string_val, - '12345'::TEXT AS text_val, - 'A'::CHAR(1) AS char_val, - 'A'::CHARACTER(1) AS character_val - --- databricks sql: -SELECT - CAST('12345' AS STRING) AS varchar_val, - CAST('12345' AS STRING) AS string_val, - CAST('12345' AS STRING) AS text_val, - CAST('A' AS STRING) AS char_val, - CAST('A' AS STRING) AS character_val; diff --git a/tests/resources/functional/snowflake/cast/test_cast_timestamp.sql b/tests/resources/functional/snowflake/cast/test_cast_timestamp.sql deleted file mode 100644 index f38bff6588..0000000000 --- a/tests/resources/functional/snowflake/cast/test_cast_timestamp.sql +++ /dev/null @@ -1,15 +0,0 @@ --- snowflake sql: -SELECT - '12:34:56'::TIME AS time_val, - '2024-01-01 12:34:56'::TIMESTAMP AS timestamp_val, - '2024-01-01 12:34:56 +00:00'::TIMESTAMP_LTZ AS timestamp_ltz_val, - '2024-01-01 12:34:56'::TIMESTAMP_NTZ AS timestamp_ntz_val, - '2024-01-01 12:34:56 +00:00'::TIMESTAMP_TZ AS timestamp_tz_val - --- databricks sql: -SELECT - CAST('12:34:56' AS TIMESTAMP) AS time_val, - CAST('2024-01-01 12:34:56' AS TIMESTAMP) AS timestamp_val, - CAST('2024-01-01 12:34:56 +00:00' AS TIMESTAMP) AS timestamp_ltz_val, - CAST('2024-01-01 12:34:56' AS TIMESTAMP_NTZ) AS timestamp_ntz_val, - CAST('2024-01-01 12:34:56 +00:00' AS TIMESTAMP) AS timestamp_tz_val; diff --git a/tests/resources/functional/snowflake/cast/test_colon_cast.sql b/tests/resources/functional/snowflake/cast/test_colon_cast.sql deleted file mode 100644 index 2353248e73..0000000000 --- a/tests/resources/functional/snowflake/cast/test_colon_cast.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: -SELECT - ARRAY_REMOVE([2, 3, 4::DOUBLE, 4, NULL], 4) - --- databricks sql: -SELECT - ARRAY_REMOVE(ARRAY(2, 3, CAST(4 AS DOUBLE), 4, NULL), 4); diff --git a/tests/resources/functional/snowflake/cast/test_typecasts.sql b/tests/resources/functional/snowflake/cast/test_typecasts.sql deleted file mode 100644 index 46b513caff..0000000000 --- a/tests/resources/functional/snowflake/cast/test_typecasts.sql +++ /dev/null @@ -1,13 +0,0 @@ --- snowflake sql: -SELECT - PARSE_JSON('[1,2,3]')::ARRAY(INTEGER) AS array_val, - 'deadbeef'::BINARY AS binary_val, - 'true'::BOOLEAN AS boolean_val, - 'deadbeef'::VARBINARY AS varbinary_val - --- databricks sql: -SELECT - FROM_JSON('[1,2,3]', 'ARRAY') AS array_val, - CAST('deadbeef' AS BINARY) AS binary_val, - CAST('true' AS BOOLEAN) AS boolean_val, - CAST('deadbeef' AS BINARY) AS varbinary_val; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_1.sql b/tests/resources/functional/snowflake/core_engine/aggregates/last_value_1.sql deleted file mode 100644 index 2c7525caa2..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_1.sql +++ /dev/null @@ -1,20 +0,0 @@ --- snowflake sql: -SELECT - last_value(col1) over ( - partition by col1 - order by - col2 - ) AS last_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - LAST(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING - AND UNBOUNDED FOLLOWING - ) AS last_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_2.sql b/tests/resources/functional/snowflake/core_engine/aggregates/last_value_2.sql deleted file mode 100644 index 03192fdfea..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_2.sql +++ /dev/null @@ -1,33 +0,0 @@ --- snowflake sql: -SELECT - taba.col_a, - taba.col_b, - last_value( - CASE - WHEN taba.col_c IN ('xyz', 'abc') THEN taba.col_d - END - ) ignore nulls OVER ( - partition BY taba.col_e - ORDER BY - taba.col_f DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a taba; - --- databricks sql: -SELECT - taba.col_a, - taba.col_b, - LAST( - CASE - WHEN taba.col_c IN ('xyz', 'abc') THEN taba.col_d - END - ) IGNORE NULLS OVER ( - PARTITION BY taba.col_e - ORDER BY - taba.col_f DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a AS taba; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_3.sql b/tests/resources/functional/snowflake/core_engine/aggregates/last_value_3.sql deleted file mode 100644 index 7cef7b85b1..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/last_value_3.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT - last_value(col1) AS last_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - LAST(col1) AS last_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_1.sql b/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_1.sql deleted file mode 100644 index d48fda055c..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT - first_value(col1) AS first_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - FIRST(col1) AS first_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_2.sql b/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_2.sql deleted file mode 100644 index 8bb3973706..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_2.sql +++ /dev/null @@ -1,20 +0,0 @@ --- snowflake sql: -SELECT - first_value(col1) over ( - partition by col1 - order by - col2 - ) AS first_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - FIRST(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING - AND UNBOUNDED FOLLOWING - ) AS first_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_3.sql b/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_3.sql deleted file mode 100644 index 20febd600d..0000000000 --- a/tests/resources/functional/snowflake/core_engine/aggregates/test_first_value_3.sql +++ /dev/null @@ -1,35 +0,0 @@ --- snowflake sql: -SELECT - tabb.col_a, - tabb.col_b, - first_value( - CASE - WHEN tabb.col_c IN ('xyz', 'abc') THEN tabb.col_d - END - ) ignore nulls OVER ( - partition BY tabb.col_e - ORDER BY - tabb.col_f DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a taba - LEFT JOIN schema_b.table_b AS tabb ON taba.col_e = tabb.col_e; - --- databricks sql: -SELECT - tabb.col_a, - tabb.col_b, - FIRST( - CASE - WHEN tabb.col_c IN ('xyz', 'abc') THEN tabb.col_d - END - ) IGNORE NULLS OVER ( - PARTITION BY tabb.col_e - ORDER BY - tabb.col_f DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a AS taba - LEFT JOIN schema_b.table_b AS tabb ON taba.col_e = tabb.col_e; diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_1.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_1.sql deleted file mode 100644 index 483fe5b9d1..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_TIME('2018-05-15', 'yyyy-MM-dd'); - --- databricks sql: -SELECT DATE_FORMAT(TO_TIMESTAMP('2018-05-15', 'yyyy-MM-dd'), 'HH:mm:ss'); diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_2.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_2.sql deleted file mode 100644 index cde2d03870..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_to_time_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_TIME('2018-05-15 00:01:02'); - --- databricks sql: -SELECT DATE_FORMAT(TO_TIMESTAMP('2018-05-15 00:01:02'), 'HH:mm:ss'); diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_1.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_1.sql deleted file mode 100644 index 34f87bfc54..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DATE('2018-05-15'); - --- databricks sql: -SELECT DATE(TRY_TO_TIMESTAMP('2018-05-15')); diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_3.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_3.sql deleted file mode 100644 index bc89a4ba05..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/test_try_to_date_3.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DATE('2012.20.12', 'yyyy.dd.MM'), TRY_TO_DATE(d.col1) FROM dummy d; - --- databricks sql: -SELECT DATE(TRY_TO_TIMESTAMP('2012.20.12', 'yyyy.dd.MM')), - DATE(TRY_TO_TIMESTAMP(d.col1)) FROM dummy AS d; diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_1.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_1.sql deleted file mode 100644 index c669c00b11..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_1.sql +++ /dev/null @@ -1,30 +0,0 @@ - --- snowflake sql: -SELECT to_timestamp(col1) AS to_timestamp_col1 FROM tabl; - --- databricks sql: -SELECT - CASE - TYPEOF(col1) - WHEN 'string' THEN IFNULL( - COALESCE( - TRY_TO_TIMESTAMP(TRY_CAST(col1 AS INT)), - TRY_TO_TIMESTAMP(col1, 'yyyy-MM-dd\'T\'HH:mmXXX'), - TRY_TO_TIMESTAMP(col1, 'yyyy-MM-dd HH:mmXXX'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy HH:mm:ss ZZZ'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy HH:mm:ss.SSSSSSSSS ZZZ'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy hh:mm:ss a ZZZ'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy hh:mm:ss.SSSSSSSSS a ZZZ'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy HH:mm:ss'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy HH:mm:ss.SSSSSSSSS'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy hh:mm:ss a'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ', dd MMM yyyy hh:mm:ss.SSSSSSSSS a'), - TRY_TO_TIMESTAMP(col1, 'M/dd/yyyy HH:mm:ss'), - TRY_TO_TIMESTAMP(SUBSTR(col1, 4), ' MMM dd HH:mm:ss ZZZ yyyy') - ), - TO_TIMESTAMP(col1) - ) - ELSE CAST(col1 AS TIMESTAMP) - END AS to_timestamp_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_variable_format.sql b/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_variable_format.sql deleted file mode 100644 index 6c3bc0806a..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/conversion/to_timestamp_variable_format.sql +++ /dev/null @@ -1,179 +0,0 @@ --- snowflake sql: - SELECT TO_TIMESTAMP(str, fmt) FROM (VALUES ('2024-11-20T18:05:59.123456789', 'YYYY-MM-DD"T"HH24:MI:SS.FF'), ('Thu, 21 Dec 2000 04:01:07 PM +0200', 'DY, DD MON YYYY HH12:MI:SS AM TZHTZM') ) AS vals(str, fmt); - --- databricks sql: -SELECT IF( - STARTSWITH(fmt, 'DY'), - TO_TIMESTAMP(SUBSTR(str, 4), SUBSTR(REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(fmt, 'YYYY', 'yyyy'), 'YY', 'yy'), 'MON', 'MMM'), 'DD', 'dd'), 'DY', 'EEE'), - 'HH24', - 'HH' - ), - 'HH12', - 'hh' - ), - 'AM', - 'a' - ), - 'PM', - 'a' - ), - 'MI', - 'mm' - ), - 'SS', - 'ss' - ), - 'FF9', - 'SSSSSSSSS' - ), - 'FF8', - 'SSSSSSSS' - ), - 'FF7', - 'SSSSSSS' - ), - 'FF6', - 'SSSSSS' - ), - 'FF5', - 'SSSSS' - ), - 'FF4', - 'SSSS' - ), - 'FF3', - 'SSS' - ), - 'FF2', - 'SS' - ), - 'FF1', - 'S' - ), - 'FF0', - '' - ), - 'FF', - 'SSSSSSSSS' - ), - 'TZH:TZM', - 'ZZZ' - ), - 'TZHTZM', - 'ZZZ' - ), - 'TZH', - 'ZZZ' - ), - 'UUUU', - 'yyyy' - ), '"', '\''), 4)), - TO_TIMESTAMP(str, REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE( - REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(fmt, 'YYYY', 'yyyy'), 'YY', 'yy'), 'MON', 'MMM'), 'DD', 'dd'), 'DY', 'EEE'), - 'HH24', - 'HH' - ), - 'HH12', - 'hh' - ), - 'AM', - 'a' - ), - 'PM', - 'a' - ), - 'MI', - 'mm' - ), - 'SS', - 'ss' - ), - 'FF9', - 'SSSSSSSSS' - ), - 'FF8', - 'SSSSSSSS' - ), - 'FF7', - 'SSSSSSS' - ), - 'FF6', - 'SSSSSS' - ), - 'FF5', - 'SSSSS' - ), - 'FF4', - 'SSSS' - ), - 'FF3', - 'SSS' - ), - 'FF2', - 'SS' - ), - 'FF1', - 'S' - ), - 'FF0', - '' - ), - 'FF', - 'SSSSSSSSS' - ), - 'TZH:TZM', - 'ZZZ' - ), - 'TZHTZM', - 'ZZZ' - ), - 'TZH', - 'ZZZ' - ), - 'UUUU', - 'yyyy' - ), '"', '\'')) -) FROM VALUES ('2024-11-20T18:05:59.123456789', 'YYYY-MM-DD"T"HH24:MI:SS.FF'), ('Thu, 21 Dec 2000 04:01:07 PM +0200', 'DY, DD MON YYYY HH12:MI:SS AM TZHTZM') AS vals(str, fmt); diff --git a/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_2.sql b/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_2.sql deleted file mode 100644 index b5de0c552a..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -DELETE FROM table1 WHERE cre_at >= DATE_TRUNC('month', TRY_TO_DATE('2022-01-15')); - --- databricks sql: -DELETE FROM table1 WHERE cre_at >= DATE_TRUNC('MONTH', DATE(TRY_TO_TIMESTAMP('2022-01-15'))); diff --git a/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_3.sql b/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_3.sql deleted file mode 100644 index 4a84dd8c8e..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/dates/test_date_trunc_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select DATE_TRUNC('month', TRY_TO_DATE(COLUMN1)) from table; - --- databricks sql: -SELECT DATE_TRUNC('MONTH', DATE(TRY_TO_TIMESTAMP(COLUMN1))) FROM table; diff --git a/tests/resources/functional/snowflake/core_engine/functions/dates/test_dayname_1.sql b/tests/resources/functional/snowflake/core_engine/functions/dates/test_dayname_1.sql deleted file mode 100644 index 91cdf05f10..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/dates/test_dayname_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT DAYNAME(TO_TIMESTAMP('2015-04-03 10:00:00')) AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT(TO_TIMESTAMP('2015-04-03 10:00:00'), 'E') AS MONTH; diff --git a/tests/resources/functional/snowflake/core_engine/functions/dates/test_monthname_1.sql b/tests/resources/functional/snowflake/core_engine/functions/dates/test_monthname_1.sql deleted file mode 100644 index b7a529d354..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/dates/test_monthname_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT MONTHNAME(TO_TIMESTAMP('2015-04-03 10:00:00')) AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT(TO_TIMESTAMP('2015-04-03 10:00:00'), 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_3.sql b/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_3.sql deleted file mode 100644 index 7346ba5777..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_3.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: - -SELECT REGEXP_SUBSTR('The real world of The Doors', 'The\\W+\\w+', 2); - --- databricks sql: - -SELECT REGEXP_EXTRACT(SUBSTR('The real world of The Doors', 2), 'The\\W+\\w+', 0); diff --git a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_4.sql b/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_4.sql deleted file mode 100644 index 5d9c432eb3..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_4.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: - -SELECT REGEXP_SUBSTR('The real world of The Doors', 'The\\W+\\w+', 1, 2); - --- databricks sql: - -SELECT REGEXP_EXTRACT_ALL(SUBSTR('The real world of The Doors', 1), 'The\\W+\\w+', 0)[1]; diff --git a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_5.sql b/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_5.sql deleted file mode 100644 index 66a8881027..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_5.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: - -SELECT REGEXP_SUBSTR('The real world of The Doors', 'the\\W+\\w+', 1, 2, 'i'); - --- databricks sql: - -SELECT REGEXP_EXTRACT_ALL(SUBSTR('The real world of The Doors', 1), '(?i)the\\W+\\w+', 0)[1]; diff --git a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_6.sql b/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_6.sql deleted file mode 100644 index 3e2d2b4bb2..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_6.sql +++ /dev/null @@ -1,22 +0,0 @@ --- snowflake sql: -WITH - params(p) AS (SELECT 'i') -SELECT REGEXP_SUBSTR('The real world of The Doors', 'the\\W+\\w+', 1, 2, p) FROM params; - --- databricks sql: -WITH - params (p) AS (SELECT 'i') -SELECT REGEXP_EXTRACT_ALL( - SUBSTR('The real world of The Doors', 1), - AGGREGATE( - SPLIT(p, ''), - CAST(ARRAY() AS ARRAY), - (agg, item) -> - CASE - WHEN item = 'c' THEN FILTER(agg, item -> item != 'i') - WHEN item IN ('i', 's', 'm') THEN ARRAY_APPEND(agg, item) - ELSE agg - END - , - filtered -> '(?' || ARRAY_JOIN(filtered, '') || ')' || 'the\\W+\\w+' - ), 0)[1] FROM params; diff --git a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_7.sql b/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_7.sql deleted file mode 100644 index 754f05c203..0000000000 --- a/tests/resources/functional/snowflake/core_engine/functions/strings/regexp_substr_7.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: - -SELECT REGEXP_SUBSTR('The real world of The Doors', 'the\\W+(\\w+)', 1, 2, 'i', 1); - --- databricks sql: - -SELECT REGEXP_EXTRACT_ALL(SUBSTR('The real world of The Doors', 1), '(?i)the\\W+(\\w+)', 1)[1]; diff --git a/tests/resources/functional/snowflake/core_engine/lca/lca_function.sql b/tests/resources/functional/snowflake/core_engine/lca/lca_function.sql deleted file mode 100644 index a58d5e1d1e..0000000000 --- a/tests/resources/functional/snowflake/core_engine/lca/lca_function.sql +++ /dev/null @@ -1,12 +0,0 @@ --- snowflake sql: -SELECT - col1 AS ca - FROM table1 - WHERE substr(ca,1,5) = '12345' - ; - --- databricks sql: -SELECT - col1 AS ca - FROM table1 - WHERE SUBSTR(col1, 1,5) = '12345'; diff --git a/tests/resources/functional/snowflake/core_engine/lca/lca_homonym.sql.saved b/tests/resources/functional/snowflake/core_engine/lca/lca_homonym.sql.saved deleted file mode 100644 index 8bc234a1cd..0000000000 --- a/tests/resources/functional/snowflake/core_engine/lca/lca_homonym.sql.saved +++ /dev/null @@ -1,28 +0,0 @@ --- snowflake sql: -select - ca_zip -from ( - SELECT - substr(ca_zip,1,5) ca_zip, - trim(name) as name, - -- ca_zip should not be transpiled - count(*) over( partition by ca_zip) - FROM - customer_address - WHERE - -- ca_zip should not be transpiled - ca_zip IN ('89436', '30868')); --- databricks sql: -SELECT - ca_zip -FROM -SELECT - SUBSTR(ca_zip,1,5) AS ca_zip, - TRIM(name) AS name, - COUNT(*) OVER ( - PARTITION BY ca_zip - ) -FROM - customer_address -WHERE - ca_zip IN ('89436', '30868'); diff --git a/tests/resources/functional/snowflake/core_engine/sample.sql b/tests/resources/functional/snowflake/core_engine/sample.sql deleted file mode 100644 index c9c9dc5f26..0000000000 --- a/tests/resources/functional/snowflake/core_engine/sample.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -select * from table_name; - --- databricks sql: -select * from table_name; diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/except.sql b/tests/resources/functional/snowflake/core_engine/set-operations/except.sql deleted file mode 100644 index bd6b08dcd9..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/except.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... EXCEPT ... --- --- Verify simple EXCEPT handling. --- --- snowflake sql: - -SELECT 1 -EXCEPT -SELECT 2; - --- databricks sql: -(SELECT 1) -EXCEPT -(SELECT 2); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/intersect.sql b/tests/resources/functional/snowflake/core_engine/set-operations/intersect.sql deleted file mode 100644 index 88f91e71ac..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/intersect.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... INTERSECT ... --- --- Verify simple INTERSECT handling. --- --- snowflake sql: - -SELECT 1 -INTERSECT -SELECT 2; - --- databricks sql: -(SELECT 1) -INTERSECT -(SELECT 2); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/minus.sql b/tests/resources/functional/snowflake/core_engine/set-operations/minus.sql deleted file mode 100644 index 1b9dc4d608..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/minus.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... MINUS ... --- --- Verify simple MINUS handling: it is an alias for EXCEPT. --- --- snowflake sql: - -SELECT 1 -MINUS -SELECT 2; - --- databricks sql: -(SELECT 1) -EXCEPT -(SELECT 2); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/precedence.sql b/tests/resources/functional/snowflake/core_engine/set-operations/precedence.sql deleted file mode 100644 index f42df26df4..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/precedence.sql +++ /dev/null @@ -1,119 +0,0 @@ --- --- Verify the precedence rules are being correctly handled. Order of evaluation when chaining is: --- 1. Brackets. --- 2. INTERSECT --- 3. UNION and EXCEPT, evaluated left to right. --- - --- snowflake sql: - --- Verifies UNION/EXCEPT/MINUS as left-to-right (1/3), with brackets. -(SELECT 1 - UNION - SELECT 2 - EXCEPT - SELECT 3 - MINUS - (SELECT 4 - UNION - SELECT 5)) - -UNION ALL - --- Verifies UNION/EXCEPT/MINUS as left-to-right (2/3) when the order is rotated from the previous. -(SELECT 6 - EXCEPT - SELECT 7 - MINUS - SELECT 8 - UNION - SELECT 9) - -UNION ALL - --- Verifies UNION/EXCEPT/MINUS as left-to-right (3/3) when the order is rotated from the previous. -(SELECT 10 - MINUS - SELECT 11 - UNION - SELECT 12 - EXCEPT - SELECT 13) - -UNION ALL - --- Verifies that INTERSECT has precedence over UNION/EXCEPT/MINUS. -(SELECT 14 - UNION - SELECT 15 - EXCEPT - SELECT 16 - MINUS - SELECT 17 - INTERSECT - SELECT 18) - -UNION ALL - --- Verifies that INTERSECT is left-to-right, although brackets have precedence. -(SELECT 19 - INTERSECT - SELECT 20 - INTERSECT - (SELECT 21 - INTERSECT - SELECT 22)); - --- databricks sql: - - ( - ( - ( - ( - ( - ((SELECT 1) UNION (SELECT 2)) - EXCEPT - (SELECT 3) - ) - EXCEPT - ((SELECT 4) UNION (SELECT 5)) - ) - UNION ALL - ( - ( - ((SELECT 6) EXCEPT (SELECT 7)) - EXCEPT - (SELECT 8) - ) - UNION - (SELECT 9) - ) - ) - UNION ALL - ( - ( - ((SELECT 10) EXCEPT (SELECT 11)) - UNION - (SELECT 12) - ) - EXCEPT - (SELECT 13) - ) - ) - UNION ALL - ( - ( - ((SELECT 14) UNION (SELECT 15)) - EXCEPT - (SELECT 16) - ) - EXCEPT - ((SELECT 17) INTERSECT (SELECT 18)) - ) - ) -UNION ALL - ( - ((SELECT 19) INTERSECT (SELECT 20)) - INTERSECT - ((SELECT 21) INTERSECT (SELECT 22)) - ); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/union-all.sql b/tests/resources/functional/snowflake/core_engine/set-operations/union-all.sql deleted file mode 100644 index 9cc59fbdf5..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/union-all.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... UNION ALL ... --- --- Verify simple UNION ALL handling. --- --- snowflake sql: - -SELECT 1 -UNION ALL -SELECT 2; - --- databricks sql: -(SELECT 1) -UNION ALL -(SELECT 2); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/union.sql b/tests/resources/functional/snowflake/core_engine/set-operations/union.sql deleted file mode 100644 index 28ded38b72..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/union.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... UNION ... --- --- Verify simple UNION handling. --- --- snowflake sql: - -SELECT 1 -UNION -SELECT 2; - --- databricks sql: -(SELECT 1) -UNION -(SELECT 2); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/union_all_left_grouped.sql b/tests/resources/functional/snowflake/core_engine/set-operations/union_all_left_grouped.sql deleted file mode 100644 index 93c462e0b9..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/union_all_left_grouped.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## (SELECT …) UNION ALL SELECT … --- --- Verify UNION handling when the LHS of the union is explicitly wrapped in parentheses. --- --- snowflake sql: - -(SELECT a, b from c) UNION ALL SELECT x, y from z; - --- databricks sql: -(SELECT a, b FROM c) UNION ALL (SELECT x, y FROM z); diff --git a/tests/resources/functional/snowflake/core_engine/set-operations/union_left_grouped.sql b/tests/resources/functional/snowflake/core_engine/set-operations/union_left_grouped.sql deleted file mode 100644 index 03d3cff80d..0000000000 --- a/tests/resources/functional/snowflake/core_engine/set-operations/union_left_grouped.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## (SELECT …) UNION SELECT … --- --- Verify UNION handling when the LHS of the union is explicitly wrapped in parentheses. --- --- snowflake sql: - -(SELECT a, b from c) UNION SELECT x, y from z; - --- databricks sql: -(SELECT a, b FROM c) UNION (SELECT x, y FROM z); diff --git a/tests/resources/functional/snowflake/core_engine/test_command/test_command_1.sql b/tests/resources/functional/snowflake/core_engine/test_command/test_command_1.sql deleted file mode 100644 index 9445b516fe..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_command/test_command_1.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: -!set exit_on_error = true; - --- databricks sql: -/* The following issues were detected: - - Unknown command in SnowflakeAstBuilder.visitSnowSqlCommand - !set exit_on_error = true; - */ diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/cte_set_operation_precedence.sql b/tests/resources/functional/snowflake/core_engine/test_cte/cte_set_operation_precedence.sql deleted file mode 100644 index 457c85f7bd..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_cte/cte_set_operation_precedence.sql +++ /dev/null @@ -1,17 +0,0 @@ --- --- CTEs are visible to all the SELECT queries within a subsequent sequence of set operations. --- - --- snowflake sql: -WITH a AS (SELECT 1, 2, 3) - -SELECT 4, 5, 6 -UNION -SELECT * FROM a; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3) - -(SELECT 4, 5, 6) -UNION -(SELECT * FROM a); diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql b/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql deleted file mode 100644 index bb0ed6c61b..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_cte/cte_simple.sql +++ /dev/null @@ -1,16 +0,0 @@ --- snowflake sql: -WITH employee_hierarchy AS ( - SELECT - employee_id, - manager_id, - employee_name - FROM - employees - WHERE - manager_id IS NULL -) -SELECT * -FROM employee_hierarchy; - --- databricks sql: -WITH employee_hierarchy AS (SELECT employee_id, manager_id, employee_name FROM employees WHERE manager_id IS NULL) SELECT * FROM employee_hierarchy; diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/multiple_cte.sql b/tests/resources/functional/snowflake/core_engine/test_cte/multiple_cte.sql deleted file mode 100644 index b330b86a87..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_cte/multiple_cte.sql +++ /dev/null @@ -1,19 +0,0 @@ --- --- Verify a few CTEs that include multiple expressions. --- - --- snowflake sql: -WITH a AS (SELECT 1, 2, 3), - b AS (SELECT 4, 5, 6), - c AS (SELECT * FROM a) -SELECT * from b -UNION -SELECT * FROM c; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3), - b AS (SELECT 4, 5, 6), - c AS (SELECT * FROM a) -(SELECT * from b) -UNION -(SELECT * FROM c); diff --git a/tests/resources/functional/snowflake/core_engine/test_cte/nested_set_operation.sql b/tests/resources/functional/snowflake/core_engine/test_cte/nested_set_operation.sql deleted file mode 100644 index 43e5d39189..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_cte/nested_set_operation.sql +++ /dev/null @@ -1,19 +0,0 @@ --- --- Verify a CTE that includes set operations. --- - --- snowflake sql: -WITH a AS ( - SELECT 1, 2, 3 - UNION - SELECT 4, 5, 6 -) -SELECT * FROM a; - --- databricks sql: -WITH a AS ( - (SELECT 1, 2, 3) - UNION - (SELECT 4, 5, 6) -) -SELECT * FROM a; diff --git a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_1.sql b/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_1.sql deleted file mode 100644 index 253aac2f17..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_1.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Note that here we have two commas in the select clause and although in other circumstances, --- the parser could notice that is an additional comma, in this case it is not able to do so because --- what can be in between the comma is just about anything. Then because any ID is accepted as --- possibly being some kind of command, then the parser has to assume that the following tokens --- are some valid command. --- Hence this error is thrown by a no viable alternative at input ',' and the parser recovers to something --- that looks like it is a valid command because of the let rule where LET is optional and the next token --- is an ID, which is therefore predicted and we will accumulate a lot of erroneous errors. - --- snowflake sql: -select col1,, col2 from table_name; - --- databricks sql: -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: select col1,, - */ -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: select - Unparsable text: col1 - Unparsable text: , - Unparsable text: , - Unparsable text: col2 - Unparsable text: from - Unparsable text: table_name - Unparsable text: parser recovered by ignoring: select col1,, col2 from table_name; - */ diff --git a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_2.sql b/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_2.sql deleted file mode 100644 index 8acd8c794b..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -* - --- databricks sql: -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: unexpected extra input '*' while parsing a Snowflake batch - expecting one of: End of batch, Select Statement, Statement, '(', ';', 'CALL', 'COMMENT', 'DECLARE', 'GET', 'LET', 'START', 'WITH'... - Unparsable text: * - */ diff --git a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_3.sql b/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_3.sql deleted file mode 100644 index 30a2c18378..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_invalid_syntax/syntax_error_3.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -* ; -SELECT 1 ; -SELECT A B FROM C ; - --- databricks sql: -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: unexpected extra input '*' while parsing a Snowflake batch - expecting one of: End of batch, Select Statement, Statement, '(', ';', 'CALL', 'COMMENT', 'DECLARE', 'GET', 'LET', 'START', 'WITH'... - Unparsable text: * - */ -SELECT - 1; -SELECT - A AS B -FROM - C; diff --git a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_1.sql b/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_1.sql deleted file mode 100644 index c87ed298fd..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_1.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: -ALTER SESSION SET QUERY_TAG = 'tag1'; - --- databricks sql: -/* The following issues were detected: - - Unknown ALTER command variant - ALTER SESSION SET QUERY_TAG = 'tag1' - */ diff --git a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_5.sql b/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_5.sql deleted file mode 100644 index 1e8f6ea25c..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_5.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: -CREATE STREAM mystream ON TABLE mytable; - --- databricks sql: -/* The following issues were detected: - - CREATE STREAM UNSUPPORTED - CREATE STREAM mystream ON TABLE mytable - */ diff --git a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_6.sql b/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_6.sql deleted file mode 100644 index 3470cc6ae9..0000000000 --- a/tests/resources/functional/snowflake/core_engine/test_skip_unsupported_operations/test_skip_unsupported_operations_6.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: -ALTER STREAM mystream SET COMMENT = 'New comment for stream'; - --- databricks sql: -/* The following issues were detected: - - Unknown ALTER command variant - ALTER STREAM mystream SET COMMENT = 'New comment for stream' - */ diff --git a/tests/resources/functional/snowflake/cte/cte_with_column_list.sql b/tests/resources/functional/snowflake/cte/cte_with_column_list.sql deleted file mode 100644 index a984432f14..0000000000 --- a/tests/resources/functional/snowflake/cte/cte_with_column_list.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- A simple CTE, with the column list expressed. --- - --- snowflake sql: -WITH a (b, c, d) AS (SELECT 1 AS b, 2 AS c, 3 AS d) -SELECT b, c, d FROM a; - --- databricks sql: -WITH a (b, c, d) AS (SELECT 1 AS b, 2 AS c, 3 AS d) -SELECT b, c, d FROM a; diff --git a/tests/resources/functional/snowflake/cte/simple_cte.sql b/tests/resources/functional/snowflake/cte/simple_cte.sql deleted file mode 100644 index cf15cca593..0000000000 --- a/tests/resources/functional/snowflake/cte/simple_cte.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- Verify a simple CTE. --- - --- snowflake sql: -WITH a AS (SELECT 1, 2, 3) -SELECT * FROM a; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3) -SELECT * FROM a; diff --git a/tests/resources/functional/snowflake/ddl/alter/test_alter_1.sql b/tests/resources/functional/snowflake/ddl/alter/test_alter_1.sql deleted file mode 100644 index 842b198836..0000000000 --- a/tests/resources/functional/snowflake/ddl/alter/test_alter_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -ALTER TABLE employees ADD COLUMN first_name VARCHAR(50); - --- databricks sql: -ALTER TABLE employees ADD COLUMN first_name STRING; diff --git a/tests/resources/functional/snowflake/ddl/alter/test_alter_2.sql b/tests/resources/functional/snowflake/ddl/alter/test_alter_2.sql deleted file mode 100644 index 554a58a46d..0000000000 --- a/tests/resources/functional/snowflake/ddl/alter/test_alter_2.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -ALTER TABLE employees ADD COLUMN first_name VARCHAR(50) NOT NULL, age INT, hire_date DATE; - --- databricks sql: -ALTER TABLE employees ADD COLUMN first_name STRING NOT NULL, age DECIMAL(38, 0), hire_date DATE; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_1.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_1.sql deleted file mode 100644 index 31f27b7f93..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_1.sql +++ /dev/null @@ -1,17 +0,0 @@ --- snowflake sql: -SELECT - p.info:id AS "ID", - p.info:first AS "First", - p.info:first.b AS C -FROM - (SELECT PARSE_JSON('{"id": {"a":{"c":"102","d":"106"}}, "first": {"b":"105"}}')) AS p(info); - --- databricks sql: -SELECT - p.info:id AS `ID`, - p.info:first AS `First`, - p.info:first.b AS C -FROM ( - SELECT - PARSE_JSON('{"id": {"a":{"c":"102","d":"106"}}, "first": {"b":"105"}}') -) AS p(info); diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_10.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_10.sql deleted file mode 100644 index 19dd4ebbe6..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_10.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - tt.id, - lit.value: details AS details -FROM VALUES - (1, '{"order": {"id": 101,"items": [{"item_id": "A1","quantity": 2,"details": {"color": "red"}},{"item_id": "B2","quantity": 5,"details": {"color": "blue"}}]}}'), - (2, '{"order": {"id": 202,"items": [{"item_id": "C3","quantity": 4,"details": {"color": "green", "size": "L"}},{"item_id": "D4","quantity": 3,"details": {"color": "yellow", "size": "M"}}]}}') -AS tt(id, resp) -, LATERAL FLATTEN(input => PARSE_JSON(tt.resp):order.items) AS lit - --- databricks sql: -SELECT -tt.id, -lit.value:details AS details -FROM VALUES - (1, '{"order": {"id": 101,"items": [{"item_id": "A1","quantity": 2,"details": {"color": "red"}},{"item_id": "B2","quantity": 5,"details": {"color": "blue"}}]}}'), - (2, '{"order": {"id": 202,"items": [{"item_id": "C3","quantity": 4,"details": {"color": "green", "size": "L"}},{"item_id": "D4","quantity": 3,"details": {"color": "yellow", "size": "M"}}]}}') -AS tt(id, resp) -, LATERAL VARIANT_EXPLODE(PARSE_JSON(tt.resp):order.items) AS lit; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_11.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_11.sql deleted file mode 100644 index f56ad0d25b..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_11.sql +++ /dev/null @@ -1,16 +0,0 @@ --- snowflake sql: -SELECT - demo.level_key:"level_1_key":"level_2_key"['1'] AS col -FROM - ( - SELECT - PARSE_JSON('{"level_1_key": { "level_2_key": { "1": "desired_value" }}}') AS level_key - ) AS demo; - --- databricks sql: -SELECT - demo.level_key:level_1_key.level_2_key["1"] AS col -FROM ( - SELECT - PARSE_JSON('{"level_1_key": { "level_2_key": { "1": "desired_value" }}}') AS level_key -) AS demo; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_12.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_12.sql deleted file mode 100644 index 33e16cb8d8..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_12.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - verticals.index AS index, - verticals.value AS array_val - FROM - ( - select ARRAY_CONSTRUCT('value1', 'value2', 'value3') as col - ) AS sample_data(array_column), - LATERAL FLATTEN(input => sample_data.array_column, OUTER => true) AS verticals; - --- databricks sql: -SELECT - verticals.index AS index, - verticals.value AS array_val -FROM ( - SELECT - ARRAY('value1', 'value2', 'value3') AS col -) AS sample_data(array_column) - LATERAL VIEW OUTER POSEXPLODE(sample_data.array_column) verticals AS index, value; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_2.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_2.sql deleted file mode 100644 index 73ea10d71e..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_2.sql +++ /dev/null @@ -1,25 +0,0 @@ --- snowflake sql: -SELECT - f.value:name AS "Contact", - f.value:first, - CAST(p.col:a:info:id AS DOUBLE) AS "id_parsed", - p.col:b:first, - p.col:a:info -FROM - (SELECT - PARSE_JSON('{"a": {"info": {"id": 101, "first": "John" }, "contact": [{"name": "Alice", "first": "A"}, {"name": "Bob", "first": "B"}]}, "b": {"id": 101, "first": "John"}}') - ) AS p(col) -, LATERAL FLATTEN(input => p.col:a:contact) AS f; - --- databricks sql: -SELECT - f.value:name AS `Contact`, - f.value:first, - CAST(p.col:a.info.id AS DOUBLE) AS `id_parsed`, - p.col:b.first, - p.col:a.info -FROM ( - SELECT - PARSE_JSON('{"a": {"info": {"id": 101, "first": "John" }, "contact": [{"name": "Alice", "first": "A"}, {"name": "Bob", "first": "B"}]}, "b": {"id": 101, "first": "John"}}') -) AS p(col) -, LATERAL VARIANT_EXPLODE(p.col:a.contact) AS f; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_3.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_3.sql deleted file mode 100644 index efb6f94120..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_3.sql +++ /dev/null @@ -1,35 +0,0 @@ --- snowflake sql: -SELECT - d.col:display_position::NUMBER AS display_position, - i.value:attributes::VARCHAR AS attributes, - CAST(CURRENT_TIMESTAMP() AS TIMESTAMP_NTZ(9)) AS created_at, - i.value:prop::FLOAT AS prop, - d.col:candidates AS candidates -FROM - ( - SELECT - PARSE_JSON('{"display_position": 123, "impressions": [{"attributes": "some_attributes", "prop": 12.34}, {"attributes": "other_attributes", "prop": 56.78}], "candidates": "some_candidates"}') AS col, - '2024-08-28' AS event_date, - 'store.replacements_view' AS event_name - ) AS d, - LATERAL FLATTEN(input => d.col:impressions, outer => true) AS i -WHERE - d.event_date = '2024-08-28' - AND d.event_name IN ('store.replacements_view'); - --- databricks sql: -SELECT - CAST(d.col:display_position AS DECIMAL(38, 0)) AS display_position, - CAST(i.value:attributes AS STRING) AS attributes, - CAST(CURRENT_TIMESTAMP() AS TIMESTAMP_NTZ) AS created_at, - CAST(i.value:prop AS DOUBLE) AS prop, - d.col:candidates AS candidates -FROM ( - SELECT - PARSE_JSON('{"display_position": 123, "impressions": [{"attributes": "some_attributes", "prop": 12.34}, {"attributes": "other_attributes", "prop": 56.78}], "candidates": "some_candidates"}') AS col, - '2024-08-28' AS event_date, - 'store.replacements_view' AS event_name -) AS d -, LATERAL VARIANT_EXPLODE_OUTER(d.col:impressions) AS i -WHERE - d.event_date = '2024-08-28' AND d.event_name IN ('store.replacements_view'); diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_4.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_4.sql deleted file mode 100644 index 3dcb2623d3..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_4.sql +++ /dev/null @@ -1,23 +0,0 @@ --- snowflake sql: -SELECT - tt.col:id AS tax_transaction_id, - CAST(tt.col:responseBody.isMpfState AS BOOLEAN) AS is_mpf_state, - REGEXP_REPLACE(tt.col:requestBody.deliveryLocation.city, '-', '') AS delivery_city, - REGEXP_REPLACE(tt.col:requestBody.store.storeAddress.zipCode, '=', '') AS store_zipcode -FROM ( - SELECT - PARSE_JSON('{"id": 1, "responseBody": { "isMpfState": true }, "requestBody": { "deliveryLocation": { "city": "New-York" }, "store": {"storeAddress": {"zipCode": "100=01"}}}}') - AS col -) AS tt; - --- databricks sql: -SELECT - tt.col:id AS tax_transaction_id, - CAST(tt.col:responseBody.isMpfState AS BOOLEAN) AS is_mpf_state, - REGEXP_REPLACE(tt.col:requestBody.deliveryLocation.city, '-', '') AS delivery_city, - REGEXP_REPLACE(tt.col:requestBody.store.storeAddress.zipCode, '=', '') AS store_zipcode -FROM ( - SELECT - PARSE_JSON('{"id": 1, "responseBody": { "isMpfState": true }, "requestBody": { "deliveryLocation": { "city": "New-York" }, "store": {"storeAddress": {"zipCode": "100=01"}}}}') - AS col -) AS tt; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_5.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_5.sql deleted file mode 100644 index 0b42edbfe1..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_5.sql +++ /dev/null @@ -1,23 +0,0 @@ --- snowflake sql: -SELECT - varchar1, - CAST(float1 AS STRING) AS float1_as_string, - CAST(variant1:Loan_Number AS STRING) AS loan_number_as_string -FROM - (SELECT - 'example_varchar' AS varchar1, - 123.456 AS float1, - PARSE_JSON('{"Loan_Number": "LN789"}') AS variant1 - ) AS tmp; - --- databricks sql: -SELECT - varchar1, - CAST(float1 AS STRING) AS float1_as_string, - CAST(variant1:Loan_Number AS STRING) AS loan_number_as_string -FROM ( - SELECT - 'example_varchar' AS varchar1, - 123.456 AS float1, - PARSE_JSON('{"Loan_Number": "LN789"}') AS variant1 -) AS tmp; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_6.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_6.sql deleted file mode 100644 index 3b3c42fd2e..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_6.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT ARRAY_EXCEPT([{'a': 1, 'b': 2}, 1], [{'a': 1, 'b': 2}, 3]); - --- databricks sql: -SELECT ARRAY_EXCEPT(ARRAY(STRUCT(1 AS a, 2 AS b), 1), ARRAY(STRUCT(1 AS a, 2 AS b), 3)); diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_7.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_7.sql deleted file mode 100644 index bc206f75ac..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_7.sql +++ /dev/null @@ -1,18 +0,0 @@ --- snowflake sql: -SELECT - v, - v:food AS food, - TO_JSON(v) AS v_as_json -FROM ( - SELECT PARSE_JSON('{"food": "apple"}') AS v -) t; - --- databricks sql: -SELECT - v, - v:food AS food, - TO_JSON(v) AS v_as_json -FROM ( - SELECT - PARSE_JSON('{"food": "apple"}') AS v -) AS t; diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_8.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_8.sql deleted file mode 100644 index 65404c060b..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_8.sql +++ /dev/null @@ -1,12 +0,0 @@ --- snowflake sql: -SELECT PARSE_JSON(src.col):c AS c -FROM VALUES - ('{"a": "1", "b": "2", "c": null}'), - ('{"a": "1", "b": "2", "c": "3"}') AS src(col); - --- databricks sql: -SELECT - PARSE_JSON(src.col):c AS c -FROM VALUES - ('{"a": "1", "b": "2", "c": null}'), - ('{"a": "1", "b": "2", "c": "3"}') AS src(col); diff --git a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_9.sql b/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_9.sql deleted file mode 100644 index a7e7bcc8f6..0000000000 --- a/tests/resources/functional/snowflake/ddl/lateral_struct/test_lateral_struct_9.sql +++ /dev/null @@ -1,44 +0,0 @@ --- snowflake sql: -SELECT - los.value:"objectDomain"::STRING AS object_type, - los.value:"objectName"::STRING AS object_name, - cols.value:"columnName"::STRING AS column_name, - COUNT(DISTINCT lah:"query_token"::STRING) AS n_queries, - COUNT(DISTINCT lah:"consumer_account_locator"::STRING) AS n_distinct_consumer_accounts -FROM - (SELECT - PARSE_JSON('{"query_date": "2022-03-02","query_token": "some_token","consumer_account_locator": "CONSUMER_ACCOUNT_LOCATOR","listing_objects_accessed": [{"objectDomain": "Table","objectName": "DATABASE_NAME.SCHEMA_NAME.TABLE_NAME","columns": [{"columnName": "column1"},{"columnName": "column2"}]}]}') AS lah - ) AS src, - LATERAL FLATTEN(input => src.lah:"listing_objects_accessed") AS los, - LATERAL FLATTEN(input => los.value:"columns") AS cols -WHERE - los.value:"objectDomain"::STRING IN ('Table', 'View') AND - src.lah:"query_date"::DATE BETWEEN '2022-03-01' AND '2022-04-30' AND - los.value:"objectName"::STRING = 'DATABASE_NAME.SCHEMA_NAME.TABLE_NAME' AND - src.lah:"consumer_account_locator"::STRING = 'CONSUMER_ACCOUNT_LOCATOR' -GROUP BY 1, 2, 3; - --- databricks sql: -SELECT - CAST(los.value:objectDomain AS STRING) AS object_type, - CAST(los.value:objectName AS STRING) AS object_name, - CAST(cols.value:columnName AS STRING) AS column_name, - COUNT(DISTINCT CAST(lah:query_token AS STRING)) AS n_queries, - COUNT(DISTINCT CAST(lah:consumer_account_locator AS STRING)) AS n_distinct_consumer_accounts -FROM ( - SELECT - PARSE_JSON( - '{"query_date": "2022-03-02","query_token": "some_token","consumer_account_locator": "CONSUMER_ACCOUNT_LOCATOR","listing_objects_accessed": [{"objectDomain": "Table","objectName": "DATABASE_NAME.SCHEMA_NAME.TABLE_NAME","columns": [{"columnName": "column1"},{"columnName": "column2"}]}]}' - ) AS lah -) AS src - , LATERAL VARIANT_EXPLODE(src.lah:listing_objects_accessed) AS los - , LATERAL VARIANT_EXPLODE(los.value:columns) AS cols -WHERE - CAST(los.value:objectDomain AS STRING) IN ('Table', 'View') - AND CAST(src.lah:query_date AS DATE) BETWEEN '2022-03-01' AND '2022-04-30' - AND CAST(los.value:objectName AS STRING) = 'DATABASE_NAME.SCHEMA_NAME.TABLE_NAME' - AND CAST(src.lah:consumer_account_locator AS STRING) = 'CONSUMER_ACCOUNT_LOCATOR' -GROUP BY - 1, - 2, - 3; diff --git a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_1.sql b/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_1.sql deleted file mode 100644 index c2d74214a2..0000000000 --- a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT OBJECT_CONSTRUCT('a',1,'b','BBBB', 'c',null); - --- databricks sql: -SELECT STRUCT(1 AS a, 'BBBB' AS b, NULL AS c); diff --git a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_2.sql b/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_2.sql deleted file mode 100644 index 414f2c5b06..0000000000 --- a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT OBJECT_CONSTRUCT(*) AS oc FROM demo_table_1 ; - --- databricks sql: -SELECT STRUCT(*) AS oc FROM demo_table_1; diff --git a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_3.sql b/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_3.sql deleted file mode 100644 index 4e5616e26c..0000000000 --- a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT OBJECT_CONSTRUCT(*) FROM VALUES(1,'x'), (2,'y'); - --- databricks sql: -SELECT STRUCT(*) FROM VALUES (1, 'x'), (2, 'y'); diff --git a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_4.sql b/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_4.sql deleted file mode 100644 index 732ba4d38d..0000000000 --- a/tests/resources/functional/snowflake/ddl/object_construct/test_object_construct_4.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT OBJECT_CONSTRUCT('Key_One', PARSE_JSON('NULL'), 'Key_Two', NULL, 'Key_Three', 'null') as obj; - --- databricks sql: -SELECT STRUCT(PARSE_JSON('NULL') AS Key_One, NULL AS Key_Two, 'null' AS Key_Three) AS obj; diff --git a/tests/resources/functional/snowflake/ddl/test_cras_simple.sql b/tests/resources/functional/snowflake/ddl/test_cras_simple.sql deleted file mode 100644 index 8e54df800d..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_cras_simple.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -CREATE OR REPLACE TABLE employee as SELECT employee_id, name FROM employee_stage; - --- databricks sql: -CREATE OR REPLACE TABLE employee as SELECT employee_id, name FROM employee_stage; diff --git a/tests/resources/functional/snowflake/ddl/test_create_ddl_1.sql b/tests/resources/functional/snowflake/ddl/test_create_ddl_1.sql deleted file mode 100644 index e70a5cc682..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_create_ddl_1.sql +++ /dev/null @@ -1,22 +0,0 @@ --- snowflake sql: -CREATE TABLE employee (employee_id INT, - first_name VARCHAR(50) NOT NULL, - last_name VARCHAR(50) NOT NULL, - birth_date DATE, - hire_date DATE, - salary DECIMAL(10, 2), - department_id INT, - remarks VARIANT) -; - --- databricks sql: -CREATE TABLE employee ( - employee_id DECIMAL(38, 0), - first_name STRING NOT NULL, - last_name STRING NOT NULL, - birth_date DATE, - hire_date DATE, - salary DECIMAL(10, 2), - department_id DECIMAL(38, 0), - remarks VARIANT -); diff --git a/tests/resources/functional/snowflake/ddl/test_create_ddl_2.sql b/tests/resources/functional/snowflake/ddl/test_create_ddl_2.sql deleted file mode 100644 index a09b654752..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_create_ddl_2.sql +++ /dev/null @@ -1,13 +0,0 @@ --- snowflake sql: -CREATE TABLE employee (employee_id INT DEFAULT 3000, - first_name VARCHAR(50) NOT NULL, - last_name VARCHAR(50) NOT NULL - ) -; - --- databricks sql: -CREATE TABLE employee ( - employee_id DECIMAL(38, 0) DEFAULT 3000, - first_name STRING NOT NULL, - last_name STRING NOT NULL -); diff --git a/tests/resources/functional/snowflake/ddl/test_create_ddl_identity.sql b/tests/resources/functional/snowflake/ddl/test_create_ddl_identity.sql deleted file mode 100644 index 99d2e38e44..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_create_ddl_identity.sql +++ /dev/null @@ -1,20 +0,0 @@ --- snowflake sql: - -CREATE OR REPLACE TABLE sales_data ( - sale_id INT AUTOINCREMENT, - product_id INT, - quantity INT, - sale_amount DECIMAL(10, 2), - sale_date DATE, - customer_id INT -); - --- databricks sql: -CREATE OR REPLACE TABLE sales_data ( - sale_id DECIMAL(38, 0) GENERATED ALWAYS AS IDENTITY, - product_id DECIMAL(38, 0), - quantity DECIMAL(38, 0), - sale_amount DECIMAL(10, 2), - sale_date DATE, - customer_id DECIMAL(38, 0) -); diff --git a/tests/resources/functional/snowflake/ddl/test_ctas_complex.sql b/tests/resources/functional/snowflake/ddl/test_ctas_complex.sql deleted file mode 100644 index 8e6b8c172d..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_ctas_complex.sql +++ /dev/null @@ -1,39 +0,0 @@ --- snowflake sql: -CREATE TABLE employee_summary AS -SELECT - e.employee_id, - e.first_name, - e.last_name, - e.salary, - d.department_name, - CASE - WHEN e.salary > 100000 THEN 'High' - WHEN e.salary BETWEEN 50000 AND 100000 THEN 'Medium' - ELSE 'Low' - END AS salary_range, - YEAR(e.hire_date) AS hire_year -FROM - employee e -JOIN - department d ON e.department_id = d.department_id -; - --- databricks sql: -CREATE TABLE employee_summary AS -SELECT - e.employee_id, - e.first_name, - e.last_name, - e.salary, - d.department_name, - CASE - WHEN e.salary > 100000 - THEN 'High' - WHEN e.salary BETWEEN 50000 AND 100000 - THEN 'Medium' - ELSE 'Low' - END AS salary_range, - YEAR(e.hire_date) AS hire_year -FROM employee AS e -JOIN department AS d - ON e.department_id = d.department_id ; diff --git a/tests/resources/functional/snowflake/ddl/test_ctas_simple.sql b/tests/resources/functional/snowflake/ddl/test_ctas_simple.sql deleted file mode 100644 index a43fdfcabc..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_ctas_simple.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -CREATE TABLE employee as SELECT employee_id, name FROM employee_stage; - --- databricks sql: -CREATE TABLE employee as SELECT employee_id, name FROM employee_stage; diff --git a/tests/resources/functional/snowflake/ddl/test_current_database_1.sql b/tests/resources/functional/snowflake/ddl/test_current_database_1.sql deleted file mode 100644 index 05b2019f27..0000000000 --- a/tests/resources/functional/snowflake/ddl/test_current_database_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT current_database() AS current_database_col1 FROM tabl; - --- databricks sql: -SELECT CURRENT_DATABASE() AS current_database_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/dml/insert/test_insert_1.sql b/tests/resources/functional/snowflake/dml/insert/test_insert_1.sql deleted file mode 100644 index 4d331bda0b..0000000000 --- a/tests/resources/functional/snowflake/dml/insert/test_insert_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -INSERT INTO foo VALUES (1, 'bar', true), (1, 'qux', false); - --- databricks sql: -INSERT INTO foo VALUES (1, 'bar', true), (1, 'qux', false); diff --git a/tests/resources/functional/snowflake/dml/insert/test_insert_2.sql b/tests/resources/functional/snowflake/dml/insert/test_insert_2.sql deleted file mode 100644 index af8e82be20..0000000000 --- a/tests/resources/functional/snowflake/dml/insert/test_insert_2.sql +++ /dev/null @@ -1,8 +0,0 @@ - - --- snowflake sql: -INSERT INTO table1 SELECT * FROM table2; - --- databricks sql: - -INSERT INTO table1 SELECT * FROM table2; diff --git a/tests/resources/functional/snowflake/dml/insert/test_insert_3.sql b/tests/resources/functional/snowflake/dml/insert/test_insert_3.sql deleted file mode 100644 index 3121b2f279..0000000000 --- a/tests/resources/functional/snowflake/dml/insert/test_insert_3.sql +++ /dev/null @@ -1,17 +0,0 @@ --- snowflake sql: -INSERT INTO foo (c1, c2, c3) - SELECT x, y, z FROM bar WHERE x > z AND y = 'qux'; - --- databricks sql: -INSERT INTO foo ( - c1, - c2, - c3 -) -SELECT - x, - y, - z -FROM bar -WHERE - x > z AND y = 'qux'; diff --git a/tests/resources/functional/snowflake/dml/insert/test_insert_overwrite_1.sql b/tests/resources/functional/snowflake/dml/insert/test_insert_overwrite_1.sql deleted file mode 100644 index 439ccb2570..0000000000 --- a/tests/resources/functional/snowflake/dml/insert/test_insert_overwrite_1.sql +++ /dev/null @@ -1,8 +0,0 @@ - - --- snowflake sql: -INSERT OVERWRITE INTO foo VALUES (1, 2, 3); - --- databricks sql: - -INSERT OVERWRITE TABLE foo VALUES (1, 2, 3); diff --git a/tests/resources/functional/snowflake/dml/test_delete.sql b/tests/resources/functional/snowflake/dml/test_delete.sql deleted file mode 100644 index e15d214b2d..0000000000 --- a/tests/resources/functional/snowflake/dml/test_delete.sql +++ /dev/null @@ -1,6 +0,0 @@ --- snowflake sql: - -DELETE FROM t1 WHERE t1.c1 > 42; - --- databricks sql: -DELETE FROM t1 WHERE t1.c1 > 42; diff --git a/tests/resources/functional/snowflake/dml/test_delete_subquery.sql b/tests/resources/functional/snowflake/dml/test_delete_subquery.sql deleted file mode 100644 index 864912774e..0000000000 --- a/tests/resources/functional/snowflake/dml/test_delete_subquery.sql +++ /dev/null @@ -1,13 +0,0 @@ --- snowflake sql: -DELETE FROM table1 AS t1 USING (SELECT c2 FROM table2 WHERE t2.c3 = 'foo') AS t2 WHERE t1.c1 = t2.c2; - --- databricks sql: -MERGE INTO table1 AS t1 USING ( - SELECT - c2 - FROM table2 - WHERE - t2.c3 = 'foo' -) AS t2 -ON - t1.c1 = t2.c2 WHEN MATCHED THEN DELETE; diff --git a/tests/resources/functional/snowflake/dml/test_delete_using.sql b/tests/resources/functional/snowflake/dml/test_delete_using.sql deleted file mode 100644 index f1982b25d2..0000000000 --- a/tests/resources/functional/snowflake/dml/test_delete_using.sql +++ /dev/null @@ -1,6 +0,0 @@ --- snowflake sql: - -DELETE FROM t1 USING t2 WHERE t1.c1 = t2.c2; - --- databricks sql: -MERGE INTO t1 USING t2 ON t1.c1 = t2.c2 WHEN MATCHED THEN DELETE; diff --git a/tests/resources/functional/snowflake/dml/test_delete_using_where.sql b/tests/resources/functional/snowflake/dml/test_delete_using_where.sql deleted file mode 100644 index 29d6ae2f8f..0000000000 --- a/tests/resources/functional/snowflake/dml/test_delete_using_where.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -DELETE FROM table1 USING table2 WHERE table1.id = table2.id; - --- databricks sql: -MERGE INTO table1 USING table2 ON table1.id = table2.id WHEN MATCHED THEN DELETE; diff --git a/tests/resources/functional/snowflake/dml/test_delete_where.sql b/tests/resources/functional/snowflake/dml/test_delete_where.sql deleted file mode 100644 index 027b22c99b..0000000000 --- a/tests/resources/functional/snowflake/dml/test_delete_where.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -DELETE FROM employee WHERE employee_id = 1; - --- databricks sql: -DELETE FROM employee WHERE employee_id = 1; diff --git a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_1.sql b/tests/resources/functional/snowflake/dml/update/test_update_from_dml_1.sql deleted file mode 100644 index 214826f50b..0000000000 --- a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_1.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: -UPDATE t1 - SET column1 = t1.column1 + t2.column1, column3 = 'success' - FROM t2 - WHERE t1.key = t2.t1_key and t1.column1 < 10; - --- databricks sql: -MERGE INTO t1 USING t2 ON t1.key = t2.t1_key and t1.column1 < 10 WHEN MATCHED THEN UPDATE SET column1 = t1.column1 + t2.column1, -column3 = 'success'; diff --git a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_2.sql b/tests/resources/functional/snowflake/dml/update/test_update_from_dml_2.sql deleted file mode 100644 index b29fad59d5..0000000000 --- a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_2.sql +++ /dev/null @@ -1,18 +0,0 @@ --- snowflake sql: -UPDATE target -SET v = b.v -FROM (SELECT k, MIN(v) v FROM src GROUP BY k) b -WHERE target.k = b.k; - --- databricks sql: -MERGE INTO target -USING ( - SELECT - k, - MIN(v) AS v - FROM src - GROUP BY - k -) AS b -ON - target.k = b.k WHEN MATCHED THEN UPDATE SET v = b.v; diff --git a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_3.sql b/tests/resources/functional/snowflake/dml/update/test_update_from_dml_3.sql deleted file mode 100644 index ad87606ed7..0000000000 --- a/tests/resources/functional/snowflake/dml/update/test_update_from_dml_3.sql +++ /dev/null @@ -1,16 +0,0 @@ --- snowflake sql: -UPDATE orders t1 -SET order_status = 'returned' -WHERE EXISTS (SELECT oid FROM returned_orders WHERE t1.oid = oid); - --- databricks sql: -UPDATE orders AS t1 SET order_status = 'returned' -WHERE - EXISTS( - SELECT - oid - FROM returned_orders - WHERE - t1.oid = oid - ) -; diff --git a/tests/resources/functional/snowflake/functions/conversion/is_integer_1.sql b/tests/resources/functional/snowflake/functions/conversion/is_integer_1.sql deleted file mode 100644 index f4b6c17e44..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/is_integer_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -select IS_INTEGER(col); - --- databricks sql: -SELECT - - CASE - WHEN col IS NULL THEN NULL - WHEN col RLIKE '^-?[0-9]+$' AND TRY_CAST(col AS INT) IS NOT NULL THEN true - ELSE false - END; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_1.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_1.sql deleted file mode 100644 index e25a88d647..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_DECIMAL('$345', '$999.00') AS col1; - --- databricks sql: -SELECT TO_NUMBER('$345', '$999.00') AS col1; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_2.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_2.sql deleted file mode 100644 index 5e72502446..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMERIC('$345', '$999.99') AS num; - --- databricks sql: -SELECT TO_NUMBER('$345', '$999.99') AS num; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_3.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_3.sql deleted file mode 100644 index e2188339b2..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMBER('$345', '$999.99') AS num; - --- databricks sql: -SELECT TO_NUMBER('$345', '$999.99') AS num; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_4.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_4.sql deleted file mode 100644 index 0b0669edf4..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_4.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT TO_DECIMAL(col1, '$999.099'), - TO_NUMERIC(tbl.col2, '$999,099.99') FROM dummy tbl; - --- databricks sql: -SELECT TO_NUMBER(col1, '$999.099'), - TO_NUMBER(tbl.col2, '$999,099.99') FROM dummy AS tbl; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_5.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_5.sql deleted file mode 100644 index 57e069837b..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMERIC('$345', '$999.99', 5, 2) AS num_with_scale; - --- databricks sql: -SELECT CAST(TO_NUMBER('$345', '$999.99') AS DECIMAL(5, 2)) AS num_with_scale; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_6.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_6.sql deleted file mode 100644 index fddd8f67d4..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_6.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_DECIMAL('$755', '$999.00', 15, 5) AS num_with_scale; - --- databricks sql: -SELECT CAST(TO_NUMBER('$755', '$999.00') AS DECIMAL(15, 5)) AS num_with_scale; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_7.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_7.sql deleted file mode 100644 index 7e8a07ab1c..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_7.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMERIC(sm.col1, '$999.00', 15, 5) AS col1, - TO_NUMBER(sm.col2, '$99.00', 15, 5) AS col2 FROM sales_reports sm; - --- databricks sql: -SELECT CAST(TO_NUMBER(sm.col1, '$999.00') AS DECIMAL(15, 5)) AS col1, - CAST(TO_NUMBER(sm.col2, '$99.00') AS DECIMAL(15, 5)) AS col2 FROM sales_reports AS sm; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_8.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_8.sql deleted file mode 100644 index 4868208c75..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_8.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMERIC(col1, 15, 5) AS col1 FROM sales_reports; - --- databricks sql: -SELECT CAST(col1 AS DECIMAL(15, 5)) AS col1 FROM sales_reports; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_9.sql b/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_9.sql deleted file mode 100644 index b7cf06e0fa..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_to_number/test_to_number_9.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select TO_NUMBER(EXPR) from test_tbl; - --- databricks sql: -SELECT CAST(EXPR AS DECIMAL(38, 0)) FROM test_tbl; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_1.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_1.sql deleted file mode 100644 index 2f2bc3a077..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT try_cast('10' AS INT); - --- databricks sql: -SELECT TRY_CAST('10' AS DECIMAL(38, 0)); diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_2.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_2.sql deleted file mode 100644 index 9cbc141123..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_cast/test_try_cast_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT try_cast(col1 AS FLOAT) AS try_cast_col1 FROM tabl; - --- databricks sql: -SELECT TRY_CAST(col1 AS DOUBLE) AS try_cast_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_date/test_try_to_date_2.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_date/test_try_to_date_2.sql deleted file mode 100644 index dd534dd1ba..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_date/test_try_to_date_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DATE('2023-25-09', 'yyyy-dd-MM'); - --- databricks sql: -SELECT DATE(TRY_TO_TIMESTAMP('2023-25-09', 'yyyy-dd-MM')); diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_1.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_1.sql deleted file mode 100644 index 9b51202dab..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DECIMAL('$345', '$999.00') AS col1; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER('$345', '$999.00') AS DECIMAL(38, 0)) AS col1; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_2.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_2.sql deleted file mode 100644 index 9c3d1628d0..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_NUMERIC('$345', '$999.99') AS num; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER('$345', '$999.99') AS DECIMAL(38, 0)) AS num; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_3.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_3.sql deleted file mode 100644 index 91e8b9bfe5..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_NUMBER('$345', '$999.99') AS num; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER('$345', '$999.99') AS DECIMAL(38, 0)) AS num; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_4.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_4.sql deleted file mode 100644 index d83096118b..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_4.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DECIMAL(col1, '$999.099'), - TRY_TO_NUMERIC(tbl.col2, '$999,099.99') FROM dummy tbl; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER(col1, '$999.099') AS DECIMAL(38, 0)), - CAST(TRY_TO_NUMBER(tbl.col2, '$999,099.99') AS DECIMAL(38, 0)) FROM dummy AS tbl; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_5.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_5.sql deleted file mode 100644 index db5d337473..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_NUMERIC('$345', '$999.99', 5, 2) AS num_with_scale; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER('$345', '$999.99') AS DECIMAL(5, 2)) AS num_with_scale; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_6.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_6.sql deleted file mode 100644 index f9912a5d23..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_6.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DECIMAL('$755', '$999.00', 15, 5) AS num_with_scale; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER('$755', '$999.00') AS DECIMAL(15, 5)) AS num_with_scale; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_7.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_7.sql deleted file mode 100644 index 3fd9563fa1..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_7.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_NUMERIC(sm.col1, '$999.00', 15, 5) AS col1, - TRY_TO_NUMBER(sm.col2, '$99.00', 15, 5) AS col2 FROM sales_reports sm; - --- databricks sql: -SELECT CAST(TRY_TO_NUMBER(sm.col1, '$999.00') AS DECIMAL(15, 5)) AS col1, - CAST(TRY_TO_NUMBER(sm.col2, '$99.00') AS DECIMAL(15, 5)) AS col2 FROM sales_reports AS sm; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_8.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_8.sql deleted file mode 100644 index 7a5078671c..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_number/test_try_to_number_8.sql +++ /dev/null @@ -1,12 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_DECIMAL('$345') AS str_col, - TRY_TO_DECIMAL(99.56854634) AS num_col, - TRY_TO_DECIMAL(-4.35) AS num_col1, - TRY_TO_DECIMAL(col1) AS col1; - --- databricks sql: -SELECT CAST('$345' AS DECIMAL(38, 0)) AS str_col, - CAST(99.56854634 AS DECIMAL(38, 0)) AS num_col, - CAST(-4.35 AS DECIMAL(38, 0)) AS num_col1, - CAST(col1 AS DECIMAL(38, 0)) AS col1; diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_1.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_1.sql deleted file mode 100644 index 896a28b998..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_TIMESTAMP('2016-12-31 00:12:00'); - --- databricks sql: -SELECT TRY_TO_TIMESTAMP('2016-12-31 00:12:00'); diff --git a/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_2.sql b/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_2.sql deleted file mode 100644 index 28ebc6f5fa..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/test_try_to_timestamp/test_try_to_timestamp_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TRY_TO_TIMESTAMP('2018-05-15', 'yyyy-MM-dd'); - --- databricks sql: -SELECT TRY_TO_TIMESTAMP('2018-05-15', 'yyyy-MM-dd'); diff --git a/tests/resources/functional/snowflake/functions/conversion/to_array_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_array_1.sql deleted file mode 100644 index f90f771f56..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_array_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT to_array(col1) AS ary_col; - --- databricks sql: -SELECT IF(col1 IS NULL, NULL, ARRAY(col1)) AS ary_col; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_array_2.sql b/tests/resources/functional/snowflake/functions/conversion/to_array_2.sql deleted file mode 100644 index 9cd615ee63..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_array_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT to_array(col1,'STRING') AS ary_col; - --- databricks sql: -SELECT IF(col1 IS NULL, NULL, ARRAY(col1)) AS ary_col; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_to_boolean_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_to_boolean_1.sql deleted file mode 100644 index 02666a99a6..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_to_boolean_1.sql +++ /dev/null @@ -1,24 +0,0 @@ - --- snowflake sql: -select TO_BOOLEAN(col1); - --- databricks sql: -SELECT - - CASE - WHEN col1 IS NULL THEN NULL - WHEN TYPEOF(col1) = 'boolean' THEN BOOLEAN(col1) - WHEN TYPEOF(col1) = 'string' THEN - CASE - WHEN LOWER(col1) IN ('true', 't', 'yes', 'y', 'on', '1') THEN true - WHEN LOWER(col1) IN ('false', 'f', 'no', 'n', 'off', '0') THEN false - ELSE RAISE_ERROR('Boolean value of x is not recognized by TO_BOOLEAN') - END - WHEN TRY_CAST(col1 AS DOUBLE) IS NOT NULL THEN - CASE - WHEN ISNAN(CAST(col1 AS DOUBLE)) OR CAST(col1 AS DOUBLE) = DOUBLE('infinity') THEN - RAISE_ERROR('Invalid parameter type for TO_BOOLEAN') - ELSE CAST(col1 AS DOUBLE) != 0.0 - END - ELSE RAISE_ERROR('Invalid parameter type for TO_BOOLEAN') - END; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_try_to_boolean_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_try_to_boolean_1.sql deleted file mode 100644 index ae7fae678b..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_boolean/test_try_to_boolean_1.sql +++ /dev/null @@ -1,23 +0,0 @@ --- snowflake sql: -select TRY_TO_BOOLEAN(1); - --- databricks sql: -SELECT - - CASE - WHEN 1 IS NULL THEN NULL - WHEN TYPEOF(1) = 'boolean' THEN BOOLEAN(1) - WHEN TYPEOF(1) = 'string' THEN - CASE - WHEN LOWER(1) IN ('true', 't', 'yes', 'y', 'on', '1') THEN true - WHEN LOWER(1) IN ('false', 'f', 'no', 'n', 'off', '0') THEN false - ELSE RAISE_ERROR('Boolean value of x is not recognized by TO_BOOLEAN') - END - WHEN TRY_CAST(1 AS DOUBLE) IS NOT NULL THEN - CASE - WHEN ISNAN(CAST(1 AS DOUBLE)) OR CAST(1 AS DOUBLE) = DOUBLE('infinity') THEN - RAISE_ERROR('Invalid parameter type for TO_BOOLEAN') - ELSE CAST(1 AS DOUBLE) != 0.0 - END - ELSE NULL - END; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_double_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_double_1.sql deleted file mode 100644 index 2096205ec2..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_double_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_DOUBLE('HELLO'); - --- databricks sql: -SELECT DOUBLE('HELLO'); diff --git a/tests/resources/functional/snowflake/functions/conversion/to_json_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_json_1.sql deleted file mode 100644 index dbfb3cc092..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_json_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT to_json(col1) AS to_json_col1 FROM tabl; - --- databricks sql: -SELECT TO_JSON(col1) AS to_json_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_object_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_object_1.sql deleted file mode 100644 index d265374e0e..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_object_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT to_object(k) FROM tabl; - --- databricks sql: -SELECT TO_JSON(k) FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_rlike_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_rlike_1.sql deleted file mode 100644 index e86289a27e..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_rlike_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT RLIKE('800-456-7891','[2-9]d{2}-d{3}-d{4}') AS matches_phone_number;; - --- databricks sql: -SELECT '800-456-7891' RLIKE '[2-9]d{2}-d{3}-d{4}' AS matches_phone_number; diff --git a/tests/resources/functional/snowflake/functions/conversion/to_variant_1.sql b/tests/resources/functional/snowflake/functions/conversion/to_variant_1.sql deleted file mode 100644 index c4b285e196..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/to_variant_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT to_variant(col1) AS json_col1 FROM dummy; - --- databricks sql: -SELECT TO_JSON(col1) AS json_col1 FROM dummy; diff --git a/tests/resources/functional/snowflake/functions/conversion/tochar_1.sql b/tests/resources/functional/snowflake/functions/conversion/tochar_1.sql deleted file mode 100644 index 5caad95910..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/tochar_1.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -select to_char(column1, '">"$99.0"<"') as D2_1, - to_char(column1, '">"B9,999.0"<"') as D4_1 FROM table; - --- databricks sql: -SELECT TO_CHAR(column1, '">"$99.0"<"') AS D2_1, TO_CHAR(column1, '">"B9,999.0"<"') AS D4_1 FROM table; diff --git a/tests/resources/functional/snowflake/functions/conversion/zeroifnull_1.sql b/tests/resources/functional/snowflake/functions/conversion/zeroifnull_1.sql deleted file mode 100644 index 77ea0282c9..0000000000 --- a/tests/resources/functional/snowflake/functions/conversion/zeroifnull_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT zeroifnull(col1) AS pcol1 FROM tabl; - --- databricks sql: -SELECT IF(col1 IS NULL, 0, col1) AS pcol1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_1.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_1.sql deleted file mode 100644 index 3d1ce22883..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- snowflake sql: -SELECT datediff(yrs, TIMESTAMP'2021-02-28 12:00:00', TIMESTAMP'2021-03-28 12:00:00'); - --- databricks sql: -SELECT - DATEDIFF( - year, - CAST('2021-02-28 12:00:00' AS TIMESTAMP), - CAST('2021-03-28 12:00:00' AS TIMESTAMP) - ); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_10.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_10.sql deleted file mode 100644 index 8daaa2ddfc..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_10.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff(quarters, 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(quarter, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_11.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_11.sql deleted file mode 100644 index fa81a4b7c3..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_11.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT DATEDIFF('DAY', start, end); - --- databricks sql: -SELECT DATEDIFF(day, start, end); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_2.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_2.sql deleted file mode 100644 index a394de9787..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- snowflake sql: -SELECT datediff(years, TIMESTAMP'2021-02-28 12:00:00', TIMESTAMP'2021-03-28 12:00:00'); - --- databricks sql: -SELECT - DATEDIFF( - year, - CAST('2021-02-28 12:00:00' AS TIMESTAMP), - CAST('2021-03-28 12:00:00' AS TIMESTAMP) - ); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_3.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_3.sql deleted file mode 100644 index d47a9b2d25..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff(mm, DATE'2021-02-28', DATE'2021-03-28'); - --- databricks sql: -SELECT DATEDIFF(month, CAST('2021-02-28' AS DATE), CAST('2021-03-28' AS DATE)); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_4.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_4.sql deleted file mode 100644 index a3a89f2f3d..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff(mons, DATE'2021-02-28', DATE'2021-03-28'); - --- databricks sql: -SELECT DATEDIFF(month, CAST('2021-02-28' AS DATE), CAST('2021-03-28' AS DATE)); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_5.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_5.sql deleted file mode 100644 index 37c2682f52..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff('days', 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(day, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_6.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_6.sql deleted file mode 100644 index a4000e0e00..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_6.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff(dayofmonth, 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(day, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_7.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_7.sql deleted file mode 100644 index c86a88c0de..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_7.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff(wk, 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(week, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_8.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_8.sql deleted file mode 100644 index 580d94cf0e..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_8.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff('woy', 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(week, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_9.sql b/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_9.sql deleted file mode 100644 index dac0c29aa3..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/datediff/test_datediff_9.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT datediff('qtrs', 'start', 'end'); - --- databricks sql: -SELECT DATEDIFF(quarter, 'start', 'end'); diff --git a/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_2.sql b/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_2.sql deleted file mode 100644 index de305e0e7f..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_2.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT DAYNAME(TO_DATE('2015-05-01')) AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT(cast('2015-05-01' as DATE), 'E') AS MONTH; diff --git a/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_3.sql b/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_3.sql deleted file mode 100644 index f8c8cbdccf..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/dayname/test_dayname_3.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT DAYNAME('2015-04-03 10:00') AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT('2015-04-03 10:00', 'E') AS MONTH; diff --git a/tests/resources/functional/snowflake/functions/dates/last_day_1.sql b/tests/resources/functional/snowflake/functions/dates/last_day_1.sql deleted file mode 100644 index 75fbc38012..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/last_day_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT last_day(col1) AS last_day_col1 FROM tabl; - --- databricks sql: -SELECT LAST_DAY(col1) AS last_day_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/last_day_2.sql b/tests/resources/functional/snowflake/functions/dates/last_day_2.sql deleted file mode 100644 index 5daf6717c7..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/last_day_2.sql +++ /dev/null @@ -1,35 +0,0 @@ --- snowflake sql: -select - last_day(current_date()) as col, - last_day(current_date(), 'YEAR') as col1, - last_day(current_date(), 'QUARTER') as col2, - last_day(current_date(), 'MONTH') as col3, - last_day(current_date(), 'WEEK') as col4, - last_day(current_timestamp()) as col5, - last_day(current_timestamp(), 'YEAR') as col6, - last_day(current_timestamp(), 'QUARTER') as col7, - last_day(current_timestamp(), 'MONTH') as col8, - last_day(current_timestamp(), 'WEEK') as col9, - last_day(date('2021-01-01')) as col10, - last_day(date('2021-01-01'), 'YEAR') as col11, - last_day(date('2021-01-01'), 'QUARTER') as col12, - last_day(date('2021-01-01'), 'MONTH') as col13, - last_day(date('2021-01-01'), 'WEEK') as col14; - --- databricks sql: -SELECT - LAST_DAY(CURRENT_DATE()) AS col, - DATE_ADD(DATEADD(YEAR, 1, TRUNC(CURRENT_DATE(), 'YEAR')), -1) AS col1, - DATE_ADD(DATEADD(QUARTER, 1, TRUNC(CURRENT_DATE(), 'QUARTER')), -1) AS col2, - DATE_ADD(DATEADD(MONTH, 1, TRUNC(CURRENT_DATE(), 'MONTH')), -1) AS col3, - DATE_ADD(DATEADD(WEEK, 1, TRUNC(CURRENT_DATE(), 'WEEK')), -1) AS col4, - LAST_DAY(CURRENT_TIMESTAMP()) AS col5, - DATE_ADD(DATEADD(YEAR, 1, TRUNC(CURRENT_TIMESTAMP(), 'YEAR')), -1) AS col6, - DATE_ADD(DATEADD(QUARTER, 1, TRUNC(CURRENT_TIMESTAMP(), 'QUARTER')), -1) AS col7, - DATE_ADD(DATEADD(MONTH, 1, TRUNC(CURRENT_TIMESTAMP(), 'MONTH')), -1) AS col8, - DATE_ADD(DATEADD(WEEK, 1, TRUNC(CURRENT_TIMESTAMP(), 'WEEK')), -1) AS col9, - LAST_DAY(CAST('2021-01-01' AS DATE)) AS col10, - DATE_ADD(DATEADD(YEAR, 1, TRUNC(CAST('2021-01-01' AS DATE), 'YEAR')), -1) AS col11, - DATE_ADD(DATEADD(QUARTER, 1, TRUNC(CAST('2021-01-01' AS DATE), 'QUARTER')), -1) AS col12, - DATE_ADD(DATEADD(MONTH, 1, TRUNC(CAST('2021-01-01' AS DATE), 'MONTH')), -1) AS col13, - DATE_ADD(DATEADD(WEEK, 1, TRUNC(CAST('2021-01-01' AS DATE), 'WEEK')), -1) AS col14; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_2.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_2.sql deleted file mode 100644 index 733de222bd..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_2.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT MONTHNAME(TO_DATE('2015-05-01')) AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT(cast('2015-05-01' as DATE), 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_3.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_3.sql deleted file mode 100644 index f609a2dc1e..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_3.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT MONTHNAME(TO_DATE('2020-01-01')) AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT(cast('2020-01-01' as DATE), 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_4.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_4.sql deleted file mode 100644 index c78d6e4949..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_4.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT MONTHNAME('2015-04-03 10:00') AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT('2015-04-03 10:00', 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_5.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_5.sql deleted file mode 100644 index 68f41a3b29..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_5.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT d, MONTHNAME(d) FROM dates; - --- databricks sql: -SELECT d, DATE_FORMAT(d, 'MMM') FROM dates; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_6.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_6.sql deleted file mode 100644 index 22a9025430..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_6.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT MONTHNAME('2015-03-04') AS MON; - --- databricks sql: -SELECT DATE_FORMAT('2015-03-04', 'MMM') AS MON; diff --git a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_7.sql b/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_7.sql deleted file mode 100644 index 38b1b0a493..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/monthname/test_monthname_7.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT TO_DATE('2015.03.04', 'yyyy.dd.MM') AS MON; - --- databricks sql: -SELECT TO_DATE('2015.03.04', 'yyyy.dd.MM') AS MON; diff --git a/tests/resources/functional/snowflake/functions/dates/next_day_1.sql b/tests/resources/functional/snowflake/functions/dates/next_day_1.sql deleted file mode 100644 index 3f40beb137..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/next_day_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT next_day('2015-01-14', 'TU') AS next_day_col1 FROM tabl; - --- databricks sql: -SELECT NEXT_DAY('2015-01-14', 'TU') AS next_day_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/test_add_months_1.sql b/tests/resources/functional/snowflake/functions/dates/test_add_months_1.sql deleted file mode 100644 index 6db43df302..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_add_months_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT add_months(col1,1) AS add_months_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 1) AS add_months_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_1.sql b/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_1.sql deleted file mode 100644 index 8f9314728a..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_1.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT - CONVERT_TIMEZONE('America/Los_Angeles', 'America/New_York', '2019-01-01 14:00:00'::timestamp_ntz) - AS conv; - --- databricks sql: -SELECT CONVERT_TIMEZONE( 'America/Los_Angeles', 'America/New_York', CAST('2019-01-01 14:00:00' AS TIMESTAMP_NTZ) ) AS conv; diff --git a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_2.sql b/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_2.sql deleted file mode 100644 index 17dae6393b..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_2.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -SELECT CONVERT_TIMEZONE('America/Los_Angeles', '2018-04-05 12:00:00 +02:00') - AS conv; - --- databricks sql: -SELECT CONVERT_TIMEZONE('America/Los_Angeles', '2018-04-05 12:00:00 +02:00') AS conv; diff --git a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_3.sql b/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_3.sql deleted file mode 100644 index 14dfcfde75..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT a.col1, CONVERT_TIMEZONE('IST', a.ts_col) AS conv_ts FROM dummy a; - --- databricks sql: -SELECT a.col1, CONVERT_TIMEZONE('IST', a.ts_col) AS conv_ts FROM dummy AS a; diff --git a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_4.sql b/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_4.sql deleted file mode 100644 index 5815939572..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_4.sql +++ /dev/null @@ -1,12 +0,0 @@ - --- snowflake sql: -SELECT CURRENT_TIMESTAMP() AS now_in_la, - CONVERT_TIMEZONE('America/New_York', CURRENT_TIMESTAMP()) AS now_in_nyc, - CONVERT_TIMEZONE('Europe/Paris', CURRENT_TIMESTAMP()) AS now_in_paris, - CONVERT_TIMEZONE('Asia/Tokyo', CURRENT_TIMESTAMP()) AS now_in_tokyo; - --- databricks sql: -SELECT - CURRENT_TIMESTAMP() AS now_in_la, CONVERT_TIMEZONE('America/New_York', CURRENT_TIMESTAMP()) AS now_in_nyc, - CONVERT_TIMEZONE('Europe/Paris', CURRENT_TIMESTAMP()) AS now_in_paris, - CONVERT_TIMEZONE('Asia/Tokyo', CURRENT_TIMESTAMP()) AS now_in_tokyo; diff --git a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_5.sql b/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_5.sql deleted file mode 100644 index 2c69a98996..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_convert_timezone_5.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -SELECT - CONVERT_TIMEZONE('Europe/Warsaw', 'UTC', '2019-01-01 00:00:00 +03:00'::timestamp_ntz); - --- databricks sql: -SELECT CONVERT_TIMEZONE('Europe/Warsaw', 'UTC', CAST('2019-01-01 00:00:00 +03:00' AS TIMESTAMP_NTZ)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_current_timestamp_1.sql b/tests/resources/functional/snowflake/functions/dates/test_current_timestamp_1.sql deleted file mode 100644 index 59367d9b26..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_current_timestamp_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT current_timestamp() AS current_timestamp_col1 FROM tabl; - --- databricks sql: -SELECT CURRENT_TIMESTAMP() AS current_timestamp_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_1.sql b/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_1.sql deleted file mode 100644 index 9e8ec5056c..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select date_from_parts(1992, 6, 1); - --- databricks sql: -SELECT MAKE_DATE(1992, 6, 1); diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_2.sql b/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_2.sql deleted file mode 100644 index e513b065ec..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select date_from_parts(2023, 10, 3), date_from_parts(2020, 4, 4); - --- databricks sql: -SELECT MAKE_DATE(2023, 10, 3), MAKE_DATE(2020, 4, 4); diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_3.sql b/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_3.sql deleted file mode 100644 index c8bb8025c2..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_from_parts_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select datefromparts(2023, 10, 3), datefromparts(2020, 4, 4); - --- databricks sql: -SELECT MAKE_DATE(2023, 10, 3), MAKE_DATE(2020, 4, 4); diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_part_1.sql b/tests/resources/functional/snowflake/functions/dates/test_date_part_1.sql deleted file mode 100644 index 155237f795..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_part_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT date_part('seconds', col1) AS date_part_col1 FROM tabl; - --- databricks sql: -SELECT EXTRACT(second FROM col1) AS date_part_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_trunc_1.sql b/tests/resources/functional/snowflake/functions/dates/test_date_trunc_1.sql deleted file mode 100644 index 033f3c0d52..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_trunc_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT date_trunc('YEAR', '2015-03-05T09:32:05.359'); - --- databricks sql: -SELECT DATE_TRUNC('YEAR', '2015-03-05T09:32:05.359'); diff --git a/tests/resources/functional/snowflake/functions/dates/test_date_trunc_4.sql b/tests/resources/functional/snowflake/functions/dates/test_date_trunc_4.sql deleted file mode 100644 index c4d59631d8..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_date_trunc_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT date_trunc('MM', col1) AS date_trunc_col1 FROM tabl; - --- databricks sql: -SELECT DATE_TRUNC('MONTH', col1) AS date_trunc_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/dates/test_dateadd_1.sql b/tests/resources/functional/snowflake/functions/dates/test_dateadd_1.sql deleted file mode 100644 index ac72b82ebe..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_dateadd_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select dateadd('day', 3, '2020-02-03'::date); - --- databricks sql: -SELECT DATEADD(day, 3, CAST('2020-02-03' AS DATE)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_1.sql b/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_1.sql deleted file mode 100644 index b4c3940d5f..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timestamp_from_parts(1992, 6, 1, 12, 35, 12); - --- databricks sql: -SELECT MAKE_TIMESTAMP(1992, 6, 1, 12, 35, 12); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_2.sql b/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_2.sql deleted file mode 100644 index 9d97ace1e9..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestamp_from_parts/test_timestamp_from_parts_2.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -select TIMESTAMP_FROM_PARTS(2023, 10, 3, 14, 10, 45), - timestamp_from_parts(2020, 4, 4, 4, 5, 6); - --- databricks sql: -SELECT MAKE_TIMESTAMP(2023, 10, 3, 14, 10, 45), MAKE_TIMESTAMP(2020, 4, 4, 4, 5, 6); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_1.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_1.sql deleted file mode 100644 index ee0aa11301..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_1.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -SELECT timestampadd('hour', -1, bp.ts) AND timestampadd('day', 2, bp.ts) - FROM base_prep AS bp; - --- databricks sql: -SELECT DATEADD(hour, -1, bp.ts) AND DATEADD(day, 2, bp.ts) FROM base_prep AS bp; diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_2.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_2.sql deleted file mode 100644 index ac72b82ebe..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select dateadd('day', 3, '2020-02-03'::date); - --- databricks sql: -SELECT DATEADD(day, 3, CAST('2020-02-03' AS DATE)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_3.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_3.sql deleted file mode 100644 index 83ad689d82..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timestampadd(year, -3, '2023-02-03'); - --- databricks sql: -SELECT DATEADD(year, -3, '2023-02-03'); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_4.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_4.sql deleted file mode 100644 index 1dadb209c5..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timestampadd(year, -3, '2023-02-03 01:02'::timestamp); - --- databricks sql: -SELECT DATEADD(year, -3, CAST('2023-02-03 01:02' AS TIMESTAMP)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_5.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_5.sql deleted file mode 100644 index bb738e6802..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampadd/test_timestampadd_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timeadd(year, -3, '2023-02-03 01:02'::timestamp); - --- databricks sql: -SELECT DATEADD(year, -3, CAST('2023-02-03 01:02' AS TIMESTAMP)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_1.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_1.sql deleted file mode 100644 index a5b6db5947..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timestampDIFF(month, '2021-01-01'::timestamp, '2021-02-28'::timestamp); - --- databricks sql: -SELECT DATEDIFF(month, CAST('2021-01-01' AS TIMESTAMP), CAST('2021-02-28' AS TIMESTAMP)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_2.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_2.sql deleted file mode 100644 index 9bb85ed62a..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select timestampDIFF('month', '2021-01-01'::timestamp, '2021-02-28'::timestamp); - --- databricks sql: -SELECT DATEDIFF(month, CAST('2021-01-01' AS TIMESTAMP), CAST('2021-02-28' AS TIMESTAMP)); diff --git a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_3.sql b/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_3.sql deleted file mode 100644 index 60e45aefc1..0000000000 --- a/tests/resources/functional/snowflake/functions/dates/test_timestampdiff/test_timestampdiff_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select datediff('day', '2020-02-03'::timestamp, '2023-10-26'::timestamp); - --- databricks sql: -SELECT DATEDIFF(day, CAST('2020-02-03' AS TIMESTAMP), CAST('2023-10-26' AS TIMESTAMP)); diff --git a/tests/resources/functional/snowflake/functions/initcap_1.sql b/tests/resources/functional/snowflake/functions/initcap_1.sql deleted file mode 100644 index 10543b57b4..0000000000 --- a/tests/resources/functional/snowflake/functions/initcap_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT initcap(col1) AS initcap_col1 FROM tabl; - --- databricks sql: -SELECT INITCAP(col1) AS initcap_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/left_1.sql b/tests/resources/functional/snowflake/functions/left_1.sql deleted file mode 100644 index 559faad13b..0000000000 --- a/tests/resources/functional/snowflake/functions/left_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT left(col1, 3) AS left_col1 FROM tabl; - --- databricks sql: -SELECT LEFT(col1, 3) AS left_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/ln_1.sql b/tests/resources/functional/snowflake/functions/math/ln_1.sql deleted file mode 100644 index 25d813daff..0000000000 --- a/tests/resources/functional/snowflake/functions/math/ln_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ln(col1) AS ln_col1 FROM tabl; - --- databricks sql: -SELECT LN(col1) AS ln_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/log_1.sql b/tests/resources/functional/snowflake/functions/math/log_1.sql deleted file mode 100644 index fbc1fc4689..0000000000 --- a/tests/resources/functional/snowflake/functions/math/log_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT log(x, y) AS log_col1 FROM tabl; - --- databricks sql: -SELECT LOG(x, y) AS log_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/mod_1.sql b/tests/resources/functional/snowflake/functions/math/mod_1.sql deleted file mode 100644 index e300d4a2ec..0000000000 --- a/tests/resources/functional/snowflake/functions/math/mod_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT mod(col1, col2) AS mod_col1 FROM tabl; - --- databricks sql: -SELECT MOD(col1, col2) AS mod_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/mode_1.sql b/tests/resources/functional/snowflake/functions/math/mode_1.sql deleted file mode 100644 index 3a37001f70..0000000000 --- a/tests/resources/functional/snowflake/functions/math/mode_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT mode(col1) AS mode_col1 FROM tabl; - --- databricks sql: -SELECT MODE(col1) AS mode_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/pi_1.sql b/tests/resources/functional/snowflake/functions/math/pi_1.sql deleted file mode 100644 index 79e819d41a..0000000000 --- a/tests/resources/functional/snowflake/functions/math/pi_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT PI() AS pi_col1 FROM tabl; - --- databricks sql: -SELECT PI() AS pi_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/radians_1.sql b/tests/resources/functional/snowflake/functions/math/radians_1.sql deleted file mode 100644 index fe7b0dbbbd..0000000000 --- a/tests/resources/functional/snowflake/functions/math/radians_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT radians(col1) AS radians_col1 FROM tabl; - --- databricks sql: -SELECT RADIANS(col1) AS radians_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/random_1.sql b/tests/resources/functional/snowflake/functions/math/random_1.sql deleted file mode 100644 index c557a8f0cd..0000000000 --- a/tests/resources/functional/snowflake/functions/math/random_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- TODO: Fix this test, it's currently incorrect because RANDOM() can't be simply passed through as-is. --- See: https://github.com/databrickslabs/remorph/issues/1280 --- Reference: https://docs.snowflake.com/en/sql-reference/functions/random.html - --- snowflake sql: -SELECT random(), random(col1) FROM tabl; - --- databricks sql: -SELECT RANDOM(), RANDOM(col1) FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/round_1.sql b/tests/resources/functional/snowflake/functions/math/round_1.sql deleted file mode 100644 index 7ab6b491b2..0000000000 --- a/tests/resources/functional/snowflake/functions/math/round_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT round(100.123) AS rounded; - --- databricks sql: -SELECT ROUND(100.123) AS rounded; diff --git a/tests/resources/functional/snowflake/functions/math/sign_1.sql b/tests/resources/functional/snowflake/functions/math/sign_1.sql deleted file mode 100644 index 9d4dc7df56..0000000000 --- a/tests/resources/functional/snowflake/functions/math/sign_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT sign(col1) AS sign_col1 FROM tabl; - --- databricks sql: -SELECT SIGN(col1) AS sign_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/sin_1.sql b/tests/resources/functional/snowflake/functions/math/sin_1.sql deleted file mode 100644 index 50308dd23f..0000000000 --- a/tests/resources/functional/snowflake/functions/math/sin_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT sin(col1) AS sin_col1 FROM tabl; - --- databricks sql: -SELECT SIN(col1) AS sin_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/sqrt_1.sql b/tests/resources/functional/snowflake/functions/math/sqrt_1.sql deleted file mode 100644 index 3831cd6415..0000000000 --- a/tests/resources/functional/snowflake/functions/math/sqrt_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT sqrt(col1) AS sqrt_col1 FROM tabl; - --- databricks sql: -SELECT SQRT(col1) AS sqrt_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/square/test_square_1.sql b/tests/resources/functional/snowflake/functions/math/square/test_square_1.sql deleted file mode 100644 index 3c6303e28c..0000000000 --- a/tests/resources/functional/snowflake/functions/math/square/test_square_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select square(1); - --- databricks sql: -SELECT POWER(1, 2); diff --git a/tests/resources/functional/snowflake/functions/math/square/test_square_2.sql b/tests/resources/functional/snowflake/functions/math/square/test_square_2.sql deleted file mode 100644 index 8cc9f679ef..0000000000 --- a/tests/resources/functional/snowflake/functions/math/square/test_square_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select square(-2); - --- databricks sql: -SELECT POWER(-2, 2); diff --git a/tests/resources/functional/snowflake/functions/math/square/test_square_3.sql b/tests/resources/functional/snowflake/functions/math/square/test_square_3.sql deleted file mode 100644 index 87518ce743..0000000000 --- a/tests/resources/functional/snowflake/functions/math/square/test_square_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select SQUARE(3.15); - --- databricks sql: -SELECT POWER(3.15, 2); diff --git a/tests/resources/functional/snowflake/functions/math/square/test_square_4.sql b/tests/resources/functional/snowflake/functions/math/square/test_square_4.sql deleted file mode 100644 index a0c2f273a0..0000000000 --- a/tests/resources/functional/snowflake/functions/math/square/test_square_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select SQUARE(null); - --- databricks sql: -SELECT POWER(NULL, 2); diff --git a/tests/resources/functional/snowflake/functions/math/sum_1.sql b/tests/resources/functional/snowflake/functions/math/sum_1.sql deleted file mode 100644 index da25c203ff..0000000000 --- a/tests/resources/functional/snowflake/functions/math/sum_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT sum(col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT SUM(col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_abs_1.sql b/tests/resources/functional/snowflake/functions/math/test_abs_1.sql deleted file mode 100644 index 579e1561f1..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_abs_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT abs(col1) AS abs_col1 FROM tabl; - --- databricks sql: -SELECT ABS(col1) AS abs_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_asin_1.sql b/tests/resources/functional/snowflake/functions/math/test_asin_1.sql deleted file mode 100644 index 8098cb3df2..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_asin_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT asin(col1) AS asin_col1 FROM tabl; - --- databricks sql: -SELECT ASIN(col1) AS asin_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_atan2_1.sql b/tests/resources/functional/snowflake/functions/math/test_atan2_1.sql deleted file mode 100644 index 1d0b9d49f4..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_atan2_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT atan2(exprY, exprX) AS atan2_col1 FROM tabl; - --- databricks sql: -SELECT ATAN2(exprY, exprX) AS atan2_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_ceil_1.sql b/tests/resources/functional/snowflake/functions/math/test_ceil_1.sql deleted file mode 100644 index 63e10076ff..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_ceil_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ceil(col1) AS ceil_col1 FROM tabl; - --- databricks sql: -SELECT CEIL(col1) AS ceil_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_cos_1.sql b/tests/resources/functional/snowflake/functions/math/test_cos_1.sql deleted file mode 100644 index 630ee8c559..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_cos_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT cos(col1) AS cos_col1 FROM tabl; - --- databricks sql: -SELECT COS(col1) AS cos_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_div0_1.sql b/tests/resources/functional/snowflake/functions/math/test_div0_1.sql deleted file mode 100644 index 285a550667..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_div0_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT DIV0(a, b); - --- databricks sql: -SELECT IF(b = 0, 0, a / b); diff --git a/tests/resources/functional/snowflake/functions/math/test_div0null_1.sql b/tests/resources/functional/snowflake/functions/math/test_div0null_1.sql deleted file mode 100644 index 5a41058989..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_div0null_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT DIV0NULL(a, b); - --- databricks sql: -SELECT IF(b = 0 OR b IS NULL, 0, a / b); diff --git a/tests/resources/functional/snowflake/functions/math/test_exp_1.sql b/tests/resources/functional/snowflake/functions/math/test_exp_1.sql deleted file mode 100644 index c62778ec7c..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_exp_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT exp(col1) AS exp_col1 FROM tabl; - --- databricks sql: -SELECT EXP(col1) AS exp_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/math/test_floor_1.sql b/tests/resources/functional/snowflake/functions/math/test_floor_1.sql deleted file mode 100644 index 780a24f56b..0000000000 --- a/tests/resources/functional/snowflake/functions/math/test_floor_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT floor(col1) AS floor_col1 FROM tabl; - --- databricks sql: -SELECT FLOOR(col1) AS floor_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_1.sql b/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_1.sql deleted file mode 100644 index d2302891b2..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT JSON_EXTRACT_PATH_TEXT(json_data, 'level_1_key.level_2_key[1]') FROM demo1; - --- databricks sql: -SELECT GET_JSON_OBJECT(json_data, '$.level_1_key.level_2_key[1]') FROM demo1; diff --git a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_2.sql b/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_2.sql deleted file mode 100644 index 046871aef8..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT JSON_EXTRACT_PATH_TEXT(json_data, path_col) FROM demo1; - --- databricks sql: -SELECT GET_JSON_OBJECT(json_data, CONCAT('$.', path_col)) FROM demo1; diff --git a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_3.sql b/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_3.sql deleted file mode 100644 index b343f2e3df..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/extract_path_text/test_parse_json_extract_path_text_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT JSON_EXTRACT_PATH_TEXT('{}', path_col) FROM demo1; - --- databricks sql: -SELECT GET_JSON_OBJECT('{}', CONCAT('$.', path_col)) FROM demo1; diff --git a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_1.sql b/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_1.sql deleted file mode 100644 index 911f283397..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT tt.id, PARSE_JSON(tt.details) FROM prod.public.table tt; - --- databricks sql: -SELECT tt.id, PARSE_JSON(tt.details) FROM prod.public.table AS tt; diff --git a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_2.sql b/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_2.sql deleted file mode 100644 index b9a159d6a4..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_2.sql +++ /dev/null @@ -1,8 +0,0 @@ --- snowflake sql: -SELECT col1, TRY_PARSE_JSON(col2) FROM tabl; - --- databricks sql: -SELECT col1, PARSE_JSON(col2) FROM tabl; - - - diff --git a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_3.sql b/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_3.sql deleted file mode 100644 index 5dd3f25d8b..0000000000 --- a/tests/resources/functional/snowflake/functions/parse_json/test_parse_json_3.sql +++ /dev/null @@ -1,33 +0,0 @@ --- snowflake sql: -WITH users AS ( - SELECT - 1 AS user_id, - '[{"id":1,"name":"A"},{"id":2,"name":"B"}]' AS json_data - UNION ALL - SELECT - 2 AS user_id, - '[{"id":3,"name":"C"},{"id":4,"name":"D"}]' AS json_data -) -SELECT - user_id, - value AS json_item -FROM - users, - LATERAL FLATTEN(input => PARSE_JSON(json_data)) as value; - --- databricks sql: -WITH users AS ( - SELECT - 1 AS user_id, - '[{"id":1,"name":"A"},{"id":2,"name":"B"}]' AS json_data - UNION ALL - SELECT - 2 AS user_id, - '[{"id":3,"name":"C"},{"id":4,"name":"D"}]' AS json_data -) -SELECT - user_id, - value AS json_item -FROM - users , - LATERAL VARIANT_EXPLODE(PARSE_JSON(json_data)) AS value diff --git a/tests/resources/functional/snowflake/functions/stats/median_1.sql b/tests/resources/functional/snowflake/functions/stats/median_1.sql deleted file mode 100644 index 18729de956..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/median_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT median(col1) AS median_col1 FROM tabl; - --- databricks sql: -SELECT MEDIAN(col1) AS median_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/nvl_1.sql b/tests/resources/functional/snowflake/functions/stats/nvl_1.sql deleted file mode 100644 index 7ed6fdf331..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/nvl_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nvl(col1, col2) AS nvl_col FROM tabl; - --- databricks sql: -SELECT COALESCE(col1, col2) AS nvl_col FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/regr_intercept_1.sql b/tests/resources/functional/snowflake/functions/stats/regr_intercept_1.sql deleted file mode 100644 index 0b690c992f..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/regr_intercept_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regr_intercept(v, v2) AS regr_intercept_col1 FROM tabl; - --- databricks sql: -SELECT REGR_INTERCEPT(v, v2) AS regr_intercept_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/regr_r2_1.sql b/tests/resources/functional/snowflake/functions/stats/regr_r2_1.sql deleted file mode 100644 index d309be5c24..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/regr_r2_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regr_r2(v, v2) AS regr_r2_col1 FROM tabl; - --- databricks sql: -SELECT REGR_R2(v, v2) AS regr_r2_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/regr_slope_1.sql b/tests/resources/functional/snowflake/functions/stats/regr_slope_1.sql deleted file mode 100644 index e9c6fbb608..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/regr_slope_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regr_slope(v, v2) AS regr_slope_col1 FROM tabl; - --- databricks sql: -SELECT REGR_SLOPE(v, v2) AS regr_slope_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/stddev_1.sql b/tests/resources/functional/snowflake/functions/stats/stddev_1.sql deleted file mode 100644 index 72d1ee3591..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/stddev_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT stddev(col1) AS stddev_col1 FROM tabl; - --- databricks sql: -SELECT STDDEV(col1) AS stddev_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/stddev_pop_1.sql b/tests/resources/functional/snowflake/functions/stats/stddev_pop_1.sql deleted file mode 100644 index 7b70860336..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/stddev_pop_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT stddev_pop(col1) AS stddev_pop_col1 FROM tabl; - --- databricks sql: -SELECT STDDEV_POP(col1) AS stddev_pop_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/stddev_samp_1.sql b/tests/resources/functional/snowflake/functions/stats/stddev_samp_1.sql deleted file mode 100644 index 9fbc1d777b..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/stddev_samp_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT stddev_samp(col1) AS stddev_samp_col1 FROM tabl; - --- databricks sql: -SELECT STDDEV_SAMP(col1) AS stddev_samp_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/test_approx_percentile_1.sql b/tests/resources/functional/snowflake/functions/stats/test_approx_percentile_1.sql deleted file mode 100644 index 570894af09..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/test_approx_percentile_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT approx_percentile(col1, 0.5) AS approx_percentile_col1 FROM tabl; - --- databricks sql: -SELECT APPROX_PERCENTILE(col1, 0.5) AS approx_percentile_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/test_approx_top_k_1.sql b/tests/resources/functional/snowflake/functions/stats/test_approx_top_k_1.sql deleted file mode 100644 index 4bca27d97d..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/test_approx_top_k_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT approx_top_k(col1) AS approx_top_k_col1 FROM tabl; - --- databricks sql: -SELECT APPROX_TOP_K(col1) AS approx_top_k_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/test_avg_1.sql b/tests/resources/functional/snowflake/functions/stats/test_avg_1.sql deleted file mode 100644 index 9eb80584f4..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/test_avg_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT avg(col1) AS avg_col1 FROM tabl; - --- databricks sql: -SELECT AVG(col1) AS avg_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/test_corr_1.sql b/tests/resources/functional/snowflake/functions/stats/test_corr_1.sql deleted file mode 100644 index 67e7424f3a..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/test_corr_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT CORR(v, v2) AS corr_col1 FROM tabl; - --- databricks sql: -SELECT CORR(v, v2) AS corr_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/stats/test_cume_dist_1.sql b/tests/resources/functional/snowflake/functions/stats/test_cume_dist_1.sql deleted file mode 100644 index 6eda8d1731..0000000000 --- a/tests/resources/functional/snowflake/functions/stats/test_cume_dist_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT cume_dist() AS cume_dist_col1 FROM tabl; - --- databricks sql: -SELECT CUME_DIST() AS cume_dist_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/lower_1.sql b/tests/resources/functional/snowflake/functions/strings/lower_1.sql deleted file mode 100644 index 655d75dfe5..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/lower_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT lower(col1) AS lower_col1 FROM tabl; - --- databricks sql: -SELECT LOWER(col1) AS lower_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/lpad_1.sql b/tests/resources/functional/snowflake/functions/strings/lpad_1.sql deleted file mode 100644 index 2292d4b06c..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/lpad_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT lpad('hi', 5, 'ab'); - --- databricks sql: -SELECT LPAD('hi', 5, 'ab'); diff --git a/tests/resources/functional/snowflake/functions/strings/ltrim_1.sql b/tests/resources/functional/snowflake/functions/strings/ltrim_1.sql deleted file mode 100644 index 5ce08e090f..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/ltrim_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT ltrim(col1) AS ltrim_col1 FROM tabl; - --- databricks sql: -SELECT LTRIM(col1) AS ltrim_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/parse_url_1.sql b/tests/resources/functional/snowflake/functions/strings/parse_url_1.sql deleted file mode 100644 index c448272919..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/parse_url_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT parse_url(col1) AS parse_url_col1 FROM tabl; - --- databricks sql: -SELECT PARSE_URL(col1) AS parse_url_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_count_1.sql b/tests/resources/functional/snowflake/functions/strings/regexp_count_1.sql deleted file mode 100644 index ae447d86a8..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_count_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_count(col1, patt1) AS regexp_count_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_COUNT(col1, patt1) AS regexp_count_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_instr_1.sql b/tests/resources/functional/snowflake/functions/strings/regexp_instr_1.sql deleted file mode 100644 index f9e1d645b0..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_instr_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_instr(col1, '.') AS regexp_instr_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_INSTR(col1, '.') AS regexp_instr_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_like_1.sql b/tests/resources/functional/snowflake/functions/strings/regexp_like_1.sql deleted file mode 100644 index e0cfc09d6a..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_like_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_like(col1, 'Users.*') AS regexp_like_col1 FROM tabl; - --- databricks sql: -SELECT col1 RLIKE 'Users.*' AS regexp_like_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_replace_1.sql b/tests/resources/functional/snowflake/functions/strings/regexp_replace_1.sql deleted file mode 100644 index cf6b036978..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_replace_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_replace(col1, '(d+)', '***') AS regexp_replace_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_REPLACE(col1, '(d+)', '***') AS regexp_replace_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_substr_1.sql b/tests/resources/functional/snowflake/functions/strings/regexp_substr_1.sql deleted file mode 100644 index f58f597001..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_substr_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_substr(col1, '(E|e)rror') AS regexp_substr_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_EXTRACT(col1, '(E|e)rror', 0) AS regexp_substr_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/regexp_substr_2.sql b/tests/resources/functional/snowflake/functions/strings/regexp_substr_2.sql deleted file mode 100644 index fbbedd2865..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/regexp_substr_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- snowflake sql: -select id, string1, - regexp_substr(string1, 'the\\W+\\w+') as "SUBSTRING" - from demo2; - --- databricks sql: - -select id, string1, - REGEXP_EXTRACT(string1, 'the\\W+\\w+', 0) as `SUBSTRING` - from demo2; diff --git a/tests/resources/functional/snowflake/functions/strings/repeat_1.sql b/tests/resources/functional/snowflake/functions/strings/repeat_1.sql deleted file mode 100644 index 62af863948..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/repeat_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT repeat(col1, 5) AS repeat_col1 FROM tabl; - --- databricks sql: -SELECT REPEAT(col1, 5) AS repeat_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/replace_1.sql b/tests/resources/functional/snowflake/functions/strings/replace_1.sql deleted file mode 100644 index 8a0ca54f53..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/replace_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT replace('ABC_abc', 'abc', 'DEF'); - --- databricks sql: -SELECT REPLACE('ABC_abc', 'abc', 'DEF'); diff --git a/tests/resources/functional/snowflake/functions/strings/reverse_1.sql b/tests/resources/functional/snowflake/functions/strings/reverse_1.sql deleted file mode 100644 index 18c1eed7bb..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/reverse_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT reverse(col1) AS reverse_col1 FROM tabl; - --- databricks sql: -SELECT REVERSE(col1) AS reverse_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/right_1.sql b/tests/resources/functional/snowflake/functions/strings/right_1.sql deleted file mode 100644 index 6add2ccc0e..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/right_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT right(col1, 5) AS right_col1 FROM tabl; - --- databricks sql: -SELECT RIGHT(col1, 5) AS right_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/rpad_1.sql b/tests/resources/functional/snowflake/functions/strings/rpad_1.sql deleted file mode 100644 index e9bdf90ec9..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/rpad_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT rpad('hi', 5, 'ab'); - --- databricks sql: -SELECT RPAD('hi', 5, 'ab'); diff --git a/tests/resources/functional/snowflake/functions/strings/rtrim_1.sql b/tests/resources/functional/snowflake/functions/strings/rtrim_1.sql deleted file mode 100644 index 3badda83ab..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/rtrim_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT rtrim(col1) AS rtrim_col1 FROM tabl; - --- databricks sql: -SELECT RTRIM(col1) AS rtrim_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_1.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_1.sql deleted file mode 100644 index 531c41c4e1..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART(col1, ',', 0); - --- databricks sql: -SELECT SPLIT_PART(col1, ',', 1); diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_2.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_2.sql deleted file mode 100644 index fc4277a210..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART(NULL, ',', 0); - --- databricks sql: -SELECT SPLIT_PART(NULL, ',', 1); diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_3.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_3.sql deleted file mode 100644 index ac873315ce..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART(col1, ',', 5); - --- databricks sql: -SELECT SPLIT_PART(col1, ',', 5); diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_4.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_4.sql deleted file mode 100644 index d73b50f71e..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART('lit_string', ',', 1); - --- databricks sql: -SELECT SPLIT_PART('lit_string', ',', 1); diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_5.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_5.sql deleted file mode 100644 index c7151b27e2..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART('lit_string', '', 1); - --- databricks sql: -SELECT SPLIT_PART('lit_string', '', 1); diff --git a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_6.sql b/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_6.sql deleted file mode 100644 index f626a551e0..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/split_part/test_split_part_6.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART(col1, 'delim', len('abc')); - --- databricks sql: -SELECT SPLIT_PART(col1, 'delim', IF(LENGTH('abc') = 0, 1, LENGTH('abc'))); diff --git a/tests/resources/functional/snowflake/functions/strings/startswith_1.sql b/tests/resources/functional/snowflake/functions/strings/startswith_1.sql deleted file mode 100644 index 39235a3ce1..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/startswith_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT startswith(col1, 'Spark') AS startswith_col1 FROM tabl; - --- databricks sql: -SELECT STARTSWITH(col1, 'Spark') AS startswith_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_1.sql b/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_1.sql deleted file mode 100644 index 8a93e20515..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select STRTOK('my text is divided'); - --- databricks sql: -SELECT SPLIT_PART('my text is divided', ' ', 1); diff --git a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_2.sql b/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_2.sql deleted file mode 100644 index b65b6637ba..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select STRTOK('a_b_c'), STRTOK(tbl.col123, '.', 3) FROM table tbl; - --- databricks sql: -SELECT SPLIT_PART('a_b_c', ' ', 1), SPLIT_PART(tbl.col123, '.', 3) FROM table AS tbl; diff --git a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_3.sql b/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_3.sql deleted file mode 100644 index e6baed6b1f..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/strtok/test_strtok_3.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -select STRTOK('user@example.com', '@.', 2), - SPLIT_PART(col123, '.', 1) FROM table tbl; - --- databricks sql: -SELECT SPLIT_PART('user@example.com', '@.', 2), SPLIT_PART(col123, '.', 1) FROM table AS tbl; diff --git a/tests/resources/functional/snowflake/functions/strings/test_base64_decode_1.sql b/tests/resources/functional/snowflake/functions/strings/test_base64_decode_1.sql deleted file mode 100644 index 726b5764b7..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_base64_decode_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT BASE64_DECODE_STRING(BASE64_ENCODE('HELLO')), TRY_BASE64_DECODE_STRING(BASE64_ENCODE('HELLO')); - --- databricks sql: -SELECT UNBASE64(BASE64('HELLO')), UNBASE64(BASE64('HELLO')); diff --git a/tests/resources/functional/snowflake/functions/strings/test_base64_encode_1.sql b/tests/resources/functional/snowflake/functions/strings/test_base64_encode_1.sql deleted file mode 100644 index ce29cf8a5f..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_base64_encode_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT BASE64_ENCODE('HELLO'), BASE64_ENCODE('HELLO'); - --- databricks sql: -SELECT BASE64('HELLO'), BASE64('HELLO'); diff --git a/tests/resources/functional/snowflake/functions/strings/test_charindex_1.sql b/tests/resources/functional/snowflake/functions/strings/test_charindex_1.sql deleted file mode 100644 index 0925f3de77..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_charindex_1.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -select charindex('an', 'banana', 3), - charindex('ab', 'abababab'), n, h, CHARINDEX(n, h) FROM pos; - --- databricks sql: -SELECT CHARINDEX('an', 'banana', 3), CHARINDEX('ab', 'abababab'), n, h, CHARINDEX(n, h) FROM pos; diff --git a/tests/resources/functional/snowflake/functions/strings/test_collate_1.sql b/tests/resources/functional/snowflake/functions/strings/test_collate_1.sql deleted file mode 100644 index 3c49ea8196..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_collate_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ENDSWITH(COLLATE('ñn', 'sp'), COLLATE('n', 'sp')); - --- databricks sql: -SELECT ENDSWITH(COLLATE('ñn', 'sp'), COLLATE('n', 'sp')); diff --git a/tests/resources/functional/snowflake/functions/strings/test_collate_2.sql b/tests/resources/functional/snowflake/functions/strings/test_collate_2.sql deleted file mode 100644 index c7fa5f7948..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_collate_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT v, COLLATION(v), COLLATE(v, 'sp-upper'), COLLATION(COLLATE(v, 'sp-upper')) FROM collation1; - --- databricks sql: -SELECT v, COLLATION(v), COLLATE(v, 'sp-upper'), COLLATION(COLLATE(v, 'sp-upper')) FROM collation1; diff --git a/tests/resources/functional/snowflake/functions/strings/test_decode_1.sql b/tests/resources/functional/snowflake/functions/strings/test_decode_1.sql deleted file mode 100644 index ff20d8f136..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_decode_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT decode(column1, 1, 'one', 2, 'two', NULL, '-NULL-', 'other') AS decode_result; - --- databricks sql: -SELECT CASE WHEN column1 = 1 THEN 'one' WHEN column1 = 2 THEN 'two' WHEN column1 IS NULL THEN '-NULL-' ELSE 'other' END AS decode_result; diff --git a/tests/resources/functional/snowflake/functions/strings/test_editdistance.sql b/tests/resources/functional/snowflake/functions/strings/test_editdistance.sql deleted file mode 100644 index 54ad4631d6..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_editdistance.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT s, t, EDITDISTANCE(s, t), EDITDISTANCE(t, s), EDITDISTANCE(s, t, 3), EDITDISTANCE(s, t, -1) FROM ed; - --- databricks sql: -SELECT s, t, LEVENSHTEIN(s, t), LEVENSHTEIN(t, s), LEVENSHTEIN(s, t, 3), LEVENSHTEIN(s, t, -1) FROM ed; diff --git a/tests/resources/functional/snowflake/functions/strings/test_endswith_1.sql b/tests/resources/functional/snowflake/functions/strings/test_endswith_1.sql deleted file mode 100644 index 3c5265a4ab..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/test_endswith_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT endswith('SparkSQL', 'SQL'); - --- databricks sql: -SELECT ENDSWITH('SparkSQL', 'SQL'); diff --git a/tests/resources/functional/snowflake/functions/strings/trim_1.sql b/tests/resources/functional/snowflake/functions/strings/trim_1.sql deleted file mode 100644 index 0412525784..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/trim_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT trim(col1) AS trim_col1 FROM tabl; - --- databricks sql: -SELECT TRIM(col1) AS trim_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/trunc_1.sql b/tests/resources/functional/snowflake/functions/strings/trunc_1.sql deleted file mode 100644 index fc2f739d3a..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/trunc_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT trunc(col1, 'YEAR') AS trunc_col1 FROM tabl; - --- databricks sql: -SELECT TRUNC(col1, 'YEAR') AS trunc_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/strings/upper_1.sql b/tests/resources/functional/snowflake/functions/strings/upper_1.sql deleted file mode 100644 index 814f299bfa..0000000000 --- a/tests/resources/functional/snowflake/functions/strings/upper_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT upper(col1) AS upper_col1 FROM tabl; - --- databricks sql: -SELECT UPPER(col1) AS upper_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/struct_1.sql b/tests/resources/functional/snowflake/functions/struct_1.sql deleted file mode 100644 index 2067e2c13c..0000000000 --- a/tests/resources/functional/snowflake/functions/struct_1.sql +++ /dev/null @@ -1,8 +0,0 @@ - --- snowflake sql: -SELECT {'a': 1, 'b': 2}, [{'c': 11, 'd': 22}, 3]; - --- databricks sql: -SELECT STRUCT(1 AS a, 2 AS b), ARRAY(STRUCT(11 AS c, 22 AS d), 3); - - diff --git a/tests/resources/functional/snowflake/functions/sysdate_1.sql b/tests/resources/functional/snowflake/functions/sysdate_1.sql deleted file mode 100644 index 9280942ca0..0000000000 --- a/tests/resources/functional/snowflake/functions/sysdate_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SYSDATE(), CURRENT_TIMESTAMP(); - --- databricks sql: -SELECT CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP(); diff --git a/tests/resources/functional/snowflake/functions/tan_1.sql b/tests/resources/functional/snowflake/functions/tan_1.sql deleted file mode 100644 index f04b82145a..0000000000 --- a/tests/resources/functional/snowflake/functions/tan_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT tan(col1) AS tan_col1 FROM tabl; - --- databricks sql: -SELECT TAN(col1) AS tan_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_1.sql b/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_1.sql deleted file mode 100644 index d9cedea260..0000000000 --- a/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nvl2(NULL, 2, 1); - --- databricks sql: -SELECT NVL2(NULL, 2, 1); diff --git a/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_2.sql b/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_2.sql deleted file mode 100644 index 9e65e46058..0000000000 --- a/tests/resources/functional/snowflake/functions/test_nvl2/test_nvl2_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nvl2(cond, col1, col2) AS nvl2_col1 FROM tabl; - --- databricks sql: -SELECT NVL2(cond, col1, col2) AS nvl2_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_1.sql b/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_1.sql deleted file mode 100644 index b9bc723913..0000000000 --- a/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_1.sql +++ /dev/null @@ -1,10 +0,0 @@ - --- snowflake sql: - - SELECT OBJECT_KEYS(object1), OBJECT_KEYS(variant1) - FROM objects_1 - ORDER BY id; - ; - --- databricks sql: -SELECT JSON_OBJECT_KEYS(object1), JSON_OBJECT_KEYS(variant1) FROM objects_1 ORDER BY id NULLS LAST; diff --git a/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_2.sql b/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_2.sql deleted file mode 100644 index 94dd52c473..0000000000 --- a/tests/resources/functional/snowflake/functions/test_object_keys/test_object_keys_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT OBJECT_KEYS (PARSE_JSON (column1)) AS keys -FROM table -ORDER BY 1; - --- databricks sql: -SELECT - JSON_OBJECT_KEYS(PARSE_JSON(column1)) AS keys -FROM table -ORDER BY - 1 NULLS LAST; diff --git a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_1.sql b/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_1.sql deleted file mode 100644 index 3558a6a9b7..0000000000 --- a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select STRTOK_TO_ARRAY('my text is divided'); - --- databricks sql: -SELECT SPLIT('my text is divided','[ ]'); diff --git a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_2.sql b/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_2.sql deleted file mode 100644 index 289aa7c308..0000000000 --- a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select STRTOK_TO_ARRAY('v_p_n', '_'), STRTOK_TO_ARRAY(col123, '.') FROM table tbl; - --- databricks sql: -SELECT SPLIT('v_p_n','[_]'), SPLIT(col123,'[.]') FROM table AS tbl; diff --git a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_3.sql b/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_3.sql deleted file mode 100644 index 5f4a91c04f..0000000000 --- a/tests/resources/functional/snowflake/functions/test_strtok_to_array/test_strtok_to_array_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select STRTOK_TO_ARRAY('a@b.c', '.@'); - --- databricks sql: -SELECT SPLIT('a@b.c','[.@]'); diff --git a/tests/resources/functional/snowflake/functions/test_uuid_string_1.sql b/tests/resources/functional/snowflake/functions/test_uuid_string_1.sql deleted file mode 100644 index a44aa1f3c5..0000000000 --- a/tests/resources/functional/snowflake/functions/test_uuid_string_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT UUID_STRING(); - --- databricks sql: -SELECT UUID(); diff --git a/tests/resources/functional/snowflake/functions/tovarchar_1.sql b/tests/resources/functional/snowflake/functions/tovarchar_1.sql deleted file mode 100644 index bafef2cd51..0000000000 --- a/tests/resources/functional/snowflake/functions/tovarchar_1.sql +++ /dev/null @@ -1,7 +0,0 @@ - --- snowflake sql: -select to_varchar(-12454.8, '99,999.9S'), - '>' || to_char(col1, '00000.00') || '<' FROM dummy; - --- databricks sql: -SELECT TO_CHAR(-12454.8, '99,999.9S'), '>' || TO_CHAR(col1, '00000.00') || '<' FROM dummy; diff --git a/tests/resources/functional/snowflake/functions/translate_1.sql b/tests/resources/functional/snowflake/functions/translate_1.sql deleted file mode 100644 index 6ddcbf6929..0000000000 --- a/tests/resources/functional/snowflake/functions/translate_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT translate('AaBbCc', 'abc', '123') AS translate_col1 FROM tabl; - --- databricks sql: -SELECT TRANSLATE('AaBbCc', 'abc', '123') AS translate_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/typeof_1.sql b/tests/resources/functional/snowflake/functions/typeof_1.sql deleted file mode 100644 index 73958be10c..0000000000 --- a/tests/resources/functional/snowflake/functions/typeof_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT typeof(col1) AS typeof_col1 FROM tabl; - --- databricks sql: -SELECT TYPEOF(col1) AS typeof_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/window/lag_1.sql b/tests/resources/functional/snowflake/functions/window/lag_1.sql deleted file mode 100644 index 837188f2ad..0000000000 --- a/tests/resources/functional/snowflake/functions/window/lag_1.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - lag(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 - ) AS lag_col1 -FROM - tabl; - --- databricks sql: -SELECT - LAG(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST - ) AS lag_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/lag_2.sql b/tests/resources/functional/snowflake/functions/window/lag_2.sql deleted file mode 100644 index 58c10bfb57..0000000000 --- a/tests/resources/functional/snowflake/functions/window/lag_2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- snowflake sql: -SELECT - lag(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS lag_col1 -FROM - tabl; - --- databricks sql: -SELECT - LAG(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS lag_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/lead_1.sql b/tests/resources/functional/snowflake/functions/window/lead_1.sql deleted file mode 100644 index 7e1a241dba..0000000000 --- a/tests/resources/functional/snowflake/functions/window/lead_1.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - lead(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 - ) AS lead_col1 -FROM - tabl; - --- databricks sql: -SELECT - LEAD(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST - ) AS lead_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/lead_2.sql b/tests/resources/functional/snowflake/functions/window/lead_2.sql deleted file mode 100644 index 2fc59e391d..0000000000 --- a/tests/resources/functional/snowflake/functions/window/lead_2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- snowflake sql: -SELECT - lead(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS lead_col1 -FROM - tabl; - --- databricks sql: -SELECT - LEAD(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS lead_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/nth_value_1.sql b/tests/resources/functional/snowflake/functions/window/nth_value_1.sql deleted file mode 100644 index c74df8e3d9..0000000000 --- a/tests/resources/functional/snowflake/functions/window/nth_value_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -SELECT - nth_value(col1, 42) AS nth_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - NTH_VALUE(col1, 42) AS nth_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/nth_value_2.sql b/tests/resources/functional/snowflake/functions/window/nth_value_2.sql deleted file mode 100644 index aef11fd550..0000000000 --- a/tests/resources/functional/snowflake/functions/window/nth_value_2.sql +++ /dev/null @@ -1,20 +0,0 @@ --- snowflake sql: -SELECT - nth_value(col1, 42) over ( - partition by col1 - order by - col2 - ) AS nth_value_col1 -FROM - tabl; - --- databricks sql: -SELECT - NTH_VALUE(col1, 42) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING - AND UNBOUNDED FOLLOWING - ) AS nth_value_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/nth_value_3.sql b/tests/resources/functional/snowflake/functions/window/nth_value_3.sql deleted file mode 100644 index fcebc6d746..0000000000 --- a/tests/resources/functional/snowflake/functions/window/nth_value_3.sql +++ /dev/null @@ -1,35 +0,0 @@ --- snowflake sql: -SELECT - taba.col_a, - taba.col_b, - nth_value( - CASE - WHEN taba.col_c IN ('xyz', 'abc') THEN taba.col_d - END, - 42 - ) ignore nulls OVER ( - partition BY taba.col_e - ORDER BY - taba.col_f DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a taba; - --- databricks sql: -SELECT - taba.col_a, - taba.col_b, - NTH_VALUE( - CASE - WHEN taba.col_c IN ('xyz', 'abc') THEN taba.col_d - END, - 42 - ) IGNORE NULLS OVER ( - PARTITION BY taba.col_e - ORDER BY - taba.col_f DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS derived_col_a -FROM - schema_a.table_a AS taba; diff --git a/tests/resources/functional/snowflake/functions/window/ntile_1.sql b/tests/resources/functional/snowflake/functions/window/ntile_1.sql deleted file mode 100644 index 2a851b35d2..0000000000 --- a/tests/resources/functional/snowflake/functions/window/ntile_1.sql +++ /dev/null @@ -1,20 +0,0 @@ --- snowflake sql: -SELECT - ntile(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 - ) AS ntile_col1 -FROM - tabl; - --- databricks sql: -SELECT - NTILE(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING - AND UNBOUNDED FOLLOWING - ) AS ntile_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/ntile_2.sql b/tests/resources/functional/snowflake/functions/window/ntile_2.sql deleted file mode 100644 index a91a36e4f9..0000000000 --- a/tests/resources/functional/snowflake/functions/window/ntile_2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- snowflake sql: -SELECT - ntile(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS ntile_col1 -FROM - tabl; - --- databricks sql: -SELECT - NTILE(col1) OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS ntile_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/percent_rank_1.sql b/tests/resources/functional/snowflake/functions/window/percent_rank_1.sql deleted file mode 100644 index 1cd6ef7a94..0000000000 --- a/tests/resources/functional/snowflake/functions/window/percent_rank_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT percent_rank() AS percent_rank_col1 FROM tabl; - --- databricks sql: -SELECT PERCENT_RANK() AS percent_rank_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/window/percentile_cont_1.sql b/tests/resources/functional/snowflake/functions/window/percentile_cont_1.sql deleted file mode 100644 index ed893223fa..0000000000 --- a/tests/resources/functional/snowflake/functions/window/percentile_cont_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT percentile_cont(col1) AS percentile_cont_col1 FROM tabl; - --- databricks sql: -SELECT PERCENTILE_CONT(col1) AS percentile_cont_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/window/percentile_disc_1.sql b/tests/resources/functional/snowflake/functions/window/percentile_disc_1.sql deleted file mode 100644 index c8e5f298b1..0000000000 --- a/tests/resources/functional/snowflake/functions/window/percentile_disc_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT percentile_disc(col1) AS percentile_disc_col1 FROM tabl; - --- databricks sql: -SELECT PERCENTILE_DISC(col1) AS percentile_disc_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/window/position_1.sql b/tests/resources/functional/snowflake/functions/window/position_1.sql deleted file mode 100644 index 71b36e305b..0000000000 --- a/tests/resources/functional/snowflake/functions/window/position_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT position('exc', col1) AS position_col1 FROM tabl; - --- databricks sql: -SELECT LOCATE('exc', col1) AS position_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/functions/window/rank_1.sql b/tests/resources/functional/snowflake/functions/window/rank_1.sql deleted file mode 100644 index 58bfc85e7d..0000000000 --- a/tests/resources/functional/snowflake/functions/window/rank_1.sql +++ /dev/null @@ -1,19 +0,0 @@ --- snowflake sql: -SELECT - rank() over ( - partition by col1 - order by - col2 - ) AS rank_col1 -FROM - tabl; - --- databricks sql: -SELECT - RANK() OVER ( - PARTITION BY col1 - ORDER BY - col2 ASC NULLS LAST - ) AS rank_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/rank_2.sql b/tests/resources/functional/snowflake/functions/window/rank_2.sql deleted file mode 100644 index 8be920dbd5..0000000000 --- a/tests/resources/functional/snowflake/functions/window/rank_2.sql +++ /dev/null @@ -1,21 +0,0 @@ --- snowflake sql: -SELECT - rank() over ( - partition by col1 - order by - col2 DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS rank_col1 -FROM - tabl; - --- databricks sql: -SELECT - RANK() OVER ( - PARTITION BY col1 - ORDER BY - col2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS rank_col1 -FROM - tabl; diff --git a/tests/resources/functional/snowflake/functions/window/row_number_1.sql b/tests/resources/functional/snowflake/functions/window/row_number_1.sql deleted file mode 100644 index e55228eeb2..0000000000 --- a/tests/resources/functional/snowflake/functions/window/row_number_1.sql +++ /dev/null @@ -1,25 +0,0 @@ --- snowflake sql: -SELECT - symbol, - exchange, - shares, - ROW_NUMBER() OVER ( - PARTITION BY exchange - ORDER BY - shares - ) AS row_number -FROM - trades; - --- databricks sql: -SELECT - symbol, - exchange, - shares, - ROW_NUMBER() OVER ( - PARTITION BY exchange - ORDER BY - shares ASC NULLS LAST - ) AS row_number -FROM - trades; diff --git a/tests/resources/functional/snowflake/functions/window/row_number_2.sql b/tests/resources/functional/snowflake/functions/window/row_number_2.sql deleted file mode 100644 index fe374f6369..0000000000 --- a/tests/resources/functional/snowflake/functions/window/row_number_2.sql +++ /dev/null @@ -1,27 +0,0 @@ --- snowflake sql: -SELECT - symbol, - exchange, - shares, - ROW_NUMBER() OVER ( - PARTITION BY exchange - ORDER BY - shares DESC RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS row_number -FROM - trades; - --- databricks sql: -SELECT - symbol, - exchange, - shares, - ROW_NUMBER() OVER ( - PARTITION BY exchange - ORDER BY - shares DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING - AND CURRENT ROW - ) AS row_number -FROM - trades; diff --git a/tests/resources/functional/snowflake/joins/test_join_1.sql b/tests/resources/functional/snowflake/joins/test_join_1.sql deleted file mode 100644 index 278e48b0e7..0000000000 --- a/tests/resources/functional/snowflake/joins/test_join_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT t1.c1, t2.c2 FROM t1 JOIN t2 USING (c3); - --- databricks sql: -SELECT t1.c1, t2.c2 FROM t1 JOIN t2 USING (c3); diff --git a/tests/resources/functional/snowflake/joins/test_join_2.sql b/tests/resources/functional/snowflake/joins/test_join_2.sql deleted file mode 100644 index fe068bcf75..0000000000 --- a/tests/resources/functional/snowflake/joins/test_join_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT * FROM table1, table2 WHERE table1.column_name = table2.column_name; - --- databricks sql: -SELECT * FROM table1, table2 WHERE table1.column_name = table2.column_name; diff --git a/tests/resources/functional/snowflake/lca/lca_cte.sql b/tests/resources/functional/snowflake/lca/lca_cte.sql deleted file mode 100644 index 3ee9c89a81..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_cte.sql +++ /dev/null @@ -1,11 +0,0 @@ --- snowflake sql: -WITH cte AS (SELECT column_a as customer_id - FROM my_table - WHERE customer_id = '123') -SELECT * FROM cte; - --- databricks sql: -WITH cte AS (SELECT column_a as customer_id - FROM my_table - WHERE column_a = '123') -SELECT * FROM cte; diff --git a/tests/resources/functional/snowflake/lca/lca_derived.sql b/tests/resources/functional/snowflake/lca/lca_derived.sql deleted file mode 100644 index cf41b3072b..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_derived.sql +++ /dev/null @@ -1,8 +0,0 @@ --- snowflake sql: -SELECT column_a as cid -FROM (select column_x as column_a, column_y as y from my_table where y = '456') -WHERE cid = '123'; --- databricks sql: -SELECT column_a as cid -FROM (select column_x as column_a, column_y as y from my_table where column_y = '456') -WHERE column_a = '123'; diff --git a/tests/resources/functional/snowflake/lca/lca_in.sql b/tests/resources/functional/snowflake/lca/lca_in.sql deleted file mode 100644 index b1ff47ba9d..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_in.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT t.col1, t.col2, t.col3 AS ca FROM table1 t WHERE ca in ('v1', 'v2'); - --- databricks sql: -SELECT t.col1, t.col2, t.col3 AS ca FROM table1 AS t WHERE t.col3 in ('v1', 'v2'); diff --git a/tests/resources/functional/snowflake/lca/lca_nested.sql b/tests/resources/functional/snowflake/lca/lca_nested.sql deleted file mode 100644 index d3b2c2e5a3..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_nested.sql +++ /dev/null @@ -1,13 +0,0 @@ --- snowflake sql: -SELECT - b * c as new_b, - a - new_b as ab_diff -FROM my_table -WHERE ab_diff >= 0; - --- databricks sql: -SELECT - b * c as new_b, - a - new_b as ab_diff -FROM my_table -WHERE a - b * c >= 0; diff --git a/tests/resources/functional/snowflake/lca/lca_subquery.sql b/tests/resources/functional/snowflake/lca/lca_subquery.sql deleted file mode 100644 index 8fc77adcdc..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_subquery.sql +++ /dev/null @@ -1,8 +0,0 @@ --- snowflake sql: -SELECT column_a as cid -FROM my_table -WHERE cid in (select cid as customer_id from customer_table where customer_id = '123'); --- databricks sql: -SELECT column_a as cid -FROM my_table -WHERE column_a in (select cid as customer_id from customer_table where cid = '123'); diff --git a/tests/resources/functional/snowflake/lca/lca_where.sql b/tests/resources/functional/snowflake/lca/lca_where.sql deleted file mode 100644 index 920915f1df..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_where.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT column_a as alias_a FROM table_a where alias_a = '123'; - --- databricks sql: -SELECT column_a as alias_a FROM table_a where column_a = '123'; diff --git a/tests/resources/functional/snowflake/lca/lca_window.sql b/tests/resources/functional/snowflake/lca/lca_window.sql deleted file mode 100644 index 66d804732d..0000000000 --- a/tests/resources/functional/snowflake/lca/lca_window.sql +++ /dev/null @@ -1,15 +0,0 @@ --- snowflake sql: -SELECT - t.col1, - t.col2, - t.col3 AS ca, - ROW_NUMBER() OVER (PARTITION by ca ORDER BY t.col2 DESC) AS rn - FROM table1 t; - --- databricks sql: -SELECT - t.col1, - t.col2, - t.col3 AS ca, - ROW_NUMBER() OVER (PARTITION by t.col3 ORDER BY t.col2 DESC NULLS FIRST) AS rn - FROM table1 AS t; diff --git a/tests/resources/functional/snowflake/misc/test_any_value_1.sql b/tests/resources/functional/snowflake/misc/test_any_value_1.sql deleted file mode 100644 index 98648f2766..0000000000 --- a/tests/resources/functional/snowflake/misc/test_any_value_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT customer.id , ANY_VALUE(customer.name) , SUM(orders.value) FROM customer JOIN orders ON customer.id = orders.customer_id GROUP BY customer.id; - --- databricks sql: -SELECT customer.id, ANY_VALUE(customer.name), SUM(orders.value) FROM customer JOIN orders ON customer.id = orders.customer_id GROUP BY customer.id; diff --git a/tests/resources/functional/snowflake/misc/test_coalesce_1.sql b/tests/resources/functional/snowflake/misc/test_coalesce_1.sql deleted file mode 100644 index 421dd6258a..0000000000 --- a/tests/resources/functional/snowflake/misc/test_coalesce_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT coalesce(col1, col2) AS coalesce_col FROM tabl; - --- databricks sql: -SELECT COALESCE(col1, col2) AS coalesce_col FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_contains_1.sql b/tests/resources/functional/snowflake/misc/test_contains_1.sql deleted file mode 100644 index 0bc56eb55e..0000000000 --- a/tests/resources/functional/snowflake/misc/test_contains_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT contains('SparkSQL', 'Spark'); - --- databricks sql: -SELECT CONTAINS('SparkSQL', 'Spark'); diff --git a/tests/resources/functional/snowflake/misc/test_equal_null_1.sql b/tests/resources/functional/snowflake/misc/test_equal_null_1.sql deleted file mode 100644 index a56ebe6143..0000000000 --- a/tests/resources/functional/snowflake/misc/test_equal_null_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT equal_null(2, 2) AS equal_null_col1 FROM tabl; - --- databricks sql: -SELECT EQUAL_NULL(2, 2) AS equal_null_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_hash_1.sql b/tests/resources/functional/snowflake/misc/test_hash_1.sql deleted file mode 100644 index 3b2daa784f..0000000000 --- a/tests/resources/functional/snowflake/misc/test_hash_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT hash(col1) AS hash_col1 FROM tabl; - --- databricks sql: -SELECT HASH(col1) AS hash_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_iff_1.sql b/tests/resources/functional/snowflake/misc/test_iff_1.sql deleted file mode 100644 index 40992d519e..0000000000 --- a/tests/resources/functional/snowflake/misc/test_iff_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT iff(cond, col1, col2) AS iff_col1 FROM tabl; - --- databricks sql: -SELECT IF(cond, col1, col2) AS iff_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_ifnull_1.sql b/tests/resources/functional/snowflake/misc/test_ifnull_1.sql deleted file mode 100644 index e02a064fd2..0000000000 --- a/tests/resources/functional/snowflake/misc/test_ifnull_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ifnull(col1, 'NA') AS ifnull_col1 FROM tabl; - --- databricks sql: -SELECT COALESCE(col1, 'NA') AS ifnull_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_ifnull_2.sql b/tests/resources/functional/snowflake/misc/test_ifnull_2.sql deleted file mode 100644 index ab998fedf2..0000000000 --- a/tests/resources/functional/snowflake/misc/test_ifnull_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT ifnull(col1) AS ifnull_col1 FROM tabl; - --- databricks sql: -SELECT COALESCE(col1) AS ifnull_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/misc/test_sha2_1.sql b/tests/resources/functional/snowflake/misc/test_sha2_1.sql deleted file mode 100644 index e3b1a9a7ee..0000000000 --- a/tests/resources/functional/snowflake/misc/test_sha2_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- snowflake sql: -select sha2(test_col), sha2(test_col, 256), sha2(test_col, 224) from test_tbl; - --- databricks sql: -SELECT - SHA2(test_col, 256), - SHA2(test_col, 256), - SHA2(test_col, 224) -FROM test_tbl; diff --git a/tests/resources/functional/snowflake/nested_query_with_json_1.sql b/tests/resources/functional/snowflake/nested_query_with_json_1.sql deleted file mode 100644 index e83ff2bcde..0000000000 --- a/tests/resources/functional/snowflake/nested_query_with_json_1.sql +++ /dev/null @@ -1,32 +0,0 @@ --- snowflake sql: -SELECT A.COL1, A.COL2, B.COL3, B.COL4 FROM - (SELECT COL1, COL2 FROM TABLE1) A, - (SELECT VALUE:PRICE::FLOAT AS COL3, COL4 FROM - (SELECT * FROM TABLE2 ) AS K - ) B - WHERE A.COL1 = B.COL4; - --- databricks sql: -SELECT - A.COL1, - A.COL2, - B.COL3, - B.COL4 -FROM ( - SELECT - COL1, - COL2 - FROM TABLE1 -) AS A, ( - SELECT - CAST(VALUE:PRICE AS DOUBLE) AS COL3, - COL4 - FROM ( - SELECT - * - FROM TABLE2 - ) AS K -) AS B -WHERE - A.COL1 = B.COL4; - diff --git a/tests/resources/functional/snowflake/nulls/test_nullif_1.sql b/tests/resources/functional/snowflake/nulls/test_nullif_1.sql deleted file mode 100644 index e5c18de906..0000000000 --- a/tests/resources/functional/snowflake/nulls/test_nullif_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nullif(col1, col2) AS nullif_col1 FROM tabl; - --- databricks sql: -SELECT NULLIF(col1, col2) AS nullif_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake/nulls/test_nullifzero_1.sql b/tests/resources/functional/snowflake/nulls/test_nullifzero_1.sql deleted file mode 100644 index 593fc2a5c0..0000000000 --- a/tests/resources/functional/snowflake/nulls/test_nullifzero_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT t.n, nullifzero(t.n) AS pcol1 FROM tbl t; - --- databricks sql: -SELECT t.n, IF(t.n = 0, NULL, t.n) AS pcol1 FROM tbl AS t; diff --git a/tests/resources/functional/snowflake/nulls/test_nullsafe_eq_1.sql b/tests/resources/functional/snowflake/nulls/test_nullsafe_eq_1.sql deleted file mode 100644 index 92ca93b2e8..0000000000 --- a/tests/resources/functional/snowflake/nulls/test_nullsafe_eq_1.sql +++ /dev/null @@ -1,14 +0,0 @@ --- snowflake sql: -SELECT A.COL1, B.COL2 FROM TABL1 A JOIN TABL2 B ON (A.COL1 = B.COL1 OR (A.COL1 IS NULL AND B.COL1 IS NULL)); - --- databricks sql: -SELECT - A.COL1, - B.COL2 -FROM TABL1 AS A -JOIN TABL2 AS B - ON ( - A.COL1 = B.COL1 OR ( - A.COL1 IS NULL AND B.COL1 IS NULL - ) - ); diff --git a/tests/resources/functional/snowflake/operators/test_bitor_agg_1.sql b/tests/resources/functional/snowflake/operators/test_bitor_agg_1.sql deleted file mode 100644 index 3159861509..0000000000 --- a/tests/resources/functional/snowflake/operators/test_bitor_agg_1.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select bitor_agg(k) from bitwise_example; - --- databricks sql: -SELECT BIT_OR(k) FROM bitwise_example; diff --git a/tests/resources/functional/snowflake/operators/test_bitor_agg_2.sql b/tests/resources/functional/snowflake/operators/test_bitor_agg_2.sql deleted file mode 100644 index f446228d9b..0000000000 --- a/tests/resources/functional/snowflake/operators/test_bitor_agg_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -select s2, bitor_agg(k) from bitwise_example group by s2; - --- databricks sql: -SELECT s2, BIT_OR(k) FROM bitwise_example GROUP BY s2; diff --git a/tests/resources/functional/snowflake/sqlglot-incorrect/test_current_date_1.sql b/tests/resources/functional/snowflake/sqlglot-incorrect/test_current_date_1.sql deleted file mode 100644 index b2e046a02f..0000000000 --- a/tests/resources/functional/snowflake/sqlglot-incorrect/test_current_date_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -SELECT CURRENT_DATE() FROM tabl; - --- databricks sql: -SELECT CURRENT_DATE() FROM tabl; diff --git a/tests/resources/functional/snowflake/sqlglot-incorrect/test_uuid_string_2.sql b/tests/resources/functional/snowflake/sqlglot-incorrect/test_uuid_string_2.sql deleted file mode 100644 index b062e5b50c..0000000000 --- a/tests/resources/functional/snowflake/sqlglot-incorrect/test_uuid_string_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT UUID_STRING('fe971b24-9572-4005-b22f-351e9c09274d','foo'); - --- databricks sql: -SELECT UUID('fe971b24-9572-4005-b22f-351e9c09274d', 'foo'); diff --git a/tests/resources/functional/snowflake/tablesample/test_tablesample_1.sql b/tests/resources/functional/snowflake/tablesample/test_tablesample_1.sql deleted file mode 100644 index de90bb1805..0000000000 --- a/tests/resources/functional/snowflake/tablesample/test_tablesample_1.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: -select * from (select * from example_table) sample (1) seed (99); - --- databricks sql: -SELECT * FROM ( - SELECT * FROM example_table -) TABLESAMPLE (1 PERCENT) REPEATABLE (99); diff --git a/tests/resources/functional/snowflake/tablesample/test_tablesample_2.sql b/tests/resources/functional/snowflake/tablesample/test_tablesample_2.sql deleted file mode 100644 index 0a683be7ac..0000000000 --- a/tests/resources/functional/snowflake/tablesample/test_tablesample_2.sql +++ /dev/null @@ -1,7 +0,0 @@ --- snowflake sql: -select * from (select * from example_table) tablesample (1) seed (99); - --- databricks sql: -SELECT * FROM ( - SELECT * FROM example_table -) TABLESAMPLE (1 PERCENT) REPEATABLE (99); diff --git a/tests/resources/functional/snowflake/tablesample/test_tablesample_3.sql b/tests/resources/functional/snowflake/tablesample/test_tablesample_3.sql deleted file mode 100644 index ba3f2e085d..0000000000 --- a/tests/resources/functional/snowflake/tablesample/test_tablesample_3.sql +++ /dev/null @@ -1,14 +0,0 @@ --- snowflake sql: - - select * - from ( - select * - from t1 join t2 - on t1.a = t2.c - ) sample (1); - ; - --- databricks sql: -SELECT * FROM ( - SELECT * FROM t1 JOIN t2 ON t1.a = t2.c -) TABLESAMPLE (1 PERCENT); diff --git a/tests/resources/functional/snowflake/test_command/test_command_2.sql b/tests/resources/functional/snowflake/test_command/test_command_2.sql deleted file mode 100644 index 9379f18c84..0000000000 --- a/tests/resources/functional/snowflake/test_command/test_command_2.sql +++ /dev/null @@ -1,6 +0,0 @@ --- snowflake sql: -SELECT !(2 = 2) AS always_false - - --- databricks sql: -SELECT !(2 = 2) AS always_false diff --git a/tests/resources/functional/snowflake/test_command/test_command_3.sql b/tests/resources/functional/snowflake/test_command/test_command_3.sql deleted file mode 100644 index 100e361372..0000000000 --- a/tests/resources/functional/snowflake/test_command/test_command_3.sql +++ /dev/null @@ -1,9 +0,0 @@ - --- snowflake sql: -!set exit_on_error = true; -SELECT !(2 = 2) AS always_false; - - --- databricks sql: --- !set exit_on_error = true; -SELECT !(2 = 2) AS always_false diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_10.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_10.sql deleted file mode 100644 index 0ab08e25ec..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_10.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -EXECUTE TASK mytask; - --- databricks sql: --- EXECUTE TASK mytask; diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_11.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_11.sql deleted file mode 100644 index f4d78086af..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_11.sql +++ /dev/null @@ -1,48 +0,0 @@ --- snowflake sql: -SELECT DISTINCT - dst.CREATED_DATE - , dst.task_id - , dd.delivery_id::TEXT AS delivery_id - , dst.ISSUE_CATEGORY - , dst.issue - , dd.store_id - FROM proddb.public.dimension_salesforce_tasks dst - JOIN edw.finance.dimension_deliveries dd - ON dd.delivery_id = dst.delivery_id - WHERE dst.mto_flag = 1 - AND dst.customer_type IN ('Consumer') - AND dd.STORE_ID IN (SELECT store_id FROM foo.bar.cng_stores_stage) - AND dd.is_test = false - AND dst.origin IN ('Chat') - AND dd_agent_id IS NOT NULL - AND dst.CREATED_DATE > CURRENT_DATE - 7 - ORDER BY 1 DESC, 3 DESC; - ; - --- databricks sql: -SELECT DISTINCT - dst.CREATED_DATE, - dst.task_id, - CAST(dd.delivery_id AS STRING) AS delivery_id, - dst.ISSUE_CATEGORY, - dst.issue, - dd.store_id - FROM proddb.public.dimension_salesforce_tasks AS dst - JOIN edw.finance.dimension_deliveries AS dd - ON dd.delivery_id = dst.delivery_id - WHERE - dst.mto_flag = 1 - AND dst.customer_type IN ('Consumer') - AND dd.STORE_ID IN ( - SELECT - store_id - FROM foo.bar.cng_stores_stage - ) - AND dd.is_test = false - AND dst.origin IN ('Chat') - AND dd_agent_id IS NOT NULL - AND dst.CREATED_DATE > CURRENT_DATE() - 7 - ORDER BY - 1 DESC NULLS FIRST, - 3 DESC NULLS FIRST; - diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_2.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_2.sql deleted file mode 100644 index 7660368601..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_2.sql +++ /dev/null @@ -1,5 +0,0 @@ - --- snowflake sql: -BEGIN; - --- databricks sql: diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_3.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_3.sql deleted file mode 100644 index f0761574db..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_3.sql +++ /dev/null @@ -1,5 +0,0 @@ - --- snowflake sql: -ROLLBACK; - --- databricks sql: diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_4.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_4.sql deleted file mode 100644 index 27972c1a8e..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_4.sql +++ /dev/null @@ -1,5 +0,0 @@ - --- snowflake sql: -COMMIT; - --- databricks sql: diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_7.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_7.sql deleted file mode 100644 index 9e7984430f..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_7.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SHOW STREAMS LIKE 'line%' IN tpch.public; - --- databricks sql: --- SHOW STREAMS LIKE 'line%' IN tpch.public; diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_8.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_8.sql deleted file mode 100644 index dfa2a7dcfd..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_8.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -ALTER TABLE tab1 ADD COLUMN c2 NUMBER; - --- databricks sql: -ALTER TABLE tab1 ADD COLUMN c2 DECIMAL(38, 0); diff --git a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_9.sql b/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_9.sql deleted file mode 100644 index a7d87855f7..0000000000 --- a/tests/resources/functional/snowflake/test_skip_unsupported_operations/test_skip_unsupported_operations_9.sql +++ /dev/null @@ -1,13 +0,0 @@ - --- snowflake sql: - - CREATE TASK t1 - SCHEDULE = '30 MINUTE' - TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24' - USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = 'XSMALL' - AS - INSERT INTO mytable(ts) VALUES(CURRENT_TIMESTAMP); - ; - --- databricks sql: --- CREATE TASK t1 SCHEDULE = '30 MINUTE' TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24' USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = 'XSMALL' AS INSERT INTO mytable(ts) VALUES(CURRENT_TIMESTAMP); diff --git a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_1.sql b/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_1.sql deleted file mode 100644 index 3b42445228..0000000000 --- a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_1.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -select emp_id from abc.emp where emp_id = &ids; - --- databricks sql: -select emp_id from abc.emp where emp_id = $ids; diff --git a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_2.sql b/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_2.sql deleted file mode 100644 index ec07bee841..0000000000 --- a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_2.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -select emp_id from abc.emp where emp_id = $ids; - --- databricks sql: -select emp_id from abc.emp where emp_id = $ids; diff --git a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_3.sql b/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_3.sql deleted file mode 100644 index ed8e90455d..0000000000 --- a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_3.sql +++ /dev/null @@ -1,5 +0,0 @@ --- snowflake sql: -select count(*) from &TEST_USER.EMP_TBL; - --- databricks sql: -select count(*) from $TEST_USER.EMP_TBL; diff --git a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_4.sql b/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_4.sql deleted file mode 100644 index a8a71b2bfb..0000000000 --- a/tests/resources/functional/snowflake/test_tokens_parameter/test_tokens_parameter_4.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Note that we cannot enable the WHERE clause here as teh python --- tests will fail because SqlGlot cannot translate variable references --- within strings. Enable the WHERE clause when we are not limited by Python - --- WHERE EMP_ID = '&empNo' => WHERE EMP_ID = '${empNo}' - --- snowflake sql: -select count(*) from &TEST_USER.EMP_TBL; - --- databricks sql: -select count(*) from $TEST_USER.EMP_TBL; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_approx_percentile_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_approx_percentile_2.sql deleted file mode 100644 index 0f32aae892..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_approx_percentile_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT approx_percentile(col1) AS approx_percentile_col1 FROM tabl; - --- databricks sql: -SELECT APPROX_PERCENTILE(col1) AS approx_percentile_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_array_contains_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_array_contains_2.sql deleted file mode 100644 index 70b62d8645..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_array_contains_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_contains(arr_col) AS array_contains_col1 FROM tabl; - --- databricks sql: -SELECT ARRAY_CONTAINS(arr_col) AS array_contains_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_array_slice_3.sql b/tests/resources/functional/snowflake_expected_exceptions/test_array_slice_3.sql deleted file mode 100644 index 00963f129f..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_array_slice_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT array_slice(array_construct(90,91,92,93,94,95,96), -4, -1); - --- databricks sql: -SELECT SLICE(ARRAY(90, 91, 92, 93, 94, 95, 96), -4, -1); diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_date_part_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_date_part_2.sql deleted file mode 100644 index 4ce19bcec3..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_date_part_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT date_part(col1) AS date_part_col1 FROM tabl; - --- databricks sql: -SELECT DATE_PART(col1) AS date_part_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_date_trunc_5.sql b/tests/resources/functional/snowflake_expected_exceptions/test_date_trunc_5.sql deleted file mode 100644 index 0b0cb9e5bb..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_date_trunc_5.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT date_trunc(col1) AS date_trunc_col1 FROM tabl; - --- databricks sql: -SELECT DATE_TRUNC(col1) AS date_trunc_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_dayname_4.sql b/tests/resources/functional/snowflake_expected_exceptions/test_dayname_4.sql deleted file mode 100644 index 8610daf168..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_dayname_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT DAYNAME('2015-04-03 10:00', 'EEE') AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT('2015-04-03 10:00', 'E') AS MONTH; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_extract_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_extract_2.sql deleted file mode 100644 index e98ac7a9b7..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_extract_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT extract(col1) AS extract_col1 FROM tabl; - --- databricks sql: -SELECT EXTRACT(col1) AS extract_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_iff_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_iff_2.sql deleted file mode 100644 index 7263354c2d..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_iff_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT iff(col1) AS iff_col1 FROM tabl; - --- databricks sql: -SELECT IFF(col1) AS iff_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_left_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_left_2.sql deleted file mode 100644 index 8c9f3a90fd..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_left_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT left(col1) AS left_col1 FROM tabl; - --- databricks sql: -SELECT LEFT(col1) AS left_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_monthname_8.sql b/tests/resources/functional/snowflake_expected_exceptions/test_monthname_8.sql deleted file mode 100644 index 8a2b45949d..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_monthname_8.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT MONTHNAME('2015-04-03 10:00', 'MMM') AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT('2015-04-03 10:00', 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_monthname_9.sql b/tests/resources/functional/snowflake_expected_exceptions/test_monthname_9.sql deleted file mode 100644 index 2572d2c7f9..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_monthname_9.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT DAYNAME('2015-04-03 10:00', 'MMM') AS MONTH; - --- databricks sql: -SELECT DATE_FORMAT('2015-04-03 10:00', 'MMM') AS MONTH; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_nullif_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_nullif_2.sql deleted file mode 100644 index 154b69f247..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_nullif_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nullif(col1) AS nullif_col1 FROM tabl; - --- databricks sql: -SELECT NULLIF(col1) AS nullif_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_nvl2_3.sql b/tests/resources/functional/snowflake_expected_exceptions/test_nvl2_3.sql deleted file mode 100644 index b91edf80a4..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_nvl2_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT nvl2(col1) AS nvl2_col1 FROM tabl; - --- databricks sql: -SELECT NVL2(col1) AS nvl2_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_parse_json_extract_path_text_4.sql b/tests/resources/functional/snowflake_expected_exceptions/test_parse_json_extract_path_text_4.sql deleted file mode 100644 index 80499218ea..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_parse_json_extract_path_text_4.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT JSON_EXTRACT_PATH_TEXT('{}') FROM demo1; - --- databricks sql: -SELECT GET_JSON_OBJECT('{}', CONCAT('$.', path_col)) FROM demo1; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_position_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_position_2.sql deleted file mode 100644 index 9fb1b9f0cd..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_position_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT position(col1) AS position_col1 FROM tabl; - --- databricks sql: -SELECT POSITION(col1) AS position_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_like_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_regexp_like_2.sql deleted file mode 100644 index d8b903bde8..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_like_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_like(col1) AS regexp_like_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_LIKE(col1) AS regexp_like_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_replace_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_regexp_replace_2.sql deleted file mode 100644 index 26565cce06..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_replace_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_replace(col1) AS regexp_replace_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_REPLACE(col1) AS regexp_replace_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_substr_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_regexp_substr_2.sql deleted file mode 100644 index fa2fc7266e..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_regexp_substr_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT regexp_substr(col1) AS regexp_substr_col1 FROM tabl; - --- databricks sql: -SELECT REGEXP_SUBSTR(col1) AS regexp_substr_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_repeat_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_repeat_2.sql deleted file mode 100644 index 45ac0f0937..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_repeat_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT repeat(col1) AS repeat_col1 FROM tabl; - --- databricks sql: -SELECT REPEAT(col1) AS repeat_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_right_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_right_2.sql deleted file mode 100644 index 7a1e7346d2..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_right_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT right(col1) AS left_col1 FROM tabl; - --- databricks sql: -SELECT RIGHT(col1) AS left_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_split_part_7.sql b/tests/resources/functional/snowflake_expected_exceptions/test_split_part_7.sql deleted file mode 100644 index 84454d3765..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_split_part_7.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT SPLIT_PART('lit_string', ','); - --- databricks sql: -SELECT SPLIT_PART('lit_string', ',', 5); diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_split_part_8.sql b/tests/resources/functional/snowflake_expected_exceptions/test_split_part_8.sql deleted file mode 100644 index f16f54dde3..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_split_part_8.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT split_part(col1) AS split_part_col1 FROM tabl; - --- databricks sql: -SELECT SPLIT_PART(col1) AS split_part_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_startswith_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_startswith_2.sql deleted file mode 100644 index 649413e621..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_startswith_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT startswith(col1) AS startswith_col1 FROM tabl; - --- databricks sql: -SELECT STARTSWITH(col1) AS startswith_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_timestampadd_6.sql b/tests/resources/functional/snowflake_expected_exceptions/test_timestampadd_6.sql deleted file mode 100644 index d7726f1040..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_timestampadd_6.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT timestampadd(col1) AS timestampadd_col1 FROM tabl; - --- databricks sql: -SELECT DATEADD(col1) AS timestampadd_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_to_number_10.sql b/tests/resources/functional/snowflake_expected_exceptions/test_to_number_10.sql deleted file mode 100644 index a66887a6c7..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_to_number_10.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT TO_NUMERIC('$345', '$999.99', 5, 2, 1) AS num_with_scale; - --- databricks sql: -SELECT CAST(TO_NUMBER('$345', '$999.99') AS DECIMAL(5, 2)) AS num_with_scale; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_trunc_2.sql b/tests/resources/functional/snowflake_expected_exceptions/test_trunc_2.sql deleted file mode 100644 index e7944c19c8..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_trunc_2.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT trunc(col1) AS trunc_col1 FROM tabl; - --- databricks sql: -SELECT TRUNC(col1) AS trunc_col1 FROM tabl; diff --git a/tests/resources/functional/snowflake_expected_exceptions/test_try_cast_3.sql b/tests/resources/functional/snowflake_expected_exceptions/test_try_cast_3.sql deleted file mode 100644 index 05379d31f6..0000000000 --- a/tests/resources/functional/snowflake_expected_exceptions/test_try_cast_3.sql +++ /dev/null @@ -1,6 +0,0 @@ - --- snowflake sql: -SELECT try_cast(col1) AS try_cast_col1 FROM tabl; - --- databricks sql: -SELECT TRY_CAST(col1) AS try_cast_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/core_engine/dbt/nofmt_twisted_input.sql b/tests/resources/functional/tsql/core_engine/dbt/nofmt_twisted_input.sql deleted file mode 100644 index 10309ea2ce..0000000000 --- a/tests/resources/functional/tsql/core_engine/dbt/nofmt_twisted_input.sql +++ /dev/null @@ -1,27 +0,0 @@ --- tsql sql: -{%- set payment_methods = dbt_utils.get_column_values( - table=ref('raw_payments'), - column='payment_method' -) -%} - -select - order_id, - {%- for payment_method in payment_methods %} - sum(case when payment_method = '{{payment_method}}' then amount end) as {{payment_method}}_amount - {%- if not loop.last %},{% endif -%} - {% endfor %} - from {{ ref('raw_payments') }} - group by 1 --- databricks sql: -{%- set payment_methods = dbt_utils.get_column_values( - table=ref('raw_payments'), - column='payment_method' -) -%} - -SELECT order_id, - {%- for payment_method in payment_methods %} - SUM(CASE WHEN payment_method = '{{payment_method}}' THEN amount END) AS {{payment_method}}_amount - {%- if not loop.last %},{% endif -%} - {% endfor %} - FROM {{ ref('raw_payments') }} - GROUP BY 1; diff --git a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_1.sql b/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_1.sql deleted file mode 100644 index 6912e2a8f2..0000000000 --- a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_1.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Note that here we have two commas in the select clause and teh TSQL grammar not --- quite as bad as the Snowflake grammar, is able to see that it can delete - --- tsql sql: -select col1,, col2 from table_name; - --- databricks sql: -SELECT - col1, -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: unexpected extra input ',' while parsing a SELECT statement - expecting one of: $Currency, 'String', @@Reference, @Local, Float, Identifier, Integer, Operator, Real, Statement, '$ACTION', '$NODE_ID'... - Unparsable text: , - */ - col2 -FROM - table_name; diff --git a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_2.sql b/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_2.sql deleted file mode 100644 index b1bd7ee603..0000000000 --- a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- tsql sql: -* - --- databricks sql: -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: unexpected extra input '*' while parsing a T-SQL batch - expecting one of: End of batch, Identifier, Select Statement, Statement, '$NODE_ID', '(', ';', 'ACCOUNTADMIN', 'ALERT', 'ARRAY', 'BODY', 'BULK'... - Unparsable text: * - */ diff --git a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_3.sql b/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_3.sql deleted file mode 100644 index efcaa7c067..0000000000 --- a/tests/resources/functional/tsql/core_engine/test_invalid_syntax/syntax_error_3.sql +++ /dev/null @@ -1,23 +0,0 @@ --- The TSql parser is much better than the Snowflake one because it does not have the --- super ambiguous LET statement that makes it impossible for batch level queries to --- recover from syntax errors. Note here how TSQL has stupid grammar though as A and B --- could be columns with a missing ',' but we cannot know. --- tsql sql: -* ; -SELECT 1 ; -SELECT A B FROM C ; - --- databricks sql: -/* The following issues were detected: - - Unparsed input - ErrorNode encountered - Unparsable text: unexpected extra input '*' while parsing a T-SQL batch - expecting one of: End of batch, Identifier, Select Statement, Statement, '$NODE_ID', '(', ';', 'ACCOUNTADMIN', 'ALERT', 'ARRAY', 'BODY', 'BULK'... - Unparsable text: * - */ -SELECT - 1; -SELECT - A AS B -FROM - C; diff --git a/tests/resources/functional/tsql/cte/cte_set_operation_precedence.sql b/tests/resources/functional/tsql/cte/cte_set_operation_precedence.sql deleted file mode 100644 index 50980b98a3..0000000000 --- a/tests/resources/functional/tsql/cte/cte_set_operation_precedence.sql +++ /dev/null @@ -1,17 +0,0 @@ --- --- CTEs are visible to all the SELECT queries within a subsequent sequence of set operations. --- - --- tsql sql: -WITH a AS (SELECT 1, 2, 3) - -SELECT 4, 5, 6 -UNION -SELECT * FROM a; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3) - -(SELECT 4, 5, 6) -UNION -(SELECT * FROM a); diff --git a/tests/resources/functional/tsql/cte/cte_with_column_list.sql b/tests/resources/functional/tsql/cte/cte_with_column_list.sql deleted file mode 100644 index a61e7f2e58..0000000000 --- a/tests/resources/functional/tsql/cte/cte_with_column_list.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- A simple CTE, with the column list expressed. --- - --- tsql sql: -WITH a (b, c, d) AS (SELECT 1 AS b, 2 AS c, 3 AS d) -SELECT b, c, d FROM a; - --- databricks sql: -WITH a (b, c, d) AS (SELECT 1 AS b, 2 AS c, 3 AS d) -SELECT b, c, d FROM a; diff --git a/tests/resources/functional/tsql/cte/multiple_cte.sql b/tests/resources/functional/tsql/cte/multiple_cte.sql deleted file mode 100644 index ba7c2ea66e..0000000000 --- a/tests/resources/functional/tsql/cte/multiple_cte.sql +++ /dev/null @@ -1,19 +0,0 @@ --- --- Verify a few CTEs that include multiple expressions. --- - --- tsql sql: -WITH a AS (SELECT 1, 2, 3), - b AS (SELECT 4, 5, 6), - c AS (SELECT * FROM a) -SELECT * from b -UNION -SELECT * FROM c; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3), - b AS (SELECT 4, 5, 6), - c AS (SELECT * FROM a) -(SELECT * from b) -UNION -(SELECT * FROM c); diff --git a/tests/resources/functional/tsql/cte/nested_set_operation.sql b/tests/resources/functional/tsql/cte/nested_set_operation.sql deleted file mode 100644 index 7d1e0f380f..0000000000 --- a/tests/resources/functional/tsql/cte/nested_set_operation.sql +++ /dev/null @@ -1,19 +0,0 @@ --- --- Verify a CTE that includes set operations. --- - --- tsql sql: -WITH a AS ( - SELECT 1, 2, 3 - UNION - SELECT 4, 5, 6 - ) -SELECT * FROM a; - --- databricks sql: -WITH a AS ( - (SELECT 1, 2, 3) - UNION - (SELECT 4, 5, 6) -) -SELECT * FROM a; diff --git a/tests/resources/functional/tsql/cte/simple_cte.sql b/tests/resources/functional/tsql/cte/simple_cte.sql deleted file mode 100644 index c393f15d36..0000000000 --- a/tests/resources/functional/tsql/cte/simple_cte.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- Verify a simple CTE. --- - --- tsql sql: -WITH a AS (SELECT 1, 2, 3) -SELECT * FROM a; - --- databricks sql: -WITH a AS (SELECT 1, 2, 3) -SELECT * FROM a; diff --git a/tests/resources/functional/tsql/functions/test_aadbts_1.sql b/tests/resources/functional/tsql/functions/test_aadbts_1.sql deleted file mode 100644 index a5d703b921..0000000000 --- a/tests/resources/functional/tsql/functions/test_aadbts_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@DBTS --- --- The @@DBTS function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@DBTS; - --- databricks sql: -SELECT @@DBTS; diff --git a/tests/resources/functional/tsql/functions/test_aalangid1.sql b/tests/resources/functional/tsql/functions/test_aalangid1.sql deleted file mode 100644 index 0e271219fd..0000000000 --- a/tests/resources/functional/tsql/functions/test_aalangid1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@LANGID --- --- The @@LANGID function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@LANGID; - --- databricks sql: -SELECT @@LANGID; diff --git a/tests/resources/functional/tsql/functions/test_aalanguage_1.sql b/tests/resources/functional/tsql/functions/test_aalanguage_1.sql deleted file mode 100644 index 52a5ddd58f..0000000000 --- a/tests/resources/functional/tsql/functions/test_aalanguage_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@LANGUAGE --- --- The @@LANGUAGE function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@LANGUAGE; - --- databricks sql: -SELECT @@LANGUAGE; diff --git a/tests/resources/functional/tsql/functions/test_aalock_timeout_1.sql b/tests/resources/functional/tsql/functions/test_aalock_timeout_1.sql deleted file mode 100644 index e571d6b676..0000000000 --- a/tests/resources/functional/tsql/functions/test_aalock_timeout_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@LOCKTIMEOUT --- --- The @@LOCKTIMEOUT function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@LOCKTIMEOUT; - --- databricks sql: -SELECT @@LOCKTIMEOUT; diff --git a/tests/resources/functional/tsql/functions/test_aamax_connections_1.sql b/tests/resources/functional/tsql/functions/test_aamax_connections_1.sql deleted file mode 100644 index 7e10a44447..0000000000 --- a/tests/resources/functional/tsql/functions/test_aamax_connections_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@MAX_CONNECTIONS --- --- The @@MAX_CONNECTIONS function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@MAX_CONNECTIONS; - --- databricks sql: -SELECT @@MAX_CONNECTIONS; diff --git a/tests/resources/functional/tsql/functions/test_aamax_precision_1.sql b/tests/resources/functional/tsql/functions/test_aamax_precision_1.sql deleted file mode 100644 index ff54d9b474..0000000000 --- a/tests/resources/functional/tsql/functions/test_aamax_precision_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@MAX_PRECISION --- --- The @@MAX_PRECISION function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@MAX_PRECISION; - --- databricks sql: -SELECT @@MAX_PRECISION; diff --git a/tests/resources/functional/tsql/functions/test_aaoptions_1.sql b/tests/resources/functional/tsql/functions/test_aaoptions_1.sql deleted file mode 100644 index fc70013be4..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaoptions_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@OPTIONS --- --- The @@OPTIONS function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@OPTIONS; - --- databricks sql: -SELECT @@OPTIONS; diff --git a/tests/resources/functional/tsql/functions/test_aaremserver_1.sql b/tests/resources/functional/tsql/functions/test_aaremserver_1.sql deleted file mode 100644 index c4a2d7e053..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaremserver_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@REMSERVER --- --- The @@REMSERVER function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@REMSERVER; - --- databricks sql: -SELECT @@REMSERVER; diff --git a/tests/resources/functional/tsql/functions/test_aaservername_1.sql b/tests/resources/functional/tsql/functions/test_aaservername_1.sql deleted file mode 100644 index 88ffeff5c8..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaservername_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@SERVERNAME --- --- The @@SERVERNAME function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@SERVERNAME; - --- databricks sql: -SELECT @@SERVERNAME; diff --git a/tests/resources/functional/tsql/functions/test_aaservicename_1.sql b/tests/resources/functional/tsql/functions/test_aaservicename_1.sql deleted file mode 100644 index 0b7e9651d8..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaservicename_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@SERVICENAME --- --- The @@SERVICENAME function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@SERVICENAME; - --- databricks sql: -SELECT @@SERVICENAME; diff --git a/tests/resources/functional/tsql/functions/test_aaspid_1.sql b/tests/resources/functional/tsql/functions/test_aaspid_1.sql deleted file mode 100644 index 229f5897ed..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaspid_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@SPID --- --- The @@DBTS function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@SPID; - --- databricks sql: -SELECT @@SPID; diff --git a/tests/resources/functional/tsql/functions/test_aatextsize_1.sql b/tests/resources/functional/tsql/functions/test_aatextsize_1.sql deleted file mode 100644 index 4c27303445..0000000000 --- a/tests/resources/functional/tsql/functions/test_aatextsize_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@TEXTSIZE --- --- The @@TEXTSIZE function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@TEXTSIZE; - --- databricks sql: -SELECT @@TEXTSIZE; diff --git a/tests/resources/functional/tsql/functions/test_aaversion_1.sql b/tests/resources/functional/tsql/functions/test_aaversion_1.sql deleted file mode 100644 index cf276afc58..0000000000 --- a/tests/resources/functional/tsql/functions/test_aaversion_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@VERSION --- --- The @@VERSION function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@VERSION; - --- databricks sql: -SELECT @@VERSION; diff --git a/tests/resources/functional/tsql/functions/test_abs_1.sql b/tests/resources/functional/tsql/functions/test_abs_1.sql deleted file mode 100644 index 524fa7b53c..0000000000 --- a/tests/resources/functional/tsql/functions/test_abs_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##ABS --- --- The ABS function is identical in TSql and Databricks. --- --- tsql sql: -SELECT abs(col1) AS abs_col1 FROM tabl; - --- databricks sql: -SELECT ABS(col1) AS abs_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_approx_count_distinct.sql b/tests/resources/functional/tsql/functions/test_approx_count_distinct.sql deleted file mode 100644 index d59dc81b68..0000000000 --- a/tests/resources/functional/tsql/functions/test_approx_count_distinct.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ##APPROX_COUNT_DISTINCT --- --- This function is identical to the APPROX_COUNT_DISTINCT function in Databricks. Though --- the syntax is the same, the results may differ slightly due to the difference in the implementations --- and the fact that it is an approximation. - --- tsql sql: -SELECT APPROX_COUNT_DISTINCT(col1) AS approx_count_distinct_col1 FROM tabl; - --- databricks sql: -SELECT APPROX_COUNT_DISTINCT(col1) AS approx_count_distinct_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_approx_percentile_cont_1.sql b/tests/resources/functional/tsql/functions/test_approx_percentile_cont_1.sql deleted file mode 100644 index 1ca5ad3e76..0000000000 --- a/tests/resources/functional/tsql/functions/test_approx_percentile_cont_1.sql +++ /dev/null @@ -1,12 +0,0 @@ --- ##APPROX_PERCENTILE_CONT --- --- Note that TSQL uses a continuous distribution model and requires an ORDER BY clause. --- Databricks uses an approximate distribution algorithm, and does not require an ORDER BY clause. --- The results may differ slightly due to the difference, but as teh result from both is an approximation, --- the difference is unlikely to be significant. - --- tsql sql: -SELECT APPROX_PERCENTILE_CONT(col1) WITHIN GROUP (ORDER BY something) AS approx_percentile_col1 FROM tabl; - --- databricks sql: -SELECT APPROX_PERCENTILE(col1) AS approx_percentile_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_approx_percentile_disc_1.sql b/tests/resources/functional/tsql/functions/test_approx_percentile_disc_1.sql deleted file mode 100644 index 701b16c052..0000000000 --- a/tests/resources/functional/tsql/functions/test_approx_percentile_disc_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## APPROX_PERCENTILE_DISC --- --- This function has no direct equivalent in Databricks. The closest equivalent is the PERCENTILE function. --- Approximations are generally faster then exact calculations, so performance may be something to explore. - --- tsql sql: -SELECT APPROX_PERCENTILE_DISC(0.5) WITHIN GROUP(ORDER BY col1) AS percent50 FROM tabl; - --- databricks sql: -SELECT PERCENTILE(col1, 0.5) AS percent50 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_avg_1.sql b/tests/resources/functional/tsql/functions/test_avg_1.sql deleted file mode 100644 index fe2fd6c292..0000000000 --- a/tests/resources/functional/tsql/functions/test_avg_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## AVG --- --- This function is directly equivalent in Databricks SQL. - --- tsql sql: -SELECT AVG(col1) AS vagcol1 FROM tabl; - --- databricks sql: -SELECT AVG(col1) AS vagcol1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_avg_2.sql b/tests/resources/functional/tsql/functions/test_avg_2.sql deleted file mode 100644 index 51571bb834..0000000000 --- a/tests/resources/functional/tsql/functions/test_avg_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## AVG with DISTINCT clause --- --- This function is directly equivalent in Databricks. - --- tsql sql: -SELECT AVG(DISTINCT col1) AS vagcol1 FROM tabl; - --- databricks sql: -SELECT AVG(DISTINCT col1) AS vagcol1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_avg_3.sql b/tests/resources/functional/tsql/functions/test_avg_3.sql deleted file mode 100644 index 6b0ac4d7ef..0000000000 --- a/tests/resources/functional/tsql/functions/test_avg_3.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## AVG with ALL clause --- --- This function is directly equivalent in Databricks. --- However, as ALL does not change the result, it is not necessary to include it in the Databricks SQL and --- it is elided. - --- tsql sql: -SELECT AVG(ALL col1) AS vagcol1 FROM tabl; - --- databricks sql: -SELECT AVG(col1) AS vagcol1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_avg_4.sql b/tests/resources/functional/tsql/functions/test_avg_4.sql deleted file mode 100644 index 45533f580c..0000000000 --- a/tests/resources/functional/tsql/functions/test_avg_4.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## AVG with the DISTINCT and OVER clauses --- --- This function is directly equivalent in Databricks when used with the DISTINCT clause, - --- tsql sql: -SELECT AVG(DISTINCT col1) OVER (PARTITION BY col1 ORDER BY col1 ASC) AS avgcol1 FROM tabl; - --- databricks sql: -SELECT AVG(DISTINCT col1) OVER (PARTITION BY col1 ORDER BY col1 ASC) AS avgcol1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_avg_5.sql b/tests/resources/functional/tsql/functions/test_avg_5.sql deleted file mode 100644 index 43db9a03a3..0000000000 --- a/tests/resources/functional/tsql/functions/test_avg_5.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## AVG with the DISTINCT and OVER clauses --- --- This function is directly equivalent in Databricks, when used with the DISTINCT clause. --- --- tsql sql: -SELECT AVG(DISTINCT col1) OVER (PARTITION BY col1 ORDER BY col1 ASC) AS avgcol1, - AVG(DISTINCT col2) FROM tabl; - --- databricks sql: -SELECT AVG(DISTINCT col1) OVER (PARTITION BY col1 ORDER BY col1 ASC) AS avgcol1, - AVG(DISTINCT col2) FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_bit_count_1.sql b/tests/resources/functional/tsql/functions/test_bit_count_1.sql deleted file mode 100644 index 9c8cd17ce4..0000000000 --- a/tests/resources/functional/tsql/functions/test_bit_count_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## BIT_COUNT --- --- The BIT_COUNT function is identical in TSql and Databricks. --- --- tsql sql: -SELECT BIT_COUNT(42); - --- databricks sql: -SELECT BIT_COUNT(42); diff --git a/tests/resources/functional/tsql/functions/test_checksum_agg_1.sql b/tests/resources/functional/tsql/functions/test_checksum_agg_1.sql deleted file mode 100644 index 780c5a23bf..0000000000 --- a/tests/resources/functional/tsql/functions/test_checksum_agg_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## CHECKSUM_AGG --- --- There is no direct equivalent of CHECKSUM_AGG in Databricks SQL. The following --- conversion is a suggestion and may not be perfectly functional. - --- tsql sql: -SELECT CHECKSUM_AGG(col1) FROM t1; - --- databricks sql: -SELECT MD5(CONCAT_WS(',', ARRAY_AGG(col1))) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_collationproperty_1.sql b/tests/resources/functional/tsql/functions/test_collationproperty_1.sql deleted file mode 100644 index c61695ca99..0000000000 --- a/tests/resources/functional/tsql/functions/test_collationproperty_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ##COLLATIONPROPERTY --- --- The COLLATIONPROPERTY function is unsupported in Databricks SQL as collation --- tends to be a function of the underlying system. --- --- tsql sql: -SELECT COLLATIONPROPERTY('somelocale', 'someproperty'); - --- databricks sql: -SELECT COLLATIONPROPERTY('somelocale', 'someproperty'); diff --git a/tests/resources/functional/tsql/functions/test_count_1.sql b/tests/resources/functional/tsql/functions/test_count_1.sql deleted file mode 100644 index 7ea94f6d7a..0000000000 --- a/tests/resources/functional/tsql/functions/test_count_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## COUNT --- --- The TSQl COUNT function and the DataBricks COUNT function are equivalent. --- --- tsql sql: -SELECT COUNT(*) FROM t1; - --- databricks sql: -SELECT COUNT(*) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_count_2.sql b/tests/resources/functional/tsql/functions/test_count_2.sql deleted file mode 100644 index 16cecab7a9..0000000000 --- a/tests/resources/functional/tsql/functions/test_count_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## COUNT --- --- The TSQl COUNT function and the DataBricks COUNT function are equivalent. --- --- tsql sql: -SELECT COUNT(DISTINCT col1) FROM t1; - --- databricks sql: -SELECT COUNT(DISTINCT col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_cume_dist_1.sql b/tests/resources/functional/tsql/functions/test_cume_dist_1.sql deleted file mode 100644 index 96115f8c55..0000000000 --- a/tests/resources/functional/tsql/functions/test_cume_dist_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## CUME_DIST --- --- The CUME_DIST function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, cume_dist() OVER (PARTITION BY col1 ORDER BY col2) AS cume_dist FROM tabl; - --- databricks sql: -SELECT col1, col2, cume_dist() OVER (PARTITION BY col1 ORDER BY col2) AS cume_dist FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_day_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_day_1.sql deleted file mode 100644 index 425d0c6ffe..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_day_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the DAY keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(day, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_day_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_day_2.sql deleted file mode 100644 index 3084c2f5a2..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_day_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the DD keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(dd, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_day_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_day_3.sql deleted file mode 100644 index 03f603b434..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_day_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the D keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(d, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_1.sql deleted file mode 100644 index 3ee1b8379e..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the DAYOFYEAR keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(dayofyear, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_2.sql deleted file mode 100644 index 71a7c0a0b2..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the DY keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(dy, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_3.sql deleted file mode 100644 index 1d2a2ab880..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_dayofyear_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the Y keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(y, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_hour_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_hour_1.sql deleted file mode 100644 index f5f4ab8694..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_hour_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the HOUR keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment HOUR - --- tsql sql: -SELECT DATEADD(hour, 7, col1) AS add_hours_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 HOUR AS add_hours_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_hour_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_hour_2.sql deleted file mode 100644 index 77d69cd154..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_hour_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the HH keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment HOUR - --- tsql sql: -SELECT DATEADD(hh, 7, col1) AS add_hours_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 HOUR AS add_hours_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_microsecond_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_microsecond_1.sql deleted file mode 100644 index c66b2a17f5..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_microsecond_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MICROSECOND keyword --- --- Databricks SQL does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MICROSECOND - --- tsql sql: -SELECT DATEADD(MICROSECOND, 7, col1) AS add_microsecond_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MICROSECOND AS add_microsecond_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_microsecond_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_microsecond_2.sql deleted file mode 100644 index ed5bd991cc..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_microsecond_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MCS keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MICROSECOND - --- tsql sql: -SELECT DATEADD(mcs, 7, col1) AS add_microsecond_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MICROSECOND AS add_microsecond_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_millisecond_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_millisecond_1.sql deleted file mode 100644 index 22af9c8265..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_millisecond_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MILLISECOND keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MILLISECOND - --- tsql sql: -SELECT DATEADD(millisecond, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MILLISECOND AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_millisecond_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_millisecond_2.sql deleted file mode 100644 index bf04f38770..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_millisecond_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MS keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MILLISECOND - --- tsql sql: -SELECT DATEADD(ms, 7, col1) AS add_milliseconds_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MILLISECOND AS add_milliseconds_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_minute_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_minute_1.sql deleted file mode 100644 index 85de3a7c9d..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_minute_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MINUTE keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MINUTE - --- tsql sql: -SELECT DATEADD(minute, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MINUTE AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_minute_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_minute_2.sql deleted file mode 100644 index 51b564a178..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_minute_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MI keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MINUTE - --- tsql sql: -SELECT DATEADD(mi, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MINUTE AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_minute_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_minute_3.sql deleted file mode 100644 index fba1d5e8b8..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_minute_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the MI keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment MINUTE - --- tsql sql: -SELECT DATEADD(n, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 MINUTE AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_month_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_month_1.sql deleted file mode 100644 index ec2287bb08..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_month_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the MONTH keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function. - - --- tsql sql: -SELECT DATEADD(MONTH, 1, col1) AS add_months_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 1) AS add_months_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_month_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_month_2.sql deleted file mode 100644 index 4f8868a1d9..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_month_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the MM keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function. - - --- tsql sql: -SELECT DATEADD(mm, 1, col1) AS add_months_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 1) AS add_months_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_month_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_month_3.sql deleted file mode 100644 index 61cc95f0d5..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_month_3.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the M keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function. - - --- tsql sql: -SELECT DATEADD(m, 1, col1) AS add_months_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 1) AS add_months_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_1.sql deleted file mode 100644 index 688c836591..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the NANOSECOND keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment NANOSECOND - --- tsql sql: -SELECT DATEADD(NANOSECOND, 7, col1) AS add_nanoseconds_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 NANOSECOND AS add_nanoseconds_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_2.sql deleted file mode 100644 index 63886749a7..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_nanosecond_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the NANOSECOND keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment NS - --- tsql sql: -SELECT DATEADD(NS, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 NANOSECOND AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_quarter_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_quarter_1.sql deleted file mode 100644 index 5d8451c6a5..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_quarter_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the QUARTER keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 3. - --- tsql sql: -SELECT DATEADD(QUARTER, 2, col1) AS add_quarters_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 3) AS add_quarters_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_quarter_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_quarter_2.sql deleted file mode 100644 index a34dca06d0..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_quarter_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the QQ keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 3. - --- tsql sql: -SELECT DATEADD(qq, 2, col1) AS add_quarters_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 3) AS add_quarters_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_quarter_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_quarter_3.sql deleted file mode 100644 index 2c3f4ef436..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_quarter_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the Q keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 3. - --- tsql sql: -SELECT DATEADD(q, 2, col1) AS add_quarters_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 3) AS add_quarters_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_second_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_second_1.sql deleted file mode 100644 index 7c9a326599..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_second_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the SECOND keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment SECOND - --- tsql sql: -SELECT DATEADD(second, 7, col1) AS add_seconds_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 SECOND AS add_seconds_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_second_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_second_2.sql deleted file mode 100644 index 0f2829dceb..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_second_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the SS keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment SECOND - --- tsql sql: -SELECT DATEADD(ss, 7, col1) AS add_seconds_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 SECOND AS add_seconds_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_second_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_second_3.sql deleted file mode 100644 index 0853177f0b..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_second_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the S keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- INTERVAL increment SECOND - --- tsql sql: -SELECT DATEADD(s, 7, col1) AS add_minutes_col1 FROM tabl; - --- databricks sql: -SELECT col1 + INTERVAL 7 SECOND AS add_minutes_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_week_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_week_1.sql deleted file mode 100644 index 05991b882b..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_week_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the WEEK keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD with the number of weeks multiplied by 7. - --- tsql sql: -SELECT DATEADD(week, 2, col1) AS add_weeks_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2 * 7) AS add_weeks_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_week_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_week_2.sql deleted file mode 100644 index 9a132835a1..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_week_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the WK keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD with the number of weeks multiplied by 7. - --- tsql sql: -SELECT DATEADD(wk, 2, col1) AS add_weeks_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2 * 7) AS add_weeks_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_week_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_week_3.sql deleted file mode 100644 index ca8ecbcc96..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_week_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the WW keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD with the number of weeks multiplied by 7. - --- tsql sql: -SELECT DATEADD(ww, 2, col1) AS add_weeks_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2 * 7) AS add_weeks_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_weekday_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_weekday_1.sql deleted file mode 100644 index e7bb477482..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_weekday_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the WEEKDAY keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(weekday, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_weekday_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_weekday_2.sql deleted file mode 100644 index 6d232dd5d9..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_weekday_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the DW keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(DW, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_weekday_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_weekday_3.sql deleted file mode 100644 index cac0617c56..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_weekday_3.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## DATEADD with the W keyword --- --- Databricks SQl does not directly support `DATEADD`, so it is translated to the equivalent --- DATE_ADD as in the context of `DATEADD`, `day`, `dayofyear` and `weekday` are equivalent. - --- tsql sql: -SELECT DATEADD(W, 2, col1) AS add_days_col1 FROM tabl; - --- databricks sql: -SELECT DATE_ADD(col1, 2) AS add_days_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_year_1.sql b/tests/resources/functional/tsql/functions/test_dateadd_year_1.sql deleted file mode 100644 index 07d50f6cf7..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_year_1.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the YEAR keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 12. - - --- tsql sql: -SELECT DATEADD(YEAR, 2, col1) AS add_years_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 12) AS add_years_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_year_2.sql b/tests/resources/functional/tsql/functions/test_dateadd_year_2.sql deleted file mode 100644 index 257d66609b..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_year_2.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the YYYY keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 12. - - --- tsql sql: -SELECT DATEADD(yyyy, 2, col1) AS add_years_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 12) AS add_years_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_dateadd_year_3.sql b/tests/resources/functional/tsql/functions/test_dateadd_year_3.sql deleted file mode 100644 index fd16646f9d..0000000000 --- a/tests/resources/functional/tsql/functions/test_dateadd_year_3.sql +++ /dev/null @@ -1,11 +0,0 @@ --- ## DATEADD with the YY keyword --- --- Databricks SQl does not directly support DATEADD, so it is translated to the equivalent --- ADD_MONTHS function with the number of months multiplied by 12. - - --- tsql sql: -SELECT DATEADD(yy, 2, col1) AS add_years_col1 FROM tabl; - --- databricks sql: -SELECT ADD_MONTHS(col1, 2 * 12) AS add_years_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_first_value_1.sql b/tests/resources/functional/tsql/functions/test_first_value_1.sql deleted file mode 100644 index 7fe13fcef3..0000000000 --- a/tests/resources/functional/tsql/functions/test_first_value_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## FIRST_VALUE --- --- The FIRST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, FIRST_VALUE(col1) OVER (ORDER BY col2 DESC) AS first_value FROM tabl; - --- databricks sql: -SELECT col1, col2, FIRST_VALUE(col1) OVER (ORDER BY col2 DESC) AS first_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_first_value_2.sql b/tests/resources/functional/tsql/functions/test_first_value_2.sql deleted file mode 100644 index 6e2241b840..0000000000 --- a/tests/resources/functional/tsql/functions/test_first_value_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## FIRST_VALUE --- --- The FIRST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, FIRST_VALUE(col1) OVER (ORDER BY col2 ASC) AS first_value FROM tabl; - --- databricks sql: -SELECT col1, col2, FIRST_VALUE(col1) OVER (ORDER BY col2 ASC) AS first_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_first_value_3.sql b/tests/resources/functional/tsql/functions/test_first_value_3.sql deleted file mode 100644 index 1cfad5486c..0000000000 --- a/tests/resources/functional/tsql/functions/test_first_value_3.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## FIRST_VALUE over PARTITIONS --- --- The FIRST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, col3, FIRST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 DESC) AS first_value FROM tabl; - --- databricks sql: -SELECT col1, col2, col3, FIRST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 DESC) AS first_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_first_value_4.sql b/tests/resources/functional/tsql/functions/test_first_value_4.sql deleted file mode 100644 index 480d859d63..0000000000 --- a/tests/resources/functional/tsql/functions/test_first_value_4.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## FIRST_VALUE over PARTITIONS --- --- The FIRST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, col3, FIRST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 ASC ROWS UNBOUNDED PRECEDING) AS first_value FROM tabl; - --- databricks sql: -SELECT col1, col2, col3, FIRST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 ASC ROWS UNBOUNDED PRECEDING) AS first_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_get_bit_1.sql b/tests/resources/functional/tsql/functions/test_get_bit_1.sql deleted file mode 100644 index 010ade0130..0000000000 --- a/tests/resources/functional/tsql/functions/test_get_bit_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## GET_BIT --- --- The GET_BIT function is not supported in Databricks SQL. The following example --- shows how to convert it to a Databricks equivalent --- --- tsql sql: -SELECT GET_BIT(42, 7); - --- databricks sql: -SELECT GETBIT(42, 7); diff --git a/tests/resources/functional/tsql/functions/test_grouping_1.sql b/tests/resources/functional/tsql/functions/test_grouping_1.sql deleted file mode 100644 index 76eb11bbcc..0000000000 --- a/tests/resources/functional/tsql/functions/test_grouping_1.sql +++ /dev/null @@ -1,15 +0,0 @@ --- ## GROUPING --- --- The TSql GROUPING() function is directly equivalent in Databricks SQL. There are however --- some differences that should be accounted for. --- --- - TSql supports GROUPING on column aliases, while Databricks SQL does not. --- - TSql allows GROUPING to be used in GROUPING SETS, The GROUPING function in Databricks --- does not support GROUPING SETS --- - TSql returns a 1 or 0, whereas Databricks returns a boolean - --- tsql sql: -SELECT GROUPING(col1) As g FROM t1 GROUP BY g WITH ROLLUP; - --- databricks sql: -SELECT GROUPING(col1) as g FROM t1 GROUP BY col1 WITH ROLLUP; diff --git a/tests/resources/functional/tsql/functions/test_grouping_id_1.sql b/tests/resources/functional/tsql/functions/test_grouping_id_1.sql deleted file mode 100644 index 26bc39cec5..0000000000 --- a/tests/resources/functional/tsql/functions/test_grouping_id_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## GROUPING_ID --- --- GROUPING_ID is directly equivalent in Databricks SQL and TSQL. - --- tsql sql: -SELECT GROUPING_ID(col1, col2) FROM t1 GROUP BY CUBE(col1, col2); - --- databricks sql: -SELECT GROUPING_ID(col1, col2) FROM t1 GROUP BY CUBE(col1, col2); diff --git a/tests/resources/functional/tsql/functions/test_grouping_id_2.sql b/tests/resources/functional/tsql/functions/test_grouping_id_2.sql deleted file mode 100644 index dd14143e74..0000000000 --- a/tests/resources/functional/tsql/functions/test_grouping_id_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## GROUPING_ID --- --- GROUPING_ID is directly equivalent in Databricks SQL and TSQL. - --- tsql sql: -SELECT GROUPING_ID(col1, col2) As someAlias FROM t1 GROUP BY CUBE(col1, col2); - --- databricks sql: -SELECT GROUPING_ID(col1, col2) AS someAlias FROM t1 GROUP BY CUBE(col1, col2); diff --git a/tests/resources/functional/tsql/functions/test_isnull_1.sql b/tests/resources/functional/tsql/functions/test_isnull_1.sql deleted file mode 100644 index 0dbd457710..0000000000 --- a/tests/resources/functional/tsql/functions/test_isnull_1.sql +++ /dev/null @@ -1,13 +0,0 @@ --- ## ISNULL --- --- In TSQL ISNULL is a function that returns the first expression if it is not NULL, --- otherwise it returns the second expression. --- --- In Databricks ISNULL is a function that returns boolean true if the single argument is NULL, --- so it is replaced with IFNULL, which is the equivalent function in Databricks. --- --- tsql sql: -SELECT ISNULL(col1, 0) AS pcol1 FROM table; - --- databricks sql: -SELECT IFNULL(col1, 0) AS pcol1 FROM table; diff --git a/tests/resources/functional/tsql/functions/test_lag_1.sql b/tests/resources/functional/tsql/functions/test_lag_1.sql deleted file mode 100644 index de01e502b0..0000000000 --- a/tests/resources/functional/tsql/functions/test_lag_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LAG --- --- The LAG function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, LAG(col2, 1, 0) OVER (ORDER BY col2 DESC) AS lag_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LAG(col2, 1, 0) OVER (ORDER BY col2 DESC) AS lag_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_lag_2.sql b/tests/resources/functional/tsql/functions/test_lag_2.sql deleted file mode 100644 index 75d9612037..0000000000 --- a/tests/resources/functional/tsql/functions/test_lag_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LAG ignoring NULL values --- --- The LAG function is identical in TSql and Databricks when IGNORING or RESPECTING NULLS (default). - --- tsql sql: -SELECT col1, col2, LAG(col2, 1, 0) IGNORE NULLS OVER (ORDER BY col2 DESC) AS lag_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LAG(col2, 1, 0) IGNORE NULLS OVER (ORDER BY col2 DESC) AS lag_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_last_value_1.sql b/tests/resources/functional/tsql/functions/test_last_value_1.sql deleted file mode 100644 index ab4c8813bc..0000000000 --- a/tests/resources/functional/tsql/functions/test_last_value_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LAST_VALUE --- --- The LAST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, LAST_VALUE(col1) OVER (ORDER BY col2 DESC) AS last_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LAST_VALUE(col1) OVER (ORDER BY col2 DESC) AS last_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_last_value_2.sql b/tests/resources/functional/tsql/functions/test_last_value_2.sql deleted file mode 100644 index 8fc53695c0..0000000000 --- a/tests/resources/functional/tsql/functions/test_last_value_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LAST_VALUE --- --- The LAST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, LAST_VALUE(col1) OVER (ORDER BY col2 ASC) AS last_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LAST_VALUE(col1) OVER (ORDER BY col2 ASC) AS last_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_last_value_3.sql b/tests/resources/functional/tsql/functions/test_last_value_3.sql deleted file mode 100644 index cf08f47d31..0000000000 --- a/tests/resources/functional/tsql/functions/test_last_value_3.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LAST_VALUE over PARTITIONS --- --- The LAST_VALUE function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, col3, LAST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 DESC) AS last_value FROM tabl; - --- databricks sql: -SELECT col1, col2, col3, LAST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 DESC) AS last_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_last_value_4.sql b/tests/resources/functional/tsql/functions/test_last_value_4.sql deleted file mode 100644 index a9a31c7269..0000000000 --- a/tests/resources/functional/tsql/functions/test_last_value_4.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## LAST_VALUE over PARTITIONS --- --- The LAST_VALUE function is identical in TSql and Databricks. --- - --- tsql sql: -SELECT col1, col2, col3, LAST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 ASC ROWS UNBOUNDED PRECEDING) AS last_value FROM tabl; - --- databricks sql: -SELECT col1, col2, col3, LAST_VALUE(col1) OVER (PARTITION BY col2 ORDER BY col2 ASC ROWS UNBOUNDED PRECEDING) AS last_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_lead_1.sql b/tests/resources/functional/tsql/functions/test_lead_1.sql deleted file mode 100644 index 86efb0772f..0000000000 --- a/tests/resources/functional/tsql/functions/test_lead_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LEAD --- --- The LEAD function is identical in TSql and Databricks. - --- tsql sql: -SELECT col1, col2, LEAD(col2, 1, 0) OVER (ORDER BY col2 DESC) AS lead_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LEAD(col2, 1, 0) OVER (ORDER BY col2 DESC) AS lead_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_lead_2.sql b/tests/resources/functional/tsql/functions/test_lead_2.sql deleted file mode 100644 index a2737b3a82..0000000000 --- a/tests/resources/functional/tsql/functions/test_lead_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LEAD ignoring NULL values --- --- The LEAD function is identical in TSql and Databricks when IGNORING or RESPECTING NULLS (default). - --- tsql sql: -SELECT col1, col2, LEAD(col2, 1, 0) IGNORE NULLS OVER (ORDER BY col2 DESC) AS lead_value FROM tabl; - --- databricks sql: -SELECT col1, col2, LEAD(col2, 1, 0) IGNORE NULLS OVER (ORDER BY col2 DESC) AS lead_value FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_left_shift_1.sql b/tests/resources/functional/tsql/functions/test_left_shift_1.sql deleted file mode 100644 index 7a6fbb55bc..0000000000 --- a/tests/resources/functional/tsql/functions/test_left_shift_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## LEFT_SHIFT --- --- The LEFT_SHIFT is identical in TSql and Databricks other than naming style. --- --- tsql sql: -SELECT LEFT_SHIFT(42, 7); - --- databricks sql: -SELECT LEFTSHIFT(42, 7); diff --git a/tests/resources/functional/tsql/functions/test_max.2.sql b/tests/resources/functional/tsql/functions/test_max.2.sql deleted file mode 100644 index 5a73496f9b..0000000000 --- a/tests/resources/functional/tsql/functions/test_max.2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## MAX with DISTINCT --- --- The MAX function is identical in Databricks SQL and T-SQL. As DISTINCT is merely removing duplicates, --- its presence or otherwise is irrelevant to the MAX function. - --- tsql sql: -SELECT MAX(DISTINCT col1) FROM t1; - --- databricks sql: -SELECT MAX(DISTINCT col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_max_1.sql b/tests/resources/functional/tsql/functions/test_max_1.sql deleted file mode 100644 index d87f3a3ad0..0000000000 --- a/tests/resources/functional/tsql/functions/test_max_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## MAX --- --- The MAX function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT MAX(col1) FROM t1; - --- databricks sql: -SELECT MAX(col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_min.1.sql b/tests/resources/functional/tsql/functions/test_min.1.sql deleted file mode 100644 index 7e9f734f62..0000000000 --- a/tests/resources/functional/tsql/functions/test_min.1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## MIN --- --- The MIN function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT MIN(col1) FROM t1; - --- databricks sql: -SELECT MIN(col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_min.2.sql b/tests/resources/functional/tsql/functions/test_min.2.sql deleted file mode 100644 index 5a73496f9b..0000000000 --- a/tests/resources/functional/tsql/functions/test_min.2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## MAX with DISTINCT --- --- The MAX function is identical in Databricks SQL and T-SQL. As DISTINCT is merely removing duplicates, --- its presence or otherwise is irrelevant to the MAX function. - --- tsql sql: -SELECT MAX(DISTINCT col1) FROM t1; - --- databricks sql: -SELECT MAX(DISTINCT col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_nestlevel_1.sql b/tests/resources/functional/tsql/functions/test_nestlevel_1.sql deleted file mode 100644 index eb04d0536f..0000000000 --- a/tests/resources/functional/tsql/functions/test_nestlevel_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ##@@NESTLEVEL --- --- The @@NESTLEVEL function is unsupported in Databricks SQL --- --- tsql sql: -SELECT @@NESTLEVEL; - --- databricks sql: -SELECT @@NESTLEVEL; diff --git a/tests/resources/functional/tsql/functions/test_percent_rank_1.sql b/tests/resources/functional/tsql/functions/test_percent_rank_1.sql deleted file mode 100644 index 484f2900fa..0000000000 --- a/tests/resources/functional/tsql/functions/test_percent_rank_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## PERCENT_RANK --- --- The PERCENT_RANK is identical in TSql and Databricks. --- --- tsql sql: -SELECT PERCENT_RANK() OVER (ORDER BY col2 DESC) AS lead_value FROM tabl; - --- databricks sql: -SELECT PERCENTILE(col1, 0.5) AS percent50 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_percentile_cont_1.sql b/tests/resources/functional/tsql/functions/test_percentile_cont_1.sql deleted file mode 100644 index f82acb8752..0000000000 --- a/tests/resources/functional/tsql/functions/test_percentile_cont_1.sql +++ /dev/null @@ -1,12 +0,0 @@ --- ## PERCENTILE_CONT --- --- Note that TSQL uses a continuous distribution model and requires an ORDER BY clause. --- Databricks uses an approximate distribution algorithm, and does not require an ORDER BY clause. --- The results may differ slightly due to the difference, but as the result from both is an approximation, --- the difference is unlikely to be significant. - --- tsql sql: -SELECT PERCENTILE_CONT(col1) WITHIN GROUP (ORDER BY something) AS approx_percentile_col1 FROM tabl; - --- databricks sql: -SELECT PERCENTILE(col1) AS approx_percentile_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_percentile_disc_1.sql b/tests/resources/functional/tsql/functions/test_percentile_disc_1.sql deleted file mode 100644 index c36967aef1..0000000000 --- a/tests/resources/functional/tsql/functions/test_percentile_disc_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## PERCENTILE_DISC --- --- This function has no direct equivalent in Databricks. The closest equivalent is the PERCENTILE function. --- Approximations are generally faster then exact calculations, so performance may be something to explore. - --- tsql sql: -SELECT PERCENTILE_DISC(0.5) WITHIN GROUP(ORDER BY col1) AS percent50 FROM tabl; - --- databricks sql: -SELECT PERCENTILE(col1, 0.5) AS percent50 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_right_shift_1.sql b/tests/resources/functional/tsql/functions/test_right_shift_1.sql deleted file mode 100644 index 0fc1fcf0c5..0000000000 --- a/tests/resources/functional/tsql/functions/test_right_shift_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## RIGHT_SHIFT --- --- The RIGHT_SHIFT is identical in TSql and Databricks. --- --- tsql sql: -SELECT RIGHT_SHIFT(42, 7); - --- databricks sql: -SELECT RIGHTSHIFT(42, 7); diff --git a/tests/resources/functional/tsql/functions/test_set_bit_1.sql b/tests/resources/functional/tsql/functions/test_set_bit_1.sql deleted file mode 100644 index c832a05056..0000000000 --- a/tests/resources/functional/tsql/functions/test_set_bit_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## SET_BIT --- --- The SET_BIT function does not exist in Databricks SQL, so we must use bit functions --- --- tsql sql: -SELECT SET_BIT(42, 7); - --- databricks sql: -SELECT 42 | SHIFTLEFT(1, 7); diff --git a/tests/resources/functional/tsql/functions/test_set_bit_2.sql b/tests/resources/functional/tsql/functions/test_set_bit_2.sql deleted file mode 100644 index 8213e82fda..0000000000 --- a/tests/resources/functional/tsql/functions/test_set_bit_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## SET_BIT --- --- The SET_BIT function is identical in TSql and Databricks, save for a renaming of the function. --- --- tsql sql: -SELECT SET_BIT(42, 7, 0); - --- databricks sql: -SELECT 42 & -1 ^ SHIFTLEFT(1, 7) | SHIFTRIGHT(0, 7); diff --git a/tests/resources/functional/tsql/functions/test_stdev_1.sql b/tests/resources/functional/tsql/functions/test_stdev_1.sql deleted file mode 100644 index b1ac41e277..0000000000 --- a/tests/resources/functional/tsql/functions/test_stdev_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## STDEV --- --- The STDEV function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT STDEV(col1) FROM t1; - --- databricks sql: -SELECT STDEV(col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_stdev_2.sql b/tests/resources/functional/tsql/functions/test_stdev_2.sql deleted file mode 100644 index 392cf2aafd..0000000000 --- a/tests/resources/functional/tsql/functions/test_stdev_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## STDEV --- --- The STDEV function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT STDEV(DISTINCT col1) FROM t1; - --- databricks sql: -SELECT STDEV(DISTINCT col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_stdevp_1.sql b/tests/resources/functional/tsql/functions/test_stdevp_1.sql deleted file mode 100644 index 96801dcd26..0000000000 --- a/tests/resources/functional/tsql/functions/test_stdevp_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## STDEVP --- --- The STDEVP function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT STDEVP(col1) FROM t1; - --- databricks sql: -SELECT STDEVP(col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_stdevp_2.sql b/tests/resources/functional/tsql/functions/test_stdevp_2.sql deleted file mode 100644 index 01c41899b9..0000000000 --- a/tests/resources/functional/tsql/functions/test_stdevp_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## STDEVP --- --- The STDEVP function is identical in Databricks SQL and T-SQL. - --- tsql sql: -SELECT STDEVP(DISTINCT col1) FROM t1; - --- databricks sql: -SELECT STDEVP(DISTINCT col1) FROM t1; diff --git a/tests/resources/functional/tsql/functions/test_sum_1.sql b/tests/resources/functional/tsql/functions/test_sum_1.sql deleted file mode 100644 index 45be4e146a..0000000000 --- a/tests/resources/functional/tsql/functions/test_sum_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## SUM --- --- The SUM function is identical in TSQL and Databricks - --- tsql sql: -SELECT sum(col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT SUM(col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_sum_2.sql b/tests/resources/functional/tsql/functions/test_sum_2.sql deleted file mode 100644 index 3d7cb3f6e8..0000000000 --- a/tests/resources/functional/tsql/functions/test_sum_2.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## SUM with DISTINCT --- --- The SUM function is identical in TSQL and Databricks - --- tsql sql: -SELECT sum(DISTINCT col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT SUM(DISTINCT col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_var_1.sql b/tests/resources/functional/tsql/functions/test_var_1.sql deleted file mode 100644 index dfc9de2d64..0000000000 --- a/tests/resources/functional/tsql/functions/test_var_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## VAR --- --- The VAR function is identical in TSQL and Databricks - --- tsql sql: -SELECT VAR(col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT VAR(col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_var_2.sql b/tests/resources/functional/tsql/functions/test_var_2.sql deleted file mode 100644 index 16880501ca..0000000000 --- a/tests/resources/functional/tsql/functions/test_var_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## VAR with DISTINCT --- --- The VAR funciton is identical in TSQL and Databricks. Using DISTINCT with VAR --- will not change the results as variance is calculated on unique values already. - --- tsql sql: -SELECT VAR(DISTINCT col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT VAR(DISTINCT col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_varp_1.sql b/tests/resources/functional/tsql/functions/test_varp_1.sql deleted file mode 100644 index cbcc7ced32..0000000000 --- a/tests/resources/functional/tsql/functions/test_varp_1.sql +++ /dev/null @@ -1,9 +0,0 @@ --- ## VARP --- --- The VARP function is identical in TSQL and Databricks - --- tsql sql: -SELECT VARP(col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT VARP(col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/functions/test_varp_2.sql b/tests/resources/functional/tsql/functions/test_varp_2.sql deleted file mode 100644 index d8e278daa3..0000000000 --- a/tests/resources/functional/tsql/functions/test_varp_2.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## VARP with DISTINCT --- --- The VARP funciton is identical in TSQL and Databricks. Using DISTINCT with VARP --- will not change the results as variance is calculated on unique values already. - --- tsql sql: -SELECT VARP(DISTINCT col1) AS sum_col1 FROM tabl; - --- databricks sql: -SELECT VARP(DISTINCT col1) AS sum_col1 FROM tabl; diff --git a/tests/resources/functional/tsql/select/limit.sql b/tests/resources/functional/tsql/select/limit.sql deleted file mode 100644 index eb5ced9ffa..0000000000 --- a/tests/resources/functional/tsql/select/limit.sql +++ /dev/null @@ -1,47 +0,0 @@ --- --- ORDER BY can have an optional OFFSET clause and FETCH clause. --- Here we use some CTEs to try different variants that are allowed. --- --- - --- tsql sql: -WITH - q1 AS ( - SELECT * - FROM a_table - ORDER BY 1 - OFFSET 0 ROWS FETCH FIRST 10 ROWS ONLY - ), - q2 AS ( - SELECT * - from b_table - ORDER BY 1 DESC - OFFSET 1 ROW FETCH NEXT 1 ROW ONLY - ) - -SELECT * FROM q1 -UNION ALL -SELECT * FROM q2 - -ORDER BY 1; - --- databricks sql: -WITH - q1 AS ( - SELECT * - FROM a_table - ORDER BY 1 - LIMIT 10 OFFSET 0 - ), - q2 AS ( - SELECT * - from b_table - ORDER BY 1 DESC - LIMIT 1 OFFSET 1 - ) - -(SELECT * FROM q1) -UNION ALL -(SELECT * FROM q2) - -ORDER BY 1; diff --git a/tests/resources/functional/tsql/select/order_by.sql b/tests/resources/functional/tsql/select/order_by.sql deleted file mode 100644 index f99eff2008..0000000000 --- a/tests/resources/functional/tsql/select/order_by.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- Simply ORDER BY on the end of a SELECT. --- - --- tsql sql: -SELECT 1 AS n -ORDER BY n; - --- databricks sql: -SELECT 1 AS n -ORDER BY n; diff --git a/tests/resources/functional/tsql/select/order_by_asc.sql b/tests/resources/functional/tsql/select/order_by_asc.sql deleted file mode 100644 index 70234a81b4..0000000000 --- a/tests/resources/functional/tsql/select/order_by_asc.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- Explicit (redundant) ascending ORDER BY on the end of a SELECT. --- - --- tsql sql: -SELECT 1 AS n -ORDER BY n ASC; - --- databricks sql: -SELECT 1 AS n -ORDER BY n; diff --git a/tests/resources/functional/tsql/select/order_by_desc.sql b/tests/resources/functional/tsql/select/order_by_desc.sql deleted file mode 100644 index 8da1908c0a..0000000000 --- a/tests/resources/functional/tsql/select/order_by_desc.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- Descending ORDER BY on the end of a SELECT. --- - --- tsql sql: -SELECT 1 AS n -ORDER BY n DESC; - --- databricks sql: -SELECT 1 AS n -ORDER BY n DESC; diff --git a/tests/resources/functional/tsql/select/order_by_offset.sql b/tests/resources/functional/tsql/select/order_by_offset.sql deleted file mode 100644 index 4808ebbfc7..0000000000 --- a/tests/resources/functional/tsql/select/order_by_offset.sql +++ /dev/null @@ -1,15 +0,0 @@ --- --- ORDER BY can have an optional OFFSET clause. --- - --- tsql sql: -SELECT * -FROM a_table -ORDER BY 1 -OFFSET 1 ROW; - --- databricks sql: -SELECT * -FROM a_table -ORDER BY 1 -OFFSET 1; diff --git a/tests/resources/functional/tsql/select/order_by_precedence.sql b/tests/resources/functional/tsql/select/order_by_precedence.sql deleted file mode 100644 index 3d02922e8f..0000000000 --- a/tests/resources/functional/tsql/select/order_by_precedence.sql +++ /dev/null @@ -1,17 +0,0 @@ --- --- ORDER BY appears at the end of a sequence of set operations, and applies to the result of the set operation. --- - --- tsql sql: -SELECT 1 AS n -UNION -SELECT 2 - -ORDER BY n DESC; -- Applies to the complete UNION, not just the final expression. - --- databricks sql: -(SELECT 1 AS n) - UNION -(SELECT 2) - -ORDER BY n DESC; diff --git a/tests/resources/functional/tsql/select/test_cte_1.sql b/tests/resources/functional/tsql/select/test_cte_1.sql deleted file mode 100644 index 37df7bd4b3..0000000000 --- a/tests/resources/functional/tsql/select/test_cte_1.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## WITH cte SELECT --- --- The use of CTEs is generally the same in Databricks SQL as TSQL but there are some differences with --- nesting CTE support. --- --- tsql sql: -WITH cte AS (SELECT * FROM t) SELECT * FROM cte - --- databricks sql: -WITH cte AS (SELECT * FROM t) SELECT * FROM cte; diff --git a/tests/resources/functional/tsql/select/test_cte_2.sql b/tests/resources/functional/tsql/select/test_cte_2.sql deleted file mode 100644 index a4b0d7cfe3..0000000000 --- a/tests/resources/functional/tsql/select/test_cte_2.sql +++ /dev/null @@ -1,37 +0,0 @@ --- ## WITH cte SELECT --- --- The use of CTEs is generally the same in Databricks SQL as TSQL but there are some differences with --- nesting CTE support. --- --- tsql sql: - -WITH cteTable1 (col1, col2, col3count) - AS - ( - SELECT col1, fred, COUNT(OrderDate) AS counter - FROM Table1 - ), - cteTable2 (colx, coly, colxcount) - AS - ( - SELECT col1, fred, COUNT(OrderDate) AS counter - FROM Table2 - ) -SELECT col2, col1, col3count, cteTable2.colx, cteTable2.coly, cteTable2.colxcount -FROM cteTable1 - --- databricks sql: -WITH cteTable1 (col1, col2, col3count) - AS - ( - SELECT col1, fred, COUNT(OrderDate) AS counter - FROM Table1 - ), - cteTable2 (colx, coly, colxcount) - AS - ( - SELECT col1, fred, COUNT(OrderDate) AS counter - FROM Table2 - ) -SELECT col2, col1, col3count, cteTable2.colx, cteTable2.coly, cteTable2.colxcount -FROM cteTable1; diff --git a/tests/resources/functional/tsql/select/test_cte_xml.sql b/tests/resources/functional/tsql/select/test_cte_xml.sql deleted file mode 100644 index c453879824..0000000000 --- a/tests/resources/functional/tsql/select/test_cte_xml.sql +++ /dev/null @@ -1,15 +0,0 @@ --- ## WITH XMLWORKSPACES --- --- Databricks SQL does not currently support XML workspaces, so for now, we cover the syntax without recommending --- a translation. --- --- tsql sql: -WITH XMLNAMESPACES ('somereference' as namespace) -SELECT col1 as 'namespace:col1', - col2 as 'namespace:col2' -FROM Table1 -WHERE col2 = 'xyz' -FOR XML RAW ('namespace:namespace'), ELEMENTS; - --- databricks sql: -WITH XMLNAMESPACES ('somereference' as namespace) SELECT col1 as 'namespace:col1', col2 as 'namespace:col2' FROM Table1 WHERE col2 = 'xyz' FOR XML RAW ('namespace:namespace'), ELEMENTS; diff --git a/tests/resources/functional/tsql/set-operations/except.sql b/tests/resources/functional/tsql/set-operations/except.sql deleted file mode 100644 index 3874a778ab..0000000000 --- a/tests/resources/functional/tsql/set-operations/except.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... EXCEPT ... --- --- Verify simple EXCEPT handling. --- --- tsql sql: - -SELECT 1 -EXCEPT -SELECT 2; - --- databricks sql: -(SELECT 1) -EXCEPT -(SELECT 2); diff --git a/tests/resources/functional/tsql/set-operations/intersect.sql b/tests/resources/functional/tsql/set-operations/intersect.sql deleted file mode 100644 index bdbf30b2d3..0000000000 --- a/tests/resources/functional/tsql/set-operations/intersect.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... INTERSECT ... --- --- Verify simple INTERSECT handling. --- --- tsql sql: - -SELECT 1 -INTERSECT -SELECT 2; - --- databricks sql: -(SELECT 1) -INTERSECT -(SELECT 2); diff --git a/tests/resources/functional/tsql/set-operations/precedence.sql b/tests/resources/functional/tsql/set-operations/precedence.sql deleted file mode 100644 index 6b26f89b6b..0000000000 --- a/tests/resources/functional/tsql/set-operations/precedence.sql +++ /dev/null @@ -1,78 +0,0 @@ --- --- Verify the precedence rules are being correctly handled. Order of evaluation when chaining is: --- 1. Brackets. --- 2. INTERSECT --- 3. UNION and EXCEPT, evaluated left to right. --- - --- tsql sql: - --- Verifies UNION/EXCEPT as left-to-right, with brackets. -(SELECT 1 - UNION - SELECT 2 - EXCEPT - (SELECT 3 - UNION - SELECT 4)) - -UNION ALL - --- Verifies UNION/EXCEPT as left-to-right when the order is reversed. -(SELECT 5 - EXCEPT - SELECT 6 - UNION - SELECT 7) - -UNION ALL - --- Verifies that INTERSECT has precedence over UNION/EXCEPT. -(SELECT 8 - UNION - SELECT 9 - EXCEPT - SELECT 10 - INTERSECT - SELECT 11) - -UNION ALL - --- Verifies that INTERSECT is left-to-right, although brackets have precedence. -(SELECT 12 - INTERSECT - SELECT 13 - INTERSECT - (SELECT 14 - INTERSECT - SELECT 15)); - --- databricks sql: - - ( - ( - ( - ((SELECT 1) UNION (SELECT 2)) - EXCEPT - ((SELECT 3) UNION (SELECT 4)) - ) - UNION ALL - ( - ((SELECT 5) EXCEPT (SELECT 6)) - UNION - (SELECT 7) - ) - ) - UNION ALL - ( - ((SELECT 8) UNION (SELECT 9)) - EXCEPT - ((SELECT 10) INTERSECT (SELECT 11)) - ) - ) -UNION ALL - ( - ((SELECT 12) INTERSECT (SELECT 13)) - INTERSECT - ((SELECT 14) INTERSECT (SELECT 15)) - ); diff --git a/tests/resources/functional/tsql/set-operations/union-all.sql b/tests/resources/functional/tsql/set-operations/union-all.sql deleted file mode 100644 index 01b36a4940..0000000000 --- a/tests/resources/functional/tsql/set-operations/union-all.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... UNION ALL ... --- --- Verify simple UNION ALL handling. --- --- tsql sql: - -SELECT 1 -UNION ALL -SELECT 2; - --- databricks sql: -(SELECT 1) -UNION ALL -(SELECT 2); diff --git a/tests/resources/functional/tsql/set-operations/union.sql b/tests/resources/functional/tsql/set-operations/union.sql deleted file mode 100644 index 872747b1b8..0000000000 --- a/tests/resources/functional/tsql/set-operations/union.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ## ... UNION ... --- --- Verify simple UNION handling. --- --- tsql sql: - -SELECT 1 -UNION -SELECT 2; - --- databricks sql: -(SELECT 1) -UNION -(SELECT 2); diff --git a/tests/resources/functional/tsql/set-operations/union_all_left_grouped.sql b/tests/resources/functional/tsql/set-operations/union_all_left_grouped.sql deleted file mode 100644 index 89f8210f13..0000000000 --- a/tests/resources/functional/tsql/set-operations/union_all_left_grouped.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## (SELECT …) UNION ALL SELECT … --- --- Verify UNION handling when the LHS of the union is explicitly wrapped in parentheses. --- --- tsql sql: - -(SELECT a, b from c) UNION ALL SELECT x, y from z; - --- databricks sql: -(SELECT a, b FROM c) UNION ALL (SELECT x, y FROM z); diff --git a/tests/resources/functional/tsql/set-operations/union_left_grouped.sql b/tests/resources/functional/tsql/set-operations/union_left_grouped.sql deleted file mode 100644 index 5678dd9c20..0000000000 --- a/tests/resources/functional/tsql/set-operations/union_left_grouped.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ## (SELECT …) UNION SELECT … --- --- Verify UNION handling when the LHS of the union is explicitly wrapped in parentheses. --- --- tsql sql: - -(SELECT a, b from c) UNION SELECT x, y from z; - --- databricks sql: -(SELECT a, b FROM c) UNION (SELECT x, y FROM z); diff --git a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst new file mode 100644 index 0000000000..93ae45abfe --- /dev/null +++ b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst @@ -0,0 +1 @@ +TranspileError(code=UNSUPPORTED_LCA, kind=ANALYSIS, severity=ERROR, path='/Users/eric.vergnaud/development/remorph/tests/resources/lsp_transpiler/unsupported_lca.sql', message='LCA conversion not supported') diff --git a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst new file mode 100644 index 0000000000..93ae45abfe --- /dev/null +++ b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst @@ -0,0 +1 @@ +TranspileError(code=UNSUPPORTED_LCA, kind=ANALYSIS, severity=ERROR, path='/Users/eric.vergnaud/development/remorph/tests/resources/lsp_transpiler/unsupported_lca.sql', message='LCA conversion not supported') diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 0b4590bfcd..012fe82e06 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,33 +1,18 @@ import io -import re import shutil from pathlib import Path -from collections.abc import Sequence from unittest.mock import create_autospec import pytest import yaml -from sqlglot import ErrorLevel, UnsupportedError, Dialect, transpile -from sqlglot import parse_one as sqlglot_parse_one -from sqlglot.errors import SqlglotError, ParseError - from databricks.sdk import WorkspaceClient from databricks.sdk.errors import NotFound from databricks.labs.remorph.config import TranspileConfig from databricks.labs.remorph.helpers.file_utils import make_dir -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import SQLGLOT_DIALECTS -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks -from databricks.labs.remorph.transpiler.sqlglot.parsers.snowflake import Snowflake from databricks.sdk.core import Config -from .transpiler.helpers.functional_test_cases import ( - FunctionalTestFile, - FunctionalTestFileWithExpectedException, - expected_exceptions, -) - @pytest.fixture(scope="session") def mock_databricks_config(): @@ -48,169 +33,6 @@ def transpile_config(): ) -# TODO Add Standardized Sql Formatter to python functional tests. -def _normalize_string(value: str) -> str: - # Remove extra spaces and ensure consistent spacing around parentheses - value = re.sub(r'\s+', ' ', value) # Replace multiple spaces with a single space - value = re.sub(r'\s*\(\s*', ' ( ', value) # Ensure space around opening parenthesis - value = re.sub(r'\s*\)\s*', ' ) ', value) # Ensure space around closing parenthesis - value = value.strip() # Remove leading and trailing spaces - # Remove indentations, trailing spaces from each line, and convert to lowercase - lines = [line.rstrip() for line in value.splitlines()] - return " ".join(lines).lower().strip() - - -@pytest.fixture -def normalize_string(): - return _normalize_string - - -def get_dialect(input_dialect: str) -> Dialect: - value = SQLGLOT_DIALECTS.get(input_dialect) - if isinstance(value, Dialect): - return value - if isinstance(value, type(Dialect)): - return value() - raise ValueError(f"Can't instantiate dialect from {value}") - - -def parse_one(sql): - dialect = Databricks - return sqlglot_parse_one(sql, read=dialect) - - -def validate_source_transpile(databricks_sql, *, source=None, pretty=False, experimental=False): - """ - Validate that: - 1. Everything in `source` transpiles to `databricks_sql` - - Args: - databricks_sql (str): Main SQL expression - source (dict): Mapping of dialect -> SQL - pretty (bool): prettify the output - experimental (bool): experimental flag False by default - """ - - for source_dialect, source_sql in (source or {}).items(): - write_dialect = get_dialect("experimental") if experimental else get_dialect("databricks") - - actual_sql = "; ".join( - transpile( - source_sql, - read=get_dialect(source_dialect), - write=write_dialect, - pretty=pretty, - error_level=None, - ) - ) - orig_sql = actual_sql - actual_sql = _normalize_string(actual_sql.rstrip(';')) - expected_sql = _normalize_string(databricks_sql.rstrip(';')) - - error_msg = f"""-> *target_sql* `{expected_sql}` is not matching with\ - \n-> *transpiled_sql* `{actual_sql}`\ - \n-> for *source_dialect* `{source_dialect}\ - ORIG: -{orig_sql} - """ - - assert expected_sql == actual_sql, error_msg - - -def validate_target_transpile(input_sql, *, target=None, pretty=False): - """ - Validate that: - 1. `target_sql` transpiles to `input_sql` using `target` dialect - - Args: - input_sql (str): Main SQL expression - target (dict): Mapping of dialect -> SQL - pretty (bool): prettify the output - """ - expression = parse_one(input_sql) if input_sql else None - for target_dialect, target_sql in (target or {}).items(): - if target_sql is UnsupportedError: - with pytest.raises(UnsupportedError): - if expression: - expression.sql(target_dialect, unsupported_level=ErrorLevel.RAISE) - else: - actual_sql = _normalize_string( - transpile( - target_sql, read=Snowflake, write=get_dialect(target_dialect), pretty=pretty, error_level=None - )[0] - ) - - expected_sql = _normalize_string(input_sql) - - error_msg = f"""-> *target_sql* `{expected_sql}` is not matching with\ - \n-> *transpiled_sql* `{actual_sql}`\ - \n-> for *target_dialect* `{target_dialect}\ - """ - - assert expected_sql == actual_sql, error_msg - - -@pytest.fixture(scope="session") -def dialect_context(): - yield validate_source_transpile, validate_target_transpile - - -_ANTLR_CORE_FOLDER = 'core_engine' - - -def parse_sql_files(input_dir: Path, source: str, target: str, is_expected_exception): - suite: list[FunctionalTestFile | FunctionalTestFileWithExpectedException] = [] - for filenames in input_dir.rglob("*.sql"): - # Skip files in the core directory - if _ANTLR_CORE_FOLDER in filenames.parts: - continue - with open(filenames, 'r', encoding="utf-8") as file_content: - content = file_content.read() - source_pattern = rf'--\s*{source} sql:\n(.*?)(?=\n--\s*{target} sql:|$)' - target_pattern = rf'--\s*{target} sql:\n(.*)' - - # Extract source and target queries - - source_match = re.search(source_pattern, content, re.DOTALL) - target_match = re.search(target_pattern, content, re.DOTALL) - - source_sql = source_match.group(1).strip().rstrip(";") if source_match else "" - target_sql = target_match.group(1).strip() if target_match else "" - - # when multiple sqls are present below target - test_name = filenames.name.replace(".sql", "") - if is_expected_exception: - exception_type = expected_exceptions.get(test_name, SqlglotError) - exception = SqlglotError(test_name) - if exception_type in {ParseError, UnsupportedError}: - exception = exception_type(test_name) - suite.append( - FunctionalTestFileWithExpectedException( - target_sql, - source_sql, - test_name, - exception, - target, - ) - ) - else: - suite.append(FunctionalTestFile(target_sql, source_sql, test_name, target)) - return suite - - -def get_functional_test_files_from_directory( - input_dir: Path, source: str, target: str, is_expected_exception=False -) -> Sequence[FunctionalTestFileWithExpectedException]: - """Get all functional tests in the input_dir.""" - suite = parse_sql_files(input_dir, source, target, is_expected_exception) - return suite - - -@pytest.fixture -def expr(): - return parse_one("SELECT col1 FROM DUAL") - - def path_to_resource(*args: str) -> str: resource_path = Path(__file__).parent.parent / "resources" for arg in args: diff --git a/tests/unit/coverage/test_coverage_utils.py b/tests/unit/coverage/test_coverage_utils.py index d7b44fad99..1542b58450 100644 --- a/tests/unit/coverage/test_coverage_utils.py +++ b/tests/unit/coverage/test_coverage_utils.py @@ -7,6 +7,7 @@ import pytest import pytz +from sqlglot.dialects import Databricks, Snowflake from databricks.labs.remorph.coverage.commons import ( ReportEntry, @@ -17,8 +18,6 @@ get_supported_sql_files, write_json_line, ) -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks -from databricks.labs.remorph.transpiler.sqlglot.parsers.snowflake import Snowflake def test_get_supported_sql_files(tmp_path): diff --git a/tests/unit/intermediate/test_root_tables.py b/tests/unit/intermediate/test_root_tables.py index c8e1e28d73..142762b5d8 100644 --- a/tests/unit/intermediate/test_root_tables.py +++ b/tests/unit/intermediate/test_root_tables.py @@ -1,7 +1,6 @@ import pytest from databricks.labs.remorph.intermediate.root_tables import RootTableAnalyzer -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine @pytest.fixture(autouse=True) @@ -18,7 +17,7 @@ def setup_file(tmpdir): def test_generate_lineage(tmpdir): - root_table_analyzer = RootTableAnalyzer(SqlglotEngine(), "snowflake", tmpdir) + root_table_analyzer = RootTableAnalyzer("snowflake", tmpdir) dag = root_table_analyzer.generate_lineage_dag() roots = ["table2", "table3", "table4"] @@ -31,7 +30,7 @@ def test_generate_lineage(tmpdir): def test_generate_lineage_sql_file(setup_file): - root_table_analyzer = RootTableAnalyzer(SqlglotEngine(), "snowflake", setup_file) + root_table_analyzer = RootTableAnalyzer("snowflake", setup_file) dag = root_table_analyzer.generate_lineage_dag() roots = ["table2", "table3", "table4"] diff --git a/tests/unit/reconcile/connectors/test_databricks.py b/tests/unit/reconcile/connectors/test_databricks.py index a3566a2656..19e2c932a5 100644 --- a/tests/unit/reconcile/connectors/test_databricks.py +++ b/tests/unit/reconcile/connectors/test_databricks.py @@ -3,9 +3,9 @@ import pytest -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.databricks import DatabricksDataSource from databricks.labs.remorph.reconcile.exception import DataSourceRuntimeException +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.sdk import WorkspaceClient diff --git a/tests/unit/reconcile/connectors/test_oracle.py b/tests/unit/reconcile/connectors/test_oracle.py index 0ee7b0ddaa..65c4f3b3b6 100644 --- a/tests/unit/reconcile/connectors/test_oracle.py +++ b/tests/unit/reconcile/connectors/test_oracle.py @@ -4,10 +4,10 @@ import pytest -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.oracle import OracleDataSource from databricks.labs.remorph.reconcile.exception import DataSourceRuntimeException from databricks.labs.remorph.reconcile.recon_config import JdbcReaderOptions, Table +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.sdk import WorkspaceClient from databricks.sdk.service.workspace import GetSecretResponse diff --git a/tests/unit/reconcile/connectors/test_snowflake.py b/tests/unit/reconcile/connectors/test_snowflake.py index 3e4ba4d210..d2902347f1 100644 --- a/tests/unit/reconcile/connectors/test_snowflake.py +++ b/tests/unit/reconcile/connectors/test_snowflake.py @@ -5,10 +5,10 @@ import pytest from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives import serialization -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.snowflake import SnowflakeDataSource from databricks.labs.remorph.reconcile.exception import DataSourceRuntimeException, InvalidSnowflakePemPrivateKey from databricks.labs.remorph.reconcile.recon_config import JdbcReaderOptions, Table +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.sdk import WorkspaceClient from databricks.sdk.service.workspace import GetSecretResponse from databricks.sdk.errors import NotFound diff --git a/tests/unit/reconcile/connectors/test_sql_server.py b/tests/unit/reconcile/connectors/test_sql_server.py index de584f7139..a952623736 100644 --- a/tests/unit/reconcile/connectors/test_sql_server.py +++ b/tests/unit/reconcile/connectors/test_sql_server.py @@ -4,10 +4,10 @@ import pytest -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.sql_server import SQLServerDataSource from databricks.labs.remorph.reconcile.exception import DataSourceRuntimeException from databricks.labs.remorph.reconcile.recon_config import JdbcReaderOptions, Table +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.sdk import WorkspaceClient from databricks.sdk.service.workspace import GetSecretResponse diff --git a/tests/unit/reconcile/query_builder/test_count_query.py b/tests/unit/reconcile/query_builder/test_count_query.py index af1942a503..9cc037cd15 100644 --- a/tests/unit/reconcile/query_builder/test_count_query.py +++ b/tests/unit/reconcile/query_builder/test_count_query.py @@ -1,5 +1,5 @@ from databricks.labs.remorph.reconcile.query_builder.count_query import CountQueryBuilder -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect def test_count_query(table_conf_with_opts): diff --git a/tests/unit/reconcile/query_builder/test_expression_generator.py b/tests/unit/reconcile/query_builder/test_expression_generator.py index 0c700750cb..b45c438874 100644 --- a/tests/unit/reconcile/query_builder/test_expression_generator.py +++ b/tests/unit/reconcile/query_builder/test_expression_generator.py @@ -3,7 +3,7 @@ from sqlglot import parse_one from sqlglot.expressions import Column -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.labs.remorph.reconcile.query_builder.expression_generator import ( array_sort, array_to_string, diff --git a/tests/unit/reconcile/query_builder/test_hash_query.py b/tests/unit/reconcile/query_builder/test_hash_query.py index 69a6dbc073..e3fb96d1b4 100644 --- a/tests/unit/reconcile/query_builder/test_hash_query.py +++ b/tests/unit/reconcile/query_builder/test_hash_query.py @@ -1,6 +1,6 @@ -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.query_builder.hash_query import HashQueryBuilder from databricks.labs.remorph.reconcile.recon_config import Filters, ColumnMapping, Transformation +from databricks.labs.remorph.reconcile.utils import get_dialect def test_hash_query_builder_for_snowflake_src(table_conf_with_opts, table_schema): diff --git a/tests/unit/reconcile/query_builder/test_threshold_query.py b/tests/unit/reconcile/query_builder/test_threshold_query.py index 8e1d3f112a..2f548e9455 100644 --- a/tests/unit/reconcile/query_builder/test_threshold_query.py +++ b/tests/unit/reconcile/query_builder/test_threshold_query.py @@ -2,7 +2,6 @@ import pytest -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.exception import InvalidInputException from databricks.labs.remorph.reconcile.query_builder.threshold_query import ( ThresholdQueryBuilder, @@ -13,6 +12,7 @@ ColumnThresholds, Transformation, ) +from databricks.labs.remorph.reconcile.utils import get_dialect def test_threshold_comparison_query_with_one_threshold(table_conf_with_opts, table_schema): diff --git a/tests/unit/reconcile/test_source_adapter.py b/tests/unit/reconcile/test_source_adapter.py index d43ace5ef4..da4ca08f75 100644 --- a/tests/unit/reconcile/test_source_adapter.py +++ b/tests/unit/reconcile/test_source_adapter.py @@ -3,11 +3,11 @@ import pytest from databricks.connect import DatabricksSession -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect from databricks.labs.remorph.reconcile.connectors.databricks import DatabricksDataSource from databricks.labs.remorph.reconcile.connectors.oracle import OracleDataSource from databricks.labs.remorph.reconcile.connectors.snowflake import SnowflakeDataSource from databricks.labs.remorph.reconcile.connectors.source_adapter import create_adapter +from databricks.labs.remorph.reconcile.utils import get_dialect from databricks.sdk import WorkspaceClient diff --git a/tests/unit/transpiler/test_databricks.py b/tests/unit/transpiler/test_databricks.py deleted file mode 100644 index 7341344468..0000000000 --- a/tests/unit/transpiler/test_databricks.py +++ /dev/null @@ -1,15 +0,0 @@ -from pathlib import Path - -import pytest - -from ..conftest import FunctionalTestFile, get_functional_test_files_from_directory - -path = Path(__file__).parent / Path('../../resources/functional/snowflake/') -functional_tests = get_functional_test_files_from_directory(path, "snowflake", "databricks", False) -test_names = [f.test_name for f in functional_tests] - - -@pytest.mark.parametrize("sample", functional_tests, ids=test_names) -def test_databricks(dialect_context, sample: FunctionalTestFile): - validate_source_transpile, _ = dialect_context - validate_source_transpile(databricks_sql=sample.databricks_sql, source={"snowflake": sample.source}, pretty=True) diff --git a/tests/unit/transpiler/test_databricks_expected_exceptions.py b/tests/unit/transpiler/test_databricks_expected_exceptions.py deleted file mode 100644 index 4691979d66..0000000000 --- a/tests/unit/transpiler/test_databricks_expected_exceptions.py +++ /dev/null @@ -1,22 +0,0 @@ -# Logic for processing test cases with expected exceptions, can be removed if not needed. -from pathlib import Path - -import pytest - -from ..conftest import ( - FunctionalTestFileWithExpectedException, - get_functional_test_files_from_directory, -) - -path_expected_exceptions = Path(__file__).parent / Path('../../resources/functional/snowflake_expected_exceptions/') -functional_tests_expected_exceptions = get_functional_test_files_from_directory( - path_expected_exceptions, "snowflake", "databricks", True -) -test_names_expected_exceptions = [f.test_name for f in functional_tests_expected_exceptions] - - -@pytest.mark.parametrize("sample", functional_tests_expected_exceptions, ids=test_names_expected_exceptions) -def test_databricks_expected_exceptions(dialect_context, sample: FunctionalTestFileWithExpectedException): - validate_source_transpile, _ = dialect_context - with pytest.raises(type(sample.expected_exception)): - validate_source_transpile(databricks_sql=sample.databricks_sql, source={"snowflake": sample.source}) diff --git a/tests/unit/transpiler/test_execute.py b/tests/unit/transpiler/test_execute.py index cfdce0ef0a..d6feff9873 100644 --- a/tests/unit/transpiler/test_execute.py +++ b/tests/unit/transpiler/test_execute.py @@ -8,26 +8,18 @@ from databricks.connect import DatabricksSession from databricks.labs.lsql.backends import MockBackend -from databricks.labs.lsql.core import Row +from databricks.labs.remorph.transpiler.transpile_engine import TranspileEngine from databricks.sdk import WorkspaceClient from databricks.labs.remorph.config import TranspileConfig, ValidationResult from databricks.labs.remorph.helpers.file_utils import dir_walk, is_sql_file from databricks.labs.remorph.helpers.validation import Validator -from databricks.labs.remorph.transpiler.execute import ( - transpile as do_transpile, - transpile_column_exp, - transpile_sql, -) +from databricks.labs.remorph.transpiler.execute import transpile as do_transpile from databricks.sdk.core import Config -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine - -# pylint: disable=unspecified-encoding - - -def transpile(workspace_client: WorkspaceClient, engine: SqlglotEngine, config: TranspileConfig): +def transpile(workspace_client: WorkspaceClient, config: TranspileConfig): + engine = create_autospec(TranspileEngine) return asyncio.run(do_transpile(workspace_client, engine, config)) @@ -65,7 +57,7 @@ def check_status( def check_error_lines(error_file_path: str, expected_errors: list[dict[str, str]]): pattern = r"TranspileError\(code=(?P[^,]+), kind=(?P[^,]+), severity=(?P[^,]+), path='(?P[^']+)', message='(?P[^']+)('\))?" - with open(Path(error_file_path)) as file: + with open(Path(error_file_path), encoding="utf-8") as file: error_count = 0 match_count = 0 for line in file: @@ -111,7 +103,7 @@ def test_with_dir_with_output_folder_skipping_validation( skip_validation=True, ) with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # check the status check_status(status, 8, 7, 1, 2, 0, 0, error_file.name) # check errors @@ -153,7 +145,7 @@ def test_with_file(input_source, error_file, mock_workspace_client): ), patch("databricks.labs.remorph.transpiler.execute.Validator", return_value=mock_validate), ): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # check the status check_status(status, 1, 1, 0, 0, 1, 0, error_file.name) @@ -176,7 +168,7 @@ def test_with_file_with_output_folder_skip_validation(input_source, output_folde 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend(), ): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # check the status check_status(status, 1, 1, 0, 0, 0, 0, "None") @@ -196,7 +188,7 @@ def test_with_not_a_sql_file_skip_validation(input_source, mock_workspace_client 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend(), ): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # check the status check_status(status, 0, 0, 0, 0, 0, 0, "None") @@ -216,61 +208,7 @@ def test_with_not_existing_file_skip_validation(input_source, mock_workspace_cli 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend(), ): - transpile(mock_workspace_client, SqlglotEngine(), config) - - -def test_transpile_sql(mock_workspace_client): - config = TranspileConfig( - transpiler_config_path="sqlglot", - source_dialect="snowflake", - skip_validation=False, - catalog_name="catalog", - schema_name="schema", - ) - query = """select col from table;""" - - with patch( - 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', - return_value=MockBackend( - rows={ - "EXPLAIN SELECT": [Row(plan="== Physical Plan ==")], - } - ), - ): - transpiler_result, validation_result = transpile_sql(mock_workspace_client, config, query) - assert transpiler_result.transpiled_code == 'SELECT\n col\nFROM table' - assert validation_result.exception_msg is None - - -def test_transpile_column_exp(mock_workspace_client): - config = TranspileConfig( - transpiler_config_path="sqlglot", - source_dialect="snowflake", - skip_validation=True, - catalog_name="catalog", - schema_name="schema", - ) - query = ["case when col1 is null then 1 else 0 end", "col2 * 2", "current_timestamp()"] - - with patch( - 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', - return_value=MockBackend( - rows={ - "EXPLAIN SELECT": [Row(plan="== Physical Plan ==")], - } - ), - ): - result = transpile_column_exp(mock_workspace_client, config, query) - assert len(result) == 3 - assert result[0][0].transpiled_code == 'CASE WHEN col1 IS NULL THEN 1 ELSE 0 END' - assert result[1][0].transpiled_code == 'col2 * 2' - assert result[2][0].transpiled_code == 'CURRENT_TIMESTAMP()' - assert result[0][0].error_list == [] - assert result[1][0].error_list == [] - assert result[2][0].error_list == [] - assert result[0][1] is None - assert result[1][1] is None - assert result[2][1] is None + transpile(mock_workspace_client, config) def test_with_file_with_success(input_source, mock_workspace_client): @@ -295,7 +233,7 @@ def test_with_file_with_success(input_source, mock_workspace_client): ), patch("databricks.labs.remorph.transpiler.execute.Validator", return_value=mock_validate), ): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # assert the status check_status(status, 1, 1, 0, 0, 0, 0, "None") @@ -311,7 +249,7 @@ def test_with_input_source_none(mock_workspace_client): ) with pytest.raises(ValueError, match="Input SQL path is not provided"): - transpile(mock_workspace_client, SqlglotEngine(), config) + transpile(mock_workspace_client, config) def test_parse_error_handling(input_source, error_file, mock_workspace_client): @@ -326,7 +264,7 @@ def test_parse_error_handling(input_source, error_file, mock_workspace_client): ) with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # assert the status check_status(status, 1, 1, 0, 1, 0, 0, error_file.name) @@ -347,7 +285,7 @@ def test_token_error_handling(input_source, error_file, mock_workspace_client): ) with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, SqlglotEngine(), config) + status, _errors = transpile(mock_workspace_client, config) # assert the status check_status(status, 1, 1, 0, 1, 0, 0, error_file.name) # check errors diff --git a/tests/unit/transpiler/test_lca_utils.py b/tests/unit/transpiler/test_lca_utils.py deleted file mode 100644 index e8c7083ad3..0000000000 --- a/tests/unit/transpiler/test_lca_utils.py +++ /dev/null @@ -1,316 +0,0 @@ -from pathlib import Path -from unittest.mock import patch - -from sqlglot import parse_one - -from databricks.labs.remorph.transpiler.sqlglot.dialect_utils import get_dialect -from databricks.labs.remorph.transpiler.sqlglot.generator.databricks import Databricks -from databricks.labs.remorph.transpiler.sqlglot.lca_utils import check_for_unsupported_lca - - -def test_query_with_no_unsupported_lca_usage(): - dialect = get_dialect("snowflake") - sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca, - FROM table1 t - """ - filename = "test_file1.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert not error - - -def test_query_with_valid_alias_usage(): - dialect = get_dialect("snowflake") - sql = """ - WITH web_v1 as ( - select - ws_item_sk item_sk, d_date, - sum(sum(ws_sales_price)) - over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales - from web_sales - ,date_dim - where ws_sold_date_sk=d_date_sk - and d_month_seq between 1212 and 1212+11 - and ws_item_sk is not NULL - group by ws_item_sk, d_date), - store_v1 as ( - select - ss_item_sk item_sk, d_date, - sum(sum(ss_sales_price)) - over ( - partition by ss_item_sk order by d_date rows between unbounded preceding and current row - ) cume_sales - from store_sales - ,date_dim - where ss_sold_date_sk=d_date_sk - and d_month_seq between 1212 and 1212+11 - and ss_item_sk is not NULL - group by ss_item_sk, d_date) - select * - from (select item_sk - ,d_date - ,web_sales - ,store_sales - ,max(web_sales) - over ( - partition by item_sk order by d_date rows between unbounded preceding and current row - ) web_cumulative - ,max(store_sales) - over ( - partition by item_sk order by d_date rows between unbounded preceding and current row - ) store_cumulative - from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk - ,case when web.d_date is not null then web.d_date else store.d_date end d_date - ,web.cume_sales web_sales - ,store.cume_sales store_sales - from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk - and web.d_date = store.d_date) - )x )y - where web_cumulative > store_cumulative - order by item_sk - ,d_date - limit 100; - """ - filename = "test_file1.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert not error - - -def test_query_with_lca_in_where(): - dialect = get_dialect("snowflake") - sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca, - FROM table1 t - WHERE ca in ('v1', 'v2') - """ - filename = "test_file2.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert error - - -def test_query_with_lca_in_window(): - dialect = get_dialect("snowflake") - sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca, - ROW_NUMBER() OVER (PARTITION by ca ORDER BY t.col2 DESC) AS rn - FROM table1 t - """ - filename = "test_file3.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert error - - -def test_query_with_error(): - dialect = get_dialect("snowflake") - sql = """ - SELECT - t.col1 - t.col2, - t.col3 AS ca, - FROM table1 t - """ - filename = "test_file4.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert not error - - -def test_query_with_same_alias_and_column_name(): - dialect = get_dialect("snowflake") - sql = """ - select ca_zip - from ( - SELECT - substr(ca_zip,1,5) ca_zip, - trim(name) as name, - count(*) over( partition by ca_zip) - FROM customer_address - WHERE substr(ca_zip,1,5) IN ('89436', '30868')); - """ - filename = "test_file5.sql" - - error = check_for_unsupported_lca(dialect, sql, Path(filename)) - assert not error - - -def test_fix_lca_with_valid_lca_usage(normalize_string): - input_sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca - FROM table1 t - """ - expected_sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca - FROM table1 AS t - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_with_lca_in_where(normalize_string): - input_sql = """ - SELECT column_a as customer_id - FROM my_table - WHERE customer_id = '123' - """ - expected_sql = """ - SELECT column_a as customer_id - FROM my_table - WHERE column_a = '123' - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_with_lca_in_window(normalize_string): - input_sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca, - ROW_NUMBER() OVER (PARTITION by ca ORDER BY t.col2 DESC) AS rn - FROM table1 t - """ - expected_sql = """ - SELECT - t.col1, - t.col2, - t.col3 AS ca, - ROW_NUMBER() OVER (PARTITION by t.col3 ORDER BY t.col2 DESC) AS rn - FROM table1 AS t - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_with_lca_in_subquery(normalize_string): - input_sql = """ - SELECT column_a as cid - FROM my_table - WHERE cid in (select cid as customer_id from customer_table where customer_id = '123') - """ - expected_sql = """ - SELECT column_a as cid - FROM my_table - WHERE column_a in (select cid as customer_id from customer_table where cid = '123') - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_with_lca_in_derived_table(normalize_string): - input_sql = """ - SELECT column_a as cid - FROM (select column_x as column_a, column_y as y from my_table where y = '456') - WHERE cid = '123' - """ - expected_sql = """ - SELECT column_a as cid - FROM (select column_x as column_a, column_y as y from my_table where column_y = '456') - WHERE column_a = '123' - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_with_lca_in_subquery_and_derived_table(normalize_string): - input_sql = """ - SELECT column_a as cid - FROM (select column_x as column_a, column_y as y from my_table where y = '456') - WHERE cid in (select cid as customer_id from customer_table where customer_id = '123') - """ - expected_sql = """ - SELECT column_a as cid - FROM (select column_x as column_a, column_y as y from my_table where column_y = '456') - WHERE column_a in (select cid as customer_id from customer_table where cid = '123') - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_lca_in_cte(normalize_string): - input_sql = """ - WITH cte AS (SELECT column_a as customer_id - FROM my_table - WHERE customer_id = '123') - SELECT * FROM cte - """ - expected_sql = """ - WITH cte AS (SELECT column_a as customer_id - FROM my_table - WHERE column_a = '123') - SELECT * FROM cte - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_nested_lca(normalize_string): - input_sql = """ - SELECT - b * c as new_b, - a - new_b as ab_diff - FROM my_table - WHERE ab_diff >= 0 - """ - expected_sql = """ - SELECT - b * c as new_b, - a - new_b as ab_diff - FROM my_table - WHERE a - b * c >= 0 - """ - ast = parse_one(input_sql) - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) - - -def test_fix_nested_lca_with_no_scope(normalize_string): - # This test is to check if the code can handle the case where the scope is not available - # In this case we will not fix the invalid LCA and return the original query - input_sql = """ - SELECT - b * c as new_b, - a - new_b as ab_diff - FROM my_table - WHERE ab_diff >= 0 - """ - expected_sql = """ - SELECT - b * c as new_b, - a - new_b as ab_diff - FROM my_table - WHERE ab_diff >= 0 - """ - ast = parse_one(input_sql) - with patch( - 'databricks.labs.remorph.transpiler.sqlglot.lca_utils.build_scope', - return_value=None, - ): - generated_sql = ast.sql(Databricks, pretty=False) - assert normalize_string(generated_sql) == normalize_string(expected_sql) diff --git a/tests/unit/transpiler/test_lsp_config.py b/tests/unit/transpiler/test_lsp_config.py index 6263a18e5d..d1dc7e7632 100644 --- a/tests/unit/transpiler/test_lsp_config.py +++ b/tests/unit/transpiler/test_lsp_config.py @@ -6,7 +6,7 @@ import pytest import yaml -from databricks.labs.remorph.transpiler.lsp.lsp_engine import LSPEngine +from databricks.labs.remorph.transpiler.lsp_engine import LSPEngine from tests.unit.conftest import path_to_resource diff --git a/tests/unit/transpiler/test_lsp_engine.py b/tests/unit/transpiler/test_lsp_engine.py index c537c2c72a..a785607789 100644 --- a/tests/unit/transpiler/test_lsp_engine.py +++ b/tests/unit/transpiler/test_lsp_engine.py @@ -7,7 +7,7 @@ from lsprotocol.types import TextEdit, Range, Position from databricks.labs.remorph.errors.exceptions import IllegalStateException -from databricks.labs.remorph.transpiler.lsp.lsp_engine import ( +from databricks.labs.remorph.transpiler.lsp_engine import ( LSPEngine, ChangeManager, ) diff --git a/tests/unit/transpiler/test_oracle.py b/tests/unit/transpiler/test_oracle.py deleted file mode 100644 index acb196cf0a..0000000000 --- a/tests/unit/transpiler/test_oracle.py +++ /dev/null @@ -1,15 +0,0 @@ -from pathlib import Path - -import pytest - -from ..conftest import FunctionalTestFile, get_functional_test_files_from_directory - -path = Path(__file__).parent / Path('../../resources/functional/oracle/') -functional_tests = get_functional_test_files_from_directory(path, "oracle", "databricks", False) -test_names = [f.test_name for f in functional_tests] - - -@pytest.mark.parametrize("sample", functional_tests, ids=test_names) -def test_oracle(dialect_context, sample: FunctionalTestFile): - validate_source_transpile, _ = dialect_context - validate_source_transpile(databricks_sql=sample.databricks_sql, source={"oracle": sample.source}) diff --git a/tests/unit/transpiler/test_presto.py b/tests/unit/transpiler/test_presto.py deleted file mode 100644 index 7958c264b9..0000000000 --- a/tests/unit/transpiler/test_presto.py +++ /dev/null @@ -1,15 +0,0 @@ -from pathlib import Path - -import pytest - -from ..conftest import FunctionalTestFile, get_functional_test_files_from_directory - -path = Path(__file__).parent / Path('../../resources/functional/presto/') -functional_tests = get_functional_test_files_from_directory(path, "presto", "databricks", False) -test_names = [f.test_name for f in functional_tests] - - -@pytest.mark.parametrize("sample", functional_tests, ids=test_names) -def test_presto(dialect_context, sample: FunctionalTestFile): - validate_source_transpile, _ = dialect_context - validate_source_transpile(databricks_sql=sample.databricks_sql, source={"presto": sample.source}) diff --git a/tests/unit/transpiler/test_presto_expected_exceptions.py b/tests/unit/transpiler/test_presto_expected_exceptions.py deleted file mode 100644 index 85821ab847..0000000000 --- a/tests/unit/transpiler/test_presto_expected_exceptions.py +++ /dev/null @@ -1,22 +0,0 @@ -# Logic for processing test cases with expected exceptions, can be removed if not needed. -from pathlib import Path - -import pytest - -from ..conftest import ( - FunctionalTestFileWithExpectedException, - get_functional_test_files_from_directory, -) - -path_expected_exceptions = Path(__file__).parent / Path('../../resources/functional/presto_expected_exceptions/') -functional_tests_expected_exceptions = get_functional_test_files_from_directory( - path_expected_exceptions, "presto", "databricks", True -) -test_names_expected_exceptions = [f.test_name for f in functional_tests_expected_exceptions] - - -@pytest.mark.parametrize("sample", functional_tests_expected_exceptions, ids=test_names_expected_exceptions) -def test_presto_expected_exceptions(dialect_context, sample: FunctionalTestFileWithExpectedException): - validate_source_transpile, _ = dialect_context - with pytest.raises(type(sample.expected_exception)): - validate_source_transpile(databricks_sql=sample.databricks_sql, source={"presto": sample.source}) diff --git a/tests/unit/transpiler/test_snow.py b/tests/unit/transpiler/test_snow.py deleted file mode 100644 index 4c21185c75..0000000000 --- a/tests/unit/transpiler/test_snow.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -Test Cases to validate source Snowflake dialect -""" - - -def test_parse_parameter(dialect_context): - """ - Function to assert conversion from source: `snowflake(read)` to target: `Databricks(sql)` - """ - validate_source_transpile, _ = dialect_context - sql = """ - SELECT DISTINCT - ABC, - CAST('${SCHEMA_NM}_MV' AS STRING), - sys_dt, - ins_ts, - upd_ts - FROM ${SCHEMA_NM}_MV.${TBL_NM} - WHERE - xyz IS NOT NULL AND src_ent = '${SCHEMA_NM}_MV.COL' - """ - - validate_source_transpile( - databricks_sql=sql, - source={ - "snowflake": """ - SELECT DISTINCT - ABC, - CAST('${SCHEMA_NM}_MV' AS VARCHAR(261)), - sys_dt, - ins_ts, - upd_ts - FROM ${SCHEMA_NM}_MV.${TBL_NM} WHERE xyz IS NOT NULL AND - src_ent = '${SCHEMA_NM}_MV.COL'; - """, - }, - pretty=True, - ) - - -def test_decimal_keyword(dialect_context): - """ - Function to test dec as alias name - """ - validate_source_transpile, _ = dialect_context - - sql = """ - SELECT - dec.id, - dec.key, - xy.value - FROM table AS dec - JOIN table2 AS xy - ON dec.id = xy.id - """ - - validate_source_transpile( - databricks_sql=sql, - source={ - "snowflake": """ - SELECT - dec.id, - dec.key, - xy.value - FROM table dec - JOIN table2 xy - ON dec.id = xy.id - """, - }, - pretty=True, - ) diff --git a/tests/unit/transpiler/test_sqlglot_engine.py b/tests/unit/transpiler/test_sqlglot_engine.py deleted file mode 100644 index a95696ed04..0000000000 --- a/tests/unit/transpiler/test_sqlglot_engine.py +++ /dev/null @@ -1,149 +0,0 @@ -import asyncio -from pathlib import Path - -import pytest -from sqlglot import expressions - -from databricks.labs.remorph.transpiler.sqlglot import local_expression -from databricks.labs.remorph.transpiler.sqlglot.sqlglot_engine import SqlglotEngine -from tests.unit.conftest import get_dialect - - -@pytest.fixture -def transpiler(): - return SqlglotEngine() - - -def test_transpile_snowflake(transpiler, transpile_config): - transpiler_result = asyncio.run( - transpiler.transpile( - "snowflake", transpile_config.target_dialect, "SELECT CURRENT_TIMESTAMP(0)", Path("file.sql") - ) - ) - assert transpiler_result.transpiled_code == "SELECT\n CURRENT_TIMESTAMP()" - - -def test_transpile_exception(transpiler, transpile_config): - transpiler_result = asyncio.run( - transpiler.transpile( - "snowflake", - transpile_config.target_dialect, - "SELECT TRY_TO_NUMBER(COLUMN, $99.99, 27) FROM table", - Path("file.sql"), - ) - ) - assert transpiler_result.transpiled_code == "" - assert transpiler_result.error_list[0].path == Path("file.sql") - assert "Error Parsing args" in transpiler_result.error_list[0].message - - -def test_parse_query(transpiler, transpile_config): - parsed_query, _ = transpiler.parse( - transpile_config.source_dialect, "SELECT TRY_TO_NUMBER(COLUMN, $99.99, 27,2) FROM table", Path("file.sql") - ) - - expected_result = [ - local_expression.TryToNumber( - this=expressions.Column(this=expressions.Identifier(this="COLUMN", quoted=False)), - expression=expressions.Parameter( - this=expressions.Literal(this=99, is_string=False), - suffix=expressions.Literal(this=0.99, is_string=False), - ), - precision=expressions.Literal(this=27, is_string=False), - scale=expressions.Literal(this=2, is_string=False), - ) - ] - - expected_from_result = expressions.From( - this=expressions.Table(this=expressions.Identifier(this="table", quoted=False)) - ) - - for exp in parsed_query: - if exp: - assert repr(exp.args["expressions"]) == repr(expected_result) - assert repr(exp.args["from"]) == repr(expected_from_result) - - -def test_parse_invalid_query(transpiler): - result, error = transpiler.parse("snowflake", "invalid sql query", Path("file.sql")) - assert result is None - assert error.path == Path("file.sql") - assert "Invalid expression / Unexpected token." in error.message - - -def test_tokenizer_exception(transpiler, transpile_config): - transpiler_result = asyncio.run( - transpiler.transpile("snowflake", transpile_config.target_dialect, "1SELECT ~v\ud83d' ", Path("file.sql")) - ) - - assert transpiler_result.transpiled_code == "" - assert transpiler_result.error_list[0].path == Path("file.sql") - assert "Error tokenizing" in transpiler_result.error_list[0].message - - -def test_procedure_conversion(transpiler, transpile_config): - procedure_sql = "CREATE OR REPLACE PROCEDURE my_procedure() AS BEGIN SELECT * FROM my_table; END;" - transpiler_result = asyncio.run( - transpiler.transpile("databricks", transpile_config.target_dialect, procedure_sql, Path("file.sql")) - ) - assert ( - transpiler_result.transpiled_code - == "CREATE OR REPLACE PROCEDURE my_procedure() AS BEGIN\nSELECT\n *\nFROM my_table\nEND" - ) - - -def test_find_root_table(transpiler): - expression, _ = transpiler.parse("snowflake", "SELECT * FROM table_name", Path("test.sql")) - # pylint: disable=protected-access - assert transpiler._find_root_table(expression[0]) == "table_name" - - -def test_analyse_table_lineage(transpiler): - result = list(transpiler.analyse_table_lineage("databricks", "SELECT * FROM table_name", Path("test.sql"))) - assert result[0][0] == "table_name" - assert result[0][1] == "test.sql" - - -def test_safe_parse(transpiler, transpile_config): - result, error = transpiler.safe_parse( - get_dialect(transpile_config.source_dialect), "SELECT col1 from tab1;SELECT11 col1 from tab2", Path("file.sql") - ) - expected_result = [expressions.Column(this=expressions.Identifier(this="col1", quoted=False))] - expected_from_result = expressions.From( - this=expressions.Table(this=expressions.Identifier(this="tab1", quoted=False)) - ) - for exp in result: - if exp.parsed_expression: - print("yes") - assert repr(exp.parsed_expression.args["expressions"]) == repr(expected_result) - assert repr(exp.parsed_expression.args["from"]) == repr(expected_from_result) - assert error[0].transpile_error.code == "PARSE_ERROR" - - -def test_safe_parse_with_semicolon(transpiler, transpile_config): - result, error = transpiler.safe_parse( - get_dialect(transpile_config.source_dialect), - "SELECT split(col2,';') from tab1 where col1 like ';%'", - Path("file.sql"), - ) - expected_result = [ - expressions.Split( - this=expressions.Column(this=expressions.Identifier(this="col2", quoted=False)), - expression=expressions.Literal(this=";", is_string=True), - ) - ] - expected_from_result = expressions.From( - this=expressions.Table(this=expressions.Identifier(this="tab1", quoted=False)) - ) - expected_where_result = expressions.Where( - this=expressions.Like( - this=expressions.Column(this=expressions.Identifier(this="col1", quoted=False)), - expression=expressions.Literal(this=";%", is_string=True), - ) - ) - for exp in result: - if exp.parsed_expression: - assert repr(exp.parsed_expression.args["expressions"]) == repr(expected_result) - assert repr(exp.parsed_expression.args["from"]) == repr(expected_from_result) - assert repr(exp.parsed_expression.args["where"]) == repr(expected_where_result) - assert len(error) == 0 From fbb5426b3e94c8ee30d6cf219c3bd79dee921a51 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 09:01:32 +0100 Subject: [PATCH 02/12] hath is a pre-requisite --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index b229f16ac6..56b22c8df4 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ setup_python: dev: - pip install hatch hatch env create hatch run pip install --upgrade pip hatch run pip install -e '.[test]' From e8bb785cad7a94ddf46c41a25095c6cdfa793774 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 09:05:13 +0100 Subject: [PATCH 03/12] fix failing tests --- src/databricks/labs/remorph/intermediate/root_tables.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/databricks/labs/remorph/intermediate/root_tables.py b/src/databricks/labs/remorph/intermediate/root_tables.py index b6e35a44c6..2d1d453800 100644 --- a/src/databricks/labs/remorph/intermediate/root_tables.py +++ b/src/databricks/labs/remorph/intermediate/root_tables.py @@ -44,9 +44,9 @@ def _populate_dag(self, sql_content: str, path: Path, dag: DAG): dag.add_edge(root_table, child) def _analyse_table_lineage(self, source_code: str, file_path: Path) -> Iterable[tuple[str, str]]: - parsed_expression, _ = parse(source_code, read=self.source_dialect, error_level=ErrorLevel.IMMEDIATE) - if parsed_expression is not None: - for expr in parsed_expression: + parsed = parse(source_code, read=self.source_dialect, error_level=ErrorLevel.IMMEDIATE) + if parsed is not None: + for expr in parsed: child: str = str(file_path) if expr is not None: # TODO: fix possible issue where the file reference is lost (if we have a 'create') From 9ca2e8952a81399107629e5e85d1afff9b24027c Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 09:13:36 +0100 Subject: [PATCH 04/12] fix failing tests --- .../unit/reconcile/query_builder/test_expression_generator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/reconcile/query_builder/test_expression_generator.py b/tests/unit/reconcile/query_builder/test_expression_generator.py index b45c438874..4c385af125 100644 --- a/tests/unit/reconcile/query_builder/test_expression_generator.py +++ b/tests/unit/reconcile/query_builder/test_expression_generator.py @@ -26,6 +26,9 @@ trim, ) +@pytest.fixture +def expr(): + yield parse_one("SELECT col1 FROM DUAL", read="databricks") def test_coalesce(expr): assert coalesce(expr, "NA", True).sql() == "SELECT COALESCE(col1, 'NA') FROM DUAL" From c84afe752e8161c999e03e1e93ed71bd71873861 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 09:23:14 +0100 Subject: [PATCH 05/12] fix failing tests --- src/databricks/labs/remorph/reconcile/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/databricks/labs/remorph/reconcile/utils.py b/src/databricks/labs/remorph/reconcile/utils.py index 88bbdc86df..abc7568621 100644 --- a/src/databricks/labs/remorph/reconcile/utils.py +++ b/src/databricks/labs/remorph/reconcile/utils.py @@ -12,5 +12,7 @@ def get_dialect(name: str) -> Dialect: def get_dialect_name(dialect: Dialect) -> str: - name = type(dialect).__name__ - return name if name in Dialects else "universal" + try: + return Dialects(dialect).value + except ValueError: + return "universal" From 1b848b01be6fd40a0226808df92cfca1a709bd8a Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 17:01:37 +0100 Subject: [PATCH 06/12] fix failing tests --- tests/unit/transpiler/test_lsp_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/transpiler/test_lsp_config.py b/tests/unit/transpiler/test_lsp_config.py index d1dc7e7632..a2948d6309 100644 --- a/tests/unit/transpiler/test_lsp_config.py +++ b/tests/unit/transpiler/test_lsp_config.py @@ -55,6 +55,7 @@ def test_invalid_config_raises_error(key, value, message): config["remorph"][key] = value with ( patch("pathlib.PosixPath.read_text", return_value=yaml.dump(config)), + patch("pathlib.PosixPath.exists", return_value=True), pytest.raises(ValueError, match=message), ): _ = LSPEngine.from_config_path(Path("stuff")) From 4f63eb736e14464c42848c8b5c7702073c53c8df Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 17:23:32 +0100 Subject: [PATCH 07/12] fix failing tests --- src/databricks/labs/remorph/cli.py | 3 +++ src/databricks/labs/remorph/reconcile/utils.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/databricks/labs/remorph/cli.py b/src/databricks/labs/remorph/cli.py index d6771d9640..ab02ead488 100644 --- a/src/databricks/labs/remorph/cli.py +++ b/src/databricks/labs/remorph/cli.py @@ -12,6 +12,7 @@ from databricks.labs.remorph.install import WorkspaceInstaller from databricks.labs.remorph.reconcile.runner import ReconcileRunner from databricks.labs.remorph.lineage import lineage_generator +from databricks.labs.remorph.reconcile.utils import get_dialect, dialect_exists from databricks.labs.remorph.transpiler.execute import transpile as do_transpile from databricks.labs.remorph.reconcile.execute import RECONCILE_OPERATION_NAME, AGG_RECONCILE_OPERATION_NAME from databricks.labs.remorph.jvmproxy import proxy_command @@ -171,6 +172,8 @@ def generate_lineage(w: WorkspaceClient, source_dialect: str, input_source: str, """[Experimental] Generates a lineage of source SQL files or folder""" ctx = ApplicationContext(w) logger.debug(f"User: {ctx.current_user}") + if not source_dialect or not dialect_exists(source_dialect): + raise_validation_exception(f"Invalid value for '--source-dialect': {source_dialect}.") if not input_source or not os.path.exists(input_source): raise_validation_exception(f"Invalid value for '--input-source': Path '{input_source}' does not exist.") if not os.path.exists(output_folder) or output_folder in {None, ""}: diff --git a/src/databricks/labs/remorph/reconcile/utils.py b/src/databricks/labs/remorph/reconcile/utils.py index abc7568621..6a2e0b1057 100644 --- a/src/databricks/labs/remorph/reconcile/utils.py +++ b/src/databricks/labs/remorph/reconcile/utils.py @@ -11,6 +11,10 @@ def get_dialect(name: str) -> Dialect: raise ValueError(f"Can't instantiate dialect from {name}") +def dialect_exists(name: str) -> bool: + values = {member.value for member in Dialects} + return name in values + def get_dialect_name(dialect: Dialect) -> str: try: return Dialects(dialect).value From eac19c78d11fdd1d39c18aa6837fb16c50b374ef Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 17:30:04 +0100 Subject: [PATCH 08/12] drop obsolete tests --- tests/unit/transpiler/test_execute.py | 162 +------------------------- 1 file changed, 4 insertions(+), 158 deletions(-) diff --git a/tests/unit/transpiler/test_execute.py b/tests/unit/transpiler/test_execute.py index d6feff9873..dbe2b283ce 100644 --- a/tests/unit/transpiler/test_execute.py +++ b/tests/unit/transpiler/test_execute.py @@ -6,16 +6,13 @@ import pytest -from databricks.connect import DatabricksSession from databricks.labs.lsql.backends import MockBackend from databricks.labs.remorph.transpiler.transpile_engine import TranspileEngine from databricks.sdk import WorkspaceClient -from databricks.labs.remorph.config import TranspileConfig, ValidationResult +from databricks.labs.remorph.config import TranspileConfig from databricks.labs.remorph.helpers.file_utils import dir_walk, is_sql_file -from databricks.labs.remorph.helpers.validation import Validator from databricks.labs.remorph.transpiler.execute import transpile as do_transpile -from databricks.sdk.core import Config def transpile(workspace_client: WorkspaceClient, config: TranspileConfig): @@ -90,91 +87,7 @@ def check_generated(input_source: Path, output_folder: Path): assert transpiled.exists(), f"Could not find transpiled file {transpiled!s} for {input_file!s}" -def test_with_dir_with_output_folder_skipping_validation( - input_source, output_folder, error_file, mock_workspace_client -): - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source), - output_folder=str(output_folder), - error_file_path=str(error_file), - sdk_config=None, - source_dialect="snowflake", - skip_validation=True, - ) - with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, config) - # check the status - check_status(status, 8, 7, 1, 2, 0, 0, error_file.name) - # check errors - expected_errors = [ - { - "path": f"{input_source!s}/query3.sql", - "message": f"Unsupported operation found in file {input_source!s}/query3.sql.", - }, - {"path": f"{input_source!s}/query4.sql", "message": "Parsing error Start:"}, - {"path": f"{input_source!s}/query5.sql", "message": "Token error Start:"}, - ] - check_error_lines(status["error_log_file"], expected_errors) - # check generation - check_generated(input_source, output_folder) - - -def test_with_file(input_source, error_file, mock_workspace_client): - sdk_config = create_autospec(Config) - spark = create_autospec(DatabricksSession) - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source / "query1.sql"), - output_folder=None, - error_file_path=str(error_file), - sdk_config=sdk_config, - source_dialect="snowflake", - skip_validation=False, - ) - mock_validate = create_autospec(Validator) - mock_validate.spark = spark - mock_validate.validate_format_result.return_value = ValidationResult( - """ Mock validated query """, "Mock validation error" - ) - - with ( - patch( - 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', - return_value=MockBackend(), - ), - patch("databricks.labs.remorph.transpiler.execute.Validator", return_value=mock_validate), - ): - status, _errors = transpile(mock_workspace_client, config) - - # check the status - check_status(status, 1, 1, 0, 0, 1, 0, error_file.name) - # check errors - expected_errors = [{"path": f"{input_source!s}/query1.sql", "message": "Mock validation error"}] - check_error_lines(status["error_log_file"], expected_errors) - - -def test_with_file_with_output_folder_skip_validation(input_source, output_folder, mock_workspace_client): - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source / "query1.sql"), - output_folder=str(output_folder), - sdk_config=None, - source_dialect="snowflake", - skip_validation=True, - ) - - with patch( - 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', - return_value=MockBackend(), - ): - status, _errors = transpile(mock_workspace_client, config) - - # check the status - check_status(status, 1, 1, 0, 0, 0, 0, "None") - - -def test_with_not_a_sql_file_skip_validation(input_source, mock_workspace_client): +def test_with_not_a_sql_file(input_source, mock_workspace_client): config = TranspileConfig( transpiler_config_path="sqlglot", input_source=str(input_source / "file.txt"), @@ -194,7 +107,7 @@ def test_with_not_a_sql_file_skip_validation(input_source, mock_workspace_client check_status(status, 0, 0, 0, 0, 0, 0, "None") -def test_with_not_existing_file_skip_validation(input_source, mock_workspace_client): +def test_with_not_existing_file(input_source, mock_workspace_client): config = TranspileConfig( transpiler_config_path="sqlglot", input_source=str(input_source / "file_not_exist.txt"), @@ -211,34 +124,7 @@ def test_with_not_existing_file_skip_validation(input_source, mock_workspace_cli transpile(mock_workspace_client, config) -def test_with_file_with_success(input_source, mock_workspace_client): - sdk_config = create_autospec(Config) - spark = create_autospec(DatabricksSession) - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source / "query1.sql"), - output_folder=None, - sdk_config=sdk_config, - source_dialect="snowflake", - skip_validation=False, - ) - mock_validate = create_autospec(Validator) - mock_validate.spark = spark - mock_validate.validate_format_result.return_value = ValidationResult(""" Mock validated query """, None) - - with ( - patch( - 'databricks.labs.remorph.helpers.db_sql.get_sql_backend', - return_value=MockBackend(), - ), - patch("databricks.labs.remorph.transpiler.execute.Validator", return_value=mock_validate), - ): - status, _errors = transpile(mock_workspace_client, config) - # assert the status - check_status(status, 1, 1, 0, 0, 0, 0, "None") - - -def test_with_input_source_none(mock_workspace_client): +def test_with_no_input_source(mock_workspace_client): config = TranspileConfig( transpiler_config_path="sqlglot", input_source=None, @@ -251,43 +137,3 @@ def test_with_input_source_none(mock_workspace_client): with pytest.raises(ValueError, match="Input SQL path is not provided"): transpile(mock_workspace_client, config) - -def test_parse_error_handling(input_source, error_file, mock_workspace_client): - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source / "query4.sql"), - output_folder=None, - error_file_path=str(error_file), - sdk_config=None, - source_dialect="snowflake", - skip_validation=True, - ) - - with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, config) - - # assert the status - check_status(status, 1, 1, 0, 1, 0, 0, error_file.name) - # check errors - expected_errors = [{"path": f"{input_source}/query4.sql", "message": "Parsing error Start:"}] - check_error_lines(status["error_log_file"], expected_errors) - - -def test_token_error_handling(input_source, error_file, mock_workspace_client): - config = TranspileConfig( - transpiler_config_path="sqlglot", - input_source=str(input_source / "query5.sql"), - output_folder=None, - error_file_path=str(error_file), - sdk_config=None, - source_dialect="snowflake", - skip_validation=True, - ) - - with patch('databricks.labs.remorph.helpers.db_sql.get_sql_backend', return_value=MockBackend()): - status, _errors = transpile(mock_workspace_client, config) - # assert the status - check_status(status, 1, 1, 0, 1, 0, 0, error_file.name) - # check errors - expected_errors = [{"path": f"{input_source}/query5.sql", "message": "Token error Start:"}] - check_error_lines(status["error_log_file"], expected_errors) From 51584e1f6a9381b35d7a2361a0f667e2f62a9ccc Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 17:33:53 +0100 Subject: [PATCH 09/12] fix failing tests --- .../unit/reconcile/query_builder/test_threshold_query.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/reconcile/query_builder/test_threshold_query.py b/tests/unit/reconcile/query_builder/test_threshold_query.py index 2f548e9455..eaa54e040a 100644 --- a/tests/unit/reconcile/query_builder/test_threshold_query.py +++ b/tests/unit/reconcile/query_builder/test_threshold_query.py @@ -32,8 +32,8 @@ def test_threshold_comparison_query_with_one_threshold(table_conf_with_opts, tab 0)) = 0 then 'match' when (coalesce(source.s_acctbal, 0) - coalesce(databricks.s_acctbal, 0)) between 0 and 100 then 'warning' else 'failed' end as s_acctbal_match, source.s_nationkey as s_nationkey_source, source.s_suppkey as s_suppkey_source from source_supplier_df_threshold_vw as source inner join - target_target_supplier_df_threshold_vw as databricks on source.s_nationkey <=> databricks.s_nationkey and - source.s_suppkey <=> databricks.s_suppkey where (1 = 1 or 1 = 1) or + target_target_supplier_df_threshold_vw as databricks on source.s_nationkey is not distinct from databricks.s_nationkey and + source.s_suppkey is not distinct from databricks.s_suppkey where (1 = 1 or 1 = 1) or (coalesce(source.s_acctbal, 0) - coalesce(databricks.s_acctbal, 0)) <> 0""".strip().lower(), ) @@ -68,8 +68,8 @@ def test_threshold_comparison_query_with_dual_threshold(table_conf_with_opts, ta coalesce(unix_timestamp(databricks.s_suppdate), 0)) between -86400 and 86400 then 'warning' else 'failed' end as s_suppdate_match, source.s_suppdate as s_suppdate_source, source.s_suppkey as s_suppkey_source from source_supplier_df_threshold_vw as - source inner join target_target_supplier_df_threshold_vw as databricks on source.s_suppdate <=> databricks.s_suppdate and - source.s_suppkey <=> databricks.s_suppkey where (1 = 1 or 1 = 1) or (coalesce(source.s_acctbal, 0) - + source inner join target_target_supplier_df_threshold_vw as databricks on source.s_suppdate is not distinct from databricks.s_suppdate and + source.s_suppkey is not distinct from databricks.s_suppkey where (1 = 1 or 1 = 1) or (coalesce(source.s_acctbal, 0) - coalesce(databricks.s_acctbal, 0)) <> 0 or (coalesce(unix_timestamp(source.s_suppdate), 0) - coalesce(unix_timestamp(databricks.s_suppdate), 0)) <> 0""".strip().lower(), ) From 23082d126165d4206fbdd6539ee6faf861222b71 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 18:05:10 +0100 Subject: [PATCH 10/12] for tests, store error file in tmp dir --- ...pile_errors_2025_02_18_08_59_22_117905.lst | 1 - ...pile_errors_2025_02_18_09_00_07_485225.lst | 1 - tests/unit/conftest.py | 23 +++++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst delete mode 100644 tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst diff --git a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst deleted file mode 100644 index 93ae45abfe..0000000000 --- a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_08_59_22_117905.lst +++ /dev/null @@ -1 +0,0 @@ -TranspileError(code=UNSUPPORTED_LCA, kind=ANALYSIS, severity=ERROR, path='/Users/eric.vergnaud/development/remorph/tests/resources/lsp_transpiler/unsupported_lca.sql', message='LCA conversion not supported') diff --git a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst b/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst deleted file mode 100644 index 93ae45abfe..0000000000 --- a/tests/resources/lsp_transpiler/transpile_errors_2025_02_18_09_00_07_485225.lst +++ /dev/null @@ -1 +0,0 @@ -TranspileError(code=UNSUPPORTED_LCA, kind=ANALYSIS, severity=ERROR, path='/Users/eric.vergnaud/development/remorph/tests/resources/lsp_transpiler/unsupported_lca.sql', message='LCA conversion not supported') diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 012fe82e06..7f1449de4d 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,6 +1,7 @@ import io import shutil from pathlib import Path +from tempfile import TemporaryDirectory from unittest.mock import create_autospec import pytest @@ -21,16 +22,18 @@ def mock_databricks_config(): @pytest.fixture() def transpile_config(): - yield TranspileConfig( - transpiler_config_path="sqlglot", - source_dialect="snowflake", - input_source="input_sql", - output_folder="output_folder", - sdk_config={"cluster_id": "test_cluster"}, - skip_validation=False, - catalog_name="catalog", - schema_name="schema", - ) + with TemporaryDirectory() as tmpdirname: + yield TranspileConfig( + transpiler_config_path="sqlglot", + source_dialect="snowflake", + input_source="input_sql", + output_folder="output_folder", + error_file_path=tmpdirname+"/errors.lst", + sdk_config={"cluster_id": "test_cluster"}, + skip_validation=False, + catalog_name="catalog", + schema_name="schema", + ) def path_to_resource(*args: str) -> str: From f7b9774eda14d7e8d7274ee500e0ab030435bf77 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 18:05:22 +0100 Subject: [PATCH 11/12] fix failing tests --- tests/unit/test_cli_transpile.py | 49 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/tests/unit/test_cli_transpile.py b/tests/unit/test_cli_transpile.py index 716df276b2..d482868d79 100644 --- a/tests/unit/test_cli_transpile.py +++ b/tests/unit/test_cli_transpile.py @@ -6,6 +6,7 @@ from databricks.labs.remorph import cli from databricks.labs.remorph.config import TranspileConfig +from databricks.labs.remorph.transpiler.lsp_engine import LSPEngine from databricks.sdk import WorkspaceClient from databricks.labs.remorph.transpiler.transpile_engine import TranspileEngine @@ -46,9 +47,11 @@ def patched_do_transpile(*args, **kwargs): def test_transpile_with_no_sdk_config(): workspace_client = create_autospec(WorkspaceClient) mock_transpile, patched_do_transpile = patch_do_transpile() + mock_engine = create_autospec(LSPEngine) with ( patch("databricks.labs.remorph.cli.ApplicationContext", autospec=True) as mock_app_context, patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), patch("os.path.exists", return_value=True), ): default_config = TranspileConfig( @@ -95,9 +98,11 @@ def test_transpile_with_no_sdk_config(): def test_transpile_with_warehouse_id_in_sdk_config(): workspace_client = create_autospec(WorkspaceClient) mock_transpile, patched_do_transpile = patch_do_transpile() + mock_engine = create_autospec(LSPEngine) with ( patch("databricks.labs.remorph.cli.ApplicationContext", autospec=True) as mock_app_context, patch("os.path.exists", return_value=True), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), ): sdk_config = {"warehouse_id": "w_id"} @@ -145,9 +150,11 @@ def test_transpile_with_warehouse_id_in_sdk_config(): def test_transpile_with_cluster_id_in_sdk_config(): workspace_client = create_autospec(WorkspaceClient) mock_transpile, patched_do_transpile = patch_do_transpile() + mock_engine = create_autospec(LSPEngine) with ( patch("databricks.labs.remorph.cli.ApplicationContext", autospec=True) as mock_app_context, patch("os.path.exists", return_value=True), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), ): sdk_config = {"cluster_id": "c_id"} @@ -207,34 +214,18 @@ def test_transpile_with_invalid_transpiler(mock_workspace_client_cli): ) -def test_transpile_with_invalid_sqlglot_dialect(mock_workspace_client_cli): - with pytest.raises(Exception, match="Invalid value for '--source-dialect'"): - cli.transpile( - mock_workspace_client_cli, - "sqlglot", - "invalid_dialect", - "/path/to/sql/file.sql", - "/path/to/output", - "/path/to/errors.log", - "true", - "my_catalog", - "my_schema", - ) - - -def test_transpile_with_invalid_transpiler_dialect(mock_workspace_client_cli): - engine = create_autospec(TranspileEngine) - type(engine).supported_dialects = PropertyMock(return_value=["oracle"]) - engine.check_source_dialect = lambda dialect: TranspileEngine.check_source_dialect(engine, dialect) +def test_transpile_with_invalid_dialect(mock_workspace_client_cli): + mock_engine = create_autospec(LSPEngine) + mock_engine.check_source_dialect.side_effect = lambda source_dialect: TranspileEngine.check_source_dialect(mock_engine, source_dialect) with ( patch("os.path.exists", return_value=True), - patch("databricks.labs.remorph.transpiler.transpile_engine.TranspileEngine.load_engine", return_value=engine), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), pytest.raises(Exception, match="Invalid value for '--source-dialect'"), ): cli.transpile( mock_workspace_client_cli, "some_transpiler", - "snowflake", + "invalid_dialect", "/path/to/sql/file.sql", "/path/to/output", "/path/to/errors.log", @@ -245,8 +236,10 @@ def test_transpile_with_invalid_transpiler_dialect(mock_workspace_client_cli): def test_transpile_with_invalid_skip_validation(mock_workspace_client_cli): + mock_engine = create_autospec(LSPEngine) with ( patch("os.path.exists", return_value=True), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), pytest.raises(Exception, match="Invalid value for '--skip-validation'"), ): cli.transpile( @@ -263,8 +256,10 @@ def test_transpile_with_invalid_skip_validation(mock_workspace_client_cli): def test_transpile_with_invalid_input_source(mock_workspace_client_cli): + mock_engine = create_autospec(LSPEngine) with ( patch("os.path.exists", return_value=False), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), pytest.raises(Exception, match="Invalid value for '--input-source'"), ): cli.transpile( @@ -292,8 +287,10 @@ def test_transpile_with_valid_input(mock_workspace_client_cli): sdk_config = {'cluster_id': 'test_cluster'} mock_transpile, patched_do_transpile = patch_do_transpile() + mock_engine = create_autospec(LSPEngine) with ( patch("os.path.exists", return_value=True), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), ): cli.transpile( @@ -327,7 +324,7 @@ def test_transpile_with_valid_input(mock_workspace_client_cli): def test_transpile_with_valid_transpiler(mock_workspace_client_cli): transpiler_config_path = path_to_resource("lsp_transpiler", "lsp_config.yml") source_dialect = "snowflake" - input_source = path_to_resource("functional", "snowflake", "aggregates", "least_1.sql") + input_source = path_to_resource("lsp_transpiler", "source_stuff.sql") output_folder = path_to_resource("lsp_transpiler") error_file = "" skip_validation = "true" @@ -336,7 +333,11 @@ def test_transpile_with_valid_transpiler(mock_workspace_client_cli): sdk_config = {'cluster_id': 'test_cluster'} mock_transpile, patched_do_transpile = patch_do_transpile() - with (patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile),): + mock_engine = create_autospec(LSPEngine) + with ( + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), + patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), + ): cli.transpile( mock_workspace_client_cli, transpiler_config_path, @@ -378,8 +379,10 @@ def test_transpile_empty_output_folder(mock_workspace_client_cli): sdk_config = {'cluster_id': 'test_cluster'} mock_transpile, patched_do_transpile = patch_do_transpile() + mock_engine = create_autospec(LSPEngine) with ( patch("os.path.exists", return_value=True), + patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), patch("databricks.labs.remorph.cli.do_transpile", new=patched_do_transpile), ): cli.transpile( From 484e1bc786a8a9262597ebc9b474810953df880e Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 18 Feb 2025 18:16:26 +0100 Subject: [PATCH 12/12] formatting --- src/databricks/labs/remorph/cli.py | 2 +- src/databricks/labs/remorph/reconcile/utils.py | 1 + tests/unit/conftest.py | 2 +- .../query_builder/test_expression_generator.py | 10 ++++++---- tests/unit/test_cli_transpile.py | 6 ++++-- tests/unit/transpiler/test_execute.py | 1 - 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/databricks/labs/remorph/cli.py b/src/databricks/labs/remorph/cli.py index fbd3f4c744..e2cfce2a5e 100644 --- a/src/databricks/labs/remorph/cli.py +++ b/src/databricks/labs/remorph/cli.py @@ -17,7 +17,7 @@ from databricks.labs.remorph.install import WorkspaceInstaller from databricks.labs.remorph.reconcile.runner import ReconcileRunner from databricks.labs.remorph.lineage import lineage_generator -from databricks.labs.remorph.reconcile.utils import get_dialect, dialect_exists +from databricks.labs.remorph.reconcile.utils import dialect_exists from databricks.labs.remorph.transpiler.execute import transpile as do_transpile from databricks.labs.remorph.reconcile.execute import RECONCILE_OPERATION_NAME, AGG_RECONCILE_OPERATION_NAME from databricks.labs.remorph.jvmproxy import proxy_command diff --git a/src/databricks/labs/remorph/reconcile/utils.py b/src/databricks/labs/remorph/reconcile/utils.py index 6a2e0b1057..dfb2198521 100644 --- a/src/databricks/labs/remorph/reconcile/utils.py +++ b/src/databricks/labs/remorph/reconcile/utils.py @@ -15,6 +15,7 @@ def dialect_exists(name: str) -> bool: values = {member.value for member in Dialects} return name in values + def get_dialect_name(dialect: Dialect) -> str: try: return Dialects(dialect).value diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 7f1449de4d..d8c1dcc787 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -28,7 +28,7 @@ def transpile_config(): source_dialect="snowflake", input_source="input_sql", output_folder="output_folder", - error_file_path=tmpdirname+"/errors.lst", + error_file_path=tmpdirname + "/errors.lst", sdk_config={"cluster_id": "test_cluster"}, skip_validation=False, catalog_name="catalog", diff --git a/tests/unit/reconcile/query_builder/test_expression_generator.py b/tests/unit/reconcile/query_builder/test_expression_generator.py index 4c385af125..da58ecbcc0 100644 --- a/tests/unit/reconcile/query_builder/test_expression_generator.py +++ b/tests/unit/reconcile/query_builder/test_expression_generator.py @@ -26,10 +26,12 @@ trim, ) + @pytest.fixture def expr(): yield parse_one("SELECT col1 FROM DUAL", read="databricks") + def test_coalesce(expr): assert coalesce(expr, "NA", True).sql() == "SELECT COALESCE(col1, 'NA') FROM DUAL" assert coalesce(expr, "0", False).sql() == "SELECT COALESCE(col1, 0) FROM DUAL" @@ -44,11 +46,11 @@ def test_trim(expr): def test_json_format(): - expr = parse_one("SELECT col1 FROM DUAL") + parsed = parse_one("SELECT col1 FROM DUAL") - assert json_format(expr).sql() == "SELECT JSON_FORMAT(col1) FROM DUAL" - assert json_format(expr).sql(dialect="databricks") == "SELECT TO_JSON(col1) FROM DUAL" - assert json_format(expr).sql(dialect="snowflake") == "SELECT JSON_FORMAT(col1) FROM DUAL" + assert json_format(parsed).sql() == "SELECT JSON_FORMAT(col1) FROM DUAL" + assert json_format(parsed).sql(dialect="databricks") == "SELECT TO_JSON(col1) FROM DUAL" + assert json_format(parsed).sql(dialect="snowflake") == "SELECT JSON_FORMAT(col1) FROM DUAL" def test_sort_array(expr): diff --git a/tests/unit/test_cli_transpile.py b/tests/unit/test_cli_transpile.py index d482868d79..516be130bd 100644 --- a/tests/unit/test_cli_transpile.py +++ b/tests/unit/test_cli_transpile.py @@ -1,5 +1,5 @@ import asyncio -from unittest.mock import create_autospec, patch, PropertyMock, ANY, MagicMock +from unittest.mock import create_autospec, patch, ANY, MagicMock import pytest @@ -216,7 +216,9 @@ def test_transpile_with_invalid_transpiler(mock_workspace_client_cli): def test_transpile_with_invalid_dialect(mock_workspace_client_cli): mock_engine = create_autospec(LSPEngine) - mock_engine.check_source_dialect.side_effect = lambda source_dialect: TranspileEngine.check_source_dialect(mock_engine, source_dialect) + mock_engine.check_source_dialect.side_effect = lambda source_dialect: TranspileEngine.check_source_dialect( + mock_engine, source_dialect + ) with ( patch("os.path.exists", return_value=True), patch("databricks.labs.remorph.transpiler.lsp_engine.LSPEngine.from_config_path", return_value=mock_engine), diff --git a/tests/unit/transpiler/test_execute.py b/tests/unit/transpiler/test_execute.py index dbe2b283ce..96947d9c81 100644 --- a/tests/unit/transpiler/test_execute.py +++ b/tests/unit/transpiler/test_execute.py @@ -136,4 +136,3 @@ def test_with_no_input_source(mock_workspace_client): with pytest.raises(ValueError, match="Input SQL path is not provided"): transpile(mock_workspace_client, config) -