From b2cfd656b345cac69f4030d77d0c5bba786b30fa Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sun, 14 Jan 2024 05:43:42 -0500 Subject: [PATCH] refactor(impala): port to sqlglot BREAKING CHANGE: Impala UDFs no longer require explicit registration. Remove any calls to `Function.register`. If you were passing `database` to `Function.register`, pass that to `scalar_function` or `aggregate_function` as appropriate. --- .github/workflows/ibis-backends.yml | 44 +- ibis/backends/base/sql/__init__.py | 1 - ibis/backends/base/sql/ddl.py | 6 +- ibis/backends/base/sql/registry/main.py | 2 - ibis/backends/base/sqlglot/compiler.py | 18 +- ibis/backends/base/sqlglot/datatypes.py | 8 + ibis/backends/base/sqlglot/rewrites.py | 6 +- ibis/backends/datafusion/compiler.py | 3 + ibis/backends/impala/__init__.py | 349 +++++++------ ibis/backends/impala/client.py | 22 +- ibis/backends/impala/compat.py | 24 - ibis/backends/impala/compiler.py | 461 ++++++++++++++++-- ibis/backends/impala/tests/conftest.py | 40 +- .../test_analytic_exprs/first/out.sql | 4 +- .../test_analytic_exprs/lag_arg/out.sql | 4 +- .../test_analytic_exprs/lag_default/out.sql | 4 +- .../lag_explicit_default/out.sql | 4 +- .../test_analytic_exprs/last/out.sql | 4 +- .../test_analytic_exprs/lead_arg/out.sql | 4 +- .../test_analytic_exprs/lead_default/out.sql | 4 +- .../lead_explicit_default/out.sql | 4 +- .../test_analytic_exprs/ntile/out.sql | 4 +- .../test_analytic_exprs/percent_rank/out.sql | 4 +- .../test_bucket_assign_labels/out.sql | 53 +- .../close_extreme_false/out.sql | 29 +- .../close_extreme_false_closed_right/out.sql | 29 +- .../out.sql | 35 +- .../test_bucket_to_case/closed_right/out.sql | 29 +- .../out.sql | 32 +- .../out.sql | 14 +- .../test_bucket_to_case/default/out.sql | 29 +- .../include_over_include_under0/out.sql | 14 +- .../include_over_include_under1/out.sql | 14 +- .../include_over_include_under2/out.sql | 14 +- .../test_bucket_to_case/include_under/out.sql | 32 +- .../include_under_include_over/out.sql | 35 +- .../fillna_l_extendedprice/out.sql | 4 +- .../fillna_l_extendedprice_double/out.sql | 4 +- .../fillna_l_quantity/out.sql | 4 +- .../test_case_exprs/test_identical_to/out.sql | 5 +- .../test_identical_to_special_case/out.sql | 3 +- .../test_ifelse_use_if/out.sql | 4 +- .../test_case_exprs/test_isnull_1_0/out1.sql | 4 +- .../test_case_exprs/test_isnull_1_0/out2.sql | 4 +- .../test_nullif_ifnull/nullif_boolean/out.sql | 4 +- .../test_nullif_ifnull/nullif_input/out.sql | 4 +- .../nullif_negate_boolean/out.sql | 4 +- .../test_case_exprs/test_search_case/out.sql | 14 +- .../test_case_exprs/test_simple_case/out.sql | 8 +- .../coalesce_columns/out.sql | 4 +- .../coalesce_scalar/out.sql | 4 +- .../greatest_columns/out.sql | 4 +- .../greatest_scalar/out.sql | 4 +- .../least_columns/out.sql | 4 +- .../least_scalar/out.sql | 4 +- .../test_avro_other_formats/out.sql | 5 +- .../test_create_external_table_as/out.sql | 5 +- .../test_create_table_parquet/out.sql | 20 +- .../test_no_overwrite/out.sql | 20 +- .../test_select_basics/out1.sql | 5 +- .../test_select_basics/out2.sql | 5 +- .../test_filter_with_analytic/out.sql | 32 +- .../test_named_from_filter_group_by/abc.sql | 21 +- .../test_named_from_filter_group_by/foo.sql | 21 +- .../test_exprs/test_nunique_where/out.sql | 5 +- .../test_where_with_timestamp/out.sql | 9 +- .../test_field_in_literals/isin/out.sql | 4 +- .../test_field_in_literals/notin/out.sql | 6 +- .../test_isin_notin_in_select/isin/out.sql | 18 +- .../test_isin_notin_in_select/notin/out.sql | 20 +- .../test_literal_in_fields/isin/out.sql | 4 +- .../test_literal_in_fields/notin/out.sql | 6 +- .../out.sql | 9 +- .../test_sql/test_is_parens/isnull/out.sql | 9 +- .../test_sql/test_is_parens/notnull/out.sql | 9 +- .../test_is_parens_identical_to/out.sql | 9 +- .../test_sql/test_join_aliasing/out.sql | 124 +++-- .../test_sql/test_join_key_name/out.sql | 150 ++++-- .../test_sql/test_join_key_name2/out.sql | 82 +++- .../cross_join/out.sql | 10 +- .../inner_join/out.sql | 11 +- .../left_join/out.sql | 11 +- .../outer_join/out.sql | 11 +- .../out.sql | 18 +- .../out.sql | 19 +- .../test_sql/test_limit_cte_extract/out.sql | 33 +- .../out.sql | 7 +- .../test_sql/test_multiple_filters/out.sql | 26 +- .../test_sql/test_multiple_filters2/out.sql | 28 +- .../test_sql/test_nested_join_base/out.sql | 41 +- .../test_nested_join_multiple_ctes/out.sql | 89 ++-- .../test_nested_joins_single_cte/out.sql | 63 ++- .../test_string_builtins/test_find/out.sql | 4 +- .../test_string_builtins/ascii_str/out.sql | 4 +- .../test_string_builtins/capitalize/out.sql | 4 +- .../test_string_builtins/extract_host/out.sql | 4 +- .../test_string_builtins/find/out.sql | 4 +- .../find_in_set_multiple/out.sql | 4 +- .../find_in_set_single/out.sql | 4 +- .../find_with_offset/out.sql | 4 +- .../test_string_builtins/length/out.sql | 4 +- .../test_string_builtins/like/out.sql | 4 +- .../like_multiple/out.sql | 4 +- .../test_string_builtins/lower/out.sql | 4 +- .../test_string_builtins/lpad_char/out.sql | 4 +- .../test_string_builtins/lpad_default/out.sql | 4 +- .../test_string_builtins/lstrip/out.sql | 4 +- .../test_string_builtins/re_extract/out.sql | 4 +- .../test_string_builtins/re_replace/out.sql | 4 +- .../test_string_builtins/re_search/out.sql | 4 +- .../test_string_builtins/repeat/out.sql | 4 +- .../test_string_builtins/reverse/out.sql | 4 +- .../test_string_builtins/rlike/out.sql | 4 +- .../test_string_builtins/rpad_char/out.sql | 4 +- .../test_string_builtins/rpad_default/out.sql | 4 +- .../test_string_builtins/rstrip/out.sql | 4 +- .../test_string_builtins/strip/out.sql | 4 +- .../test_string_builtins/strright/out.sql | 6 +- .../test_string_builtins/substr_0_3/out.sql | 10 +- .../test_string_builtins/substr_2/out.sql | 10 +- .../test_string_builtins/translate/out.sql | 4 +- .../test_string_builtins/upper/out.sql | 4 +- .../test_string_join/out.sql | 3 +- .../test_udf/test_sql_generation/out.sql | 3 +- .../out.sql | 3 +- .../test_unary_builtins/test_hash/out.sql | 4 +- .../test_numeric/log_with_base/out.sql | 4 +- .../test_numeric/round_expr/out.sql | 4 +- .../test_numeric/round_no_args/out.sql | 4 +- .../test_numeric/round_two/out.sql | 4 +- .../test_numeric/round_zero/out.sql | 4 +- .../test_numeric/sign_double/out.sql | 4 +- .../test_numeric/sign_float/out.sql | 4 +- .../test_numeric/sign_tinyint/out.sql | 4 +- .../double_col-abs/out.sql | 4 +- .../double_col-approx_median/out.sql | 4 +- .../double_col-approx_nunique/out.sql | 4 +- .../double_col-ceil/out.sql | 4 +- .../double_col-exp/out.sql | 4 +- .../double_col-floor/out.sql | 4 +- .../double_col-ln/out.sql | 4 +- .../double_col-log/out.sql | 4 +- .../double_col-log10/out.sql | 4 +- .../double_col-log2/out.sql | 4 +- .../double_col-nullif_zero/out.sql | 4 +- .../double_col-sqrt/out.sql | 4 +- .../double_col-zero_ifnull/out.sql | 4 +- .../int_col-abs/out.sql | 4 +- .../int_col-approx_median/out.sql | 4 +- .../int_col-approx_nunique/out.sql | 4 +- .../int_col-ceil/out.sql | 4 +- .../int_col-exp/out.sql | 4 +- .../int_col-floor/out.sql | 4 +- .../int_col-ln/out.sql | 4 +- .../int_col-log/out.sql | 4 +- .../int_col-log10/out.sql | 4 +- .../int_col-log2/out.sql | 4 +- .../int_col-nullif_zero/out.sql | 4 +- .../int_col-sqrt/out.sql | 4 +- .../int_col-zero_ifnull/out.sql | 4 +- .../test_reduction_where/avg/out.sql | 4 +- .../test_reduction_where/count/out.sql | 4 +- .../test_reduction_where/max/out.sql | 4 +- .../test_reduction_where/min/out.sql | 4 +- .../test_reduction_where/stddev_pop/out.sql | 4 +- .../test_reduction_where/stddev_samp/out.sql | 4 +- .../test_reduction_where/sum/out.sql | 4 +- .../test_reduction_where/var_pop/out.sql | 4 +- .../test_reduction_where/var_samp/out.sql | 4 +- .../test_value_exprs/test_any_all/all/out.sql | 4 +- .../test_value_exprs/test_any_all/any/out.sql | 4 +- .../test_any_all/not_all/out.sql | 6 +- .../test_any_all/not_any/out.sql | 6 +- .../test_value_exprs/test_between/out.sql | 4 +- .../test_binary_infix_operators/add/out.sql | 4 +- .../test_binary_infix_operators/and/out.sql | 6 +- .../test_binary_infix_operators/div/out.sql | 4 +- .../test_binary_infix_operators/eq/out.sql | 4 +- .../test_binary_infix_operators/ge/out.sql | 4 +- .../test_binary_infix_operators/gt/out.sql | 4 +- .../test_binary_infix_operators/le/out.sql | 4 +- .../test_binary_infix_operators/lt/out.sql | 4 +- .../test_binary_infix_operators/mul/out.sql | 4 +- .../test_binary_infix_operators/ne/out.sql | 4 +- .../test_binary_infix_operators/or/out.sql | 6 +- .../test_binary_infix_operators/pow/out.sql | 4 +- .../test_binary_infix_operators/sub/out.sql | 4 +- .../test_binary_infix_operators/xor/out.sql | 8 +- .../function_call/out.sql | 4 +- .../negation/out.sql | 6 +- .../parens_left/out.sql | 6 +- .../test_casts/a-int16/out.sql | 4 +- .../test_casts/a-int32/out.sql | 4 +- .../test_casts/a-int64/out.sql | 4 +- .../test_casts/a-string/out.sql | 4 +- .../test_casts/d-int8/out.sql | 4 +- .../test_casts/g-double/out.sql | 4 +- .../test_casts/g-timestamp/out.sql | 4 +- .../test_column_ref_table_aliases/out.sql | 1 - .../out1.sql | 15 + .../out2.sql | 15 + .../test_decimal_casts/column/out.sql | 4 +- .../test_decimal_casts/literal/out.sql | 3 +- .../compound_isnull/out.sql | 6 +- .../test_isnull_notnull/isnull/out.sql | 4 +- .../test_isnull_notnull/notnull/out.sql | 4 +- .../embedded_double_quote/out.sql | 3 +- .../embedded_single_quote/out.sql | 3 +- .../test_literals/false/out.sql | 3 +- .../test_literals/float/out.sql | 3 +- .../test_literals/int/out.sql | 3 +- .../test_literals/simple/out.sql | 3 +- .../test_literals/true/out.sql | 3 +- .../test_misc_conditionals/out.sql | 4 +- .../test_named_expressions/cast/out.sql | 4 +- .../compound_expr/out.sql | 6 +- .../test_named_expressions/spaces/out.sql | 4 +- .../test_value_exprs/test_negate/a/out.sql | 6 +- .../test_value_exprs/test_negate/f/out.sql | 6 +- .../test_value_exprs/test_negate/h/out.sql | 6 +- .../test_value_exprs/test_sql_extract/out.sql | 8 +- .../full_name/out.sql | 3 +- .../test_timestamp_day_of_week/index/out.sql | 3 +- .../test_timestamp_deltas/days/out1.sql | 4 +- .../test_timestamp_deltas/days/out2.sql | 4 +- .../test_timestamp_deltas/hours/out1.sql | 4 +- .../test_timestamp_deltas/hours/out2.sql | 4 +- .../test_timestamp_deltas/minutes/out1.sql | 4 +- .../test_timestamp_deltas/minutes/out2.sql | 4 +- .../test_timestamp_deltas/months/out1.sql | 4 +- .../test_timestamp_deltas/months/out2.sql | 4 +- .../test_timestamp_deltas/seconds/out1.sql | 4 +- .../test_timestamp_deltas/seconds/out2.sql | 4 +- .../test_timestamp_deltas/weeks/out1.sql | 4 +- .../test_timestamp_deltas/weeks/out2.sql | 4 +- .../test_timestamp_deltas/years/out1.sql | 4 +- .../test_timestamp_deltas/years/out2.sql | 4 +- .../test_timestamp_extract_field/day/out.sql | 4 +- .../test_timestamp_extract_field/hour/out.sql | 4 +- .../microsecond/out.sql | 4 +- .../millisecond/out.sql | 4 +- .../minute/out.sql | 4 +- .../month/out.sql | 4 +- .../second/out.sql | 4 +- .../test_timestamp_extract_field/year/out.sql | 4 +- .../default/out.sql | 4 +- .../test_timestamp_from_integer/ms/out.sql | 4 +- .../test_timestamp_from_integer/us/out.sql | 4 +- .../pd_timestamp/out.sql | 3 +- .../pydatetime/out.sql | 3 +- .../timestamp_function/out.sql | 3 +- .../test_timestamp_now/out.sql | 3 +- .../test_add_default_order_by/out.sql | 25 +- .../test_aggregate_in_projection/out.sql | 16 +- .../test_cumulative_functions/max/out1.sql | 5 +- .../test_cumulative_functions/max/out2.sql | 5 +- .../test_cumulative_functions/mean/out1.sql | 5 +- .../test_cumulative_functions/mean/out2.sql | 5 +- .../test_cumulative_functions/min/out1.sql | 5 +- .../test_cumulative_functions/min/out2.sql | 5 +- .../test_cumulative_functions/sum/out1.sql | 5 +- .../test_cumulative_functions/sum/out2.sql | 5 +- .../test_window/test_multiple_windows/out.sql | 7 +- .../test_nested_analytic_function/out.sql | 5 +- .../test_window/test_order_by_desc/out1.sql | 6 +- .../test_window/test_order_by_desc/out2.sql | 7 +- .../test_propagate_nested_windows/out.sql | 7 +- .../test_window/test_rank_functions/out.sql | 8 +- .../out1.sql | 16 +- .../out2.sql | 17 +- .../out.sql | 18 +- .../cumulative/out.sql | 5 +- .../test_window_frame_specs/foll_0/out.sql | 5 +- .../test_window_frame_specs/foll_10_5/out.sql | 5 +- .../test_window_frame_specs/foll_2/out.sql | 5 +- .../foll_2_prec_0/out.sql | 5 +- .../test_window_frame_specs/foll_5_10/out.sql | 5 +- .../test_window_frame_specs/prec_0/out.sql | 5 +- .../test_window_frame_specs/prec_5/out.sql | 5 +- .../prec_5_foll_0/out.sql | 5 +- .../prec_5_foll_2/out.sql | 5 +- .../trailing_10/out.sql | 5 +- .../impala/tests/test_bucket_histogram.py | 2 +- ibis/backends/impala/tests/test_case_exprs.py | 4 +- ibis/backends/impala/tests/test_client.py | 2 +- ibis/backends/impala/tests/test_ddl.py | 7 +- .../impala/tests/test_ddl_compilation.py | 24 +- ibis/backends/impala/tests/test_exprs.py | 16 +- ibis/backends/impala/tests/test_in_not_in.py | 3 +- .../backends/impala/tests/test_parquet_ddl.py | 4 +- ibis/backends/impala/tests/test_partition.py | 2 +- ibis/backends/impala/tests/test_sql.py | 26 +- ibis/backends/impala/tests/test_udf.py | 53 +- .../backends/impala/tests/test_value_exprs.py | 47 +- ibis/backends/impala/tests/test_window.py | 17 +- ibis/backends/impala/udf.py | 217 +++------ .../test_default_limit/impala/out.sql | 5 + .../test_disable_query_limit/impala/out.sql | 5 + .../impala/out.sql | 3 + .../test_respect_set_limit/impala/out.sql | 10 + .../test_group_by_has_index/impala/out.sql | 6 +- .../test_sql/test_isin_bug/impala/out.sql | 18 +- ibis/backends/tests/test_aggregation.py | 11 +- ibis/backends/tests/test_array.py | 62 +-- ibis/backends/tests/test_asof_join.py | 22 +- ibis/backends/tests/test_dot_sql.py | 9 +- ibis/backends/tests/test_generic.py | 52 +- ibis/backends/tests/test_numeric.py | 65 +-- ibis/backends/tests/test_sql.py | 7 +- ibis/backends/tests/test_string.py | 7 +- ibis/backends/tests/test_temporal.py | 45 +- ibis/backends/tests/test_uuid.py | 15 +- ibis/backends/tests/test_window.py | 5 - ibis/expr/operations/udf.py | 1 + poetry.lock | 4 +- pyproject.toml | 2 +- 316 files changed, 2760 insertions(+), 1369 deletions(-) delete mode 100644 ibis/backends/impala/compat.py delete mode 100644 ibis/backends/impala/tests/snapshots/test_value_exprs/test_column_ref_table_aliases/out.sql create mode 100644 ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out1.sql create mode 100644 ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out2.sql create mode 100644 ibis/backends/tests/snapshots/test_interactive/test_default_limit/impala/out.sql create mode 100644 ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/impala/out.sql create mode 100644 ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/impala/out.sql create mode 100644 ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/impala/out.sql diff --git a/.github/workflows/ibis-backends.yml b/.github/workflows/ibis-backends.yml index 0c7eda4b78bc..dce3f7b4220e 100644 --- a/.github/workflows/ibis-backends.yml +++ b/.github/workflows/ibis-backends.yml @@ -122,16 +122,16 @@ jobs: - postgres sys-deps: - libgeos-dev - # - name: impala - # title: Impala - # extras: - # - impala - # services: - # - impala - # - kudu - # sys-deps: - # - cmake - # - ninja-build + - name: impala + title: Impala + extras: + - impala + services: + - impala + - kudu + sys-deps: + - cmake + - ninja-build # - name: mssql # title: MS SQL Server # extras: @@ -223,18 +223,18 @@ jobs: - postgres sys-deps: - libgeos-dev - # - os: windows-latest - # backend: - # name: impala - # title: Impala - # extras: - # - impala - # services: - # - impala - # - kudu - # sys-deps: - # - cmake - # - ninja-build + - os: windows-latest + backend: + name: impala + title: Impala + extras: + - impala + services: + - impala + - kudu + sys-deps: + - cmake + - ninja-build # - os: windows-latest # backend: # name: mssql diff --git a/ibis/backends/base/sql/__init__.py b/ibis/backends/base/sql/__init__.py index 1fd6528170c4..618fa85678fa 100644 --- a/ibis/backends/base/sql/__init__.py +++ b/ibis/backends/base/sql/__init__.py @@ -22,7 +22,6 @@ import pandas as pd import pyarrow as pa -raise RuntimeError("Temporarily make the SQL backends dysfunctional") __all__ = ["BaseSQLBackend"] diff --git a/ibis/backends/base/sql/ddl.py b/ibis/backends/base/sql/ddl.py index f608c8ffd811..0f88a93a1df6 100644 --- a/ibis/backends/base/sql/ddl.py +++ b/ibis/backends/base/sql/ddl.py @@ -193,7 +193,7 @@ def _pieces(self): yield self._storage() yield self._location() yield "AS" - yield self.select.compile() + yield self.select def _partitioned_by(self): if self.partition is not None: @@ -212,7 +212,7 @@ def __init__(self, table_name, select, database=None, can_exist=False): @property def _pieces(self): yield "AS" - yield self.select.compile() + yield self.select @property def _prefix(self): @@ -352,7 +352,7 @@ def compile(self): else: partition = "" - select_query = self.select.compile() + select_query = self.select scoped_name = self._get_scoped_name(self.table_name, self.database) return f"{cmd} {scoped_name}{partition}\n{select_query}" diff --git a/ibis/backends/base/sql/registry/main.py b/ibis/backends/base/sql/registry/main.py index 91bf90f29707..96d74fa83013 100644 --- a/ibis/backends/base/sql/registry/main.py +++ b/ibis/backends/base/sql/registry/main.py @@ -355,10 +355,8 @@ def _floor(t, op): ops.IfElse: fixed_arity("if", 3), ops.Between: between, ops.InValues: binary_infix.in_values, - ops.InSubquery: binary_infix.in_column, ops.SimpleCase: case.simple_case, ops.SearchedCase: case.searched_case, - ops.Field: table_column, ops.DateAdd: timestamp.timestamp_op("date_add"), ops.DateSub: timestamp.timestamp_op("date_sub"), ops.DateDiff: timestamp.timestamp_op("datediff"), diff --git a/ibis/backends/base/sqlglot/compiler.py b/ibis/backends/base/sqlglot/compiler.py index 3f6a7088c747..61a257b97655 100644 --- a/ibis/backends/base/sqlglot/compiler.py +++ b/ibis/backends/base/sqlglot/compiler.py @@ -822,6 +822,14 @@ def visit_Window(self, op, *, how, func, start, end, group_by, order_by): end_value = end.get("value", "UNBOUNDED") end_side = end.get("side", "FOLLOWING") + if getattr(start_value, "this", None) == "0": + start_value = "CURRENT ROW" + start_side = None + + if getattr(end_value, "this", None) == "0": + end_value = "CURRENT ROW" + end_side = None + spec = sge.WindowSpec( kind=how.upper(), start=start_value, @@ -1004,10 +1012,12 @@ def visit_JoinLink(self, op, *, how, table, predicates): "cross": "cross", "outer": "outer", } - assert predicates - return sge.Join( - this=table, side=sides[how], kind=kinds[how], on=sg.and_(*predicates) - ) + assert ( + predicates or how == "cross" + ), "expected non-empty predicates when not a cross join" + + on = sg.and_(*predicates) if predicates else None + return sge.Join(this=table, side=sides[how], kind=kinds[how], on=on) @staticmethod def _gen_valid_name(name: str) -> str: diff --git a/ibis/backends/base/sqlglot/datatypes.py b/ibis/backends/base/sqlglot/datatypes.py index e342ebcd080e..b1d4c336739e 100644 --- a/ibis/backends/base/sqlglot/datatypes.py +++ b/ibis/backends/base/sqlglot/datatypes.py @@ -608,7 +608,15 @@ class SQLiteType(SqlglotType): dialect = "sqlite" +class ImpalaType(SqlglotType): + dialect = "impala" + + default_decimal_precision = 9 + default_decimal_scale = 0 + + class PySparkType(SqlglotType): dialect = "spark" + default_decimal_precision = 38 default_decimal_scale = 18 diff --git a/ibis/backends/base/sqlglot/rewrites.py b/ibis/backends/base/sqlglot/rewrites.py index c6b02d23423c..d3084e8f1543 100644 --- a/ibis/backends/base/sqlglot/rewrites.py +++ b/ibis/backends/base/sqlglot/rewrites.py @@ -168,10 +168,8 @@ def rewrite_last_to_last_value(_, x, y): @replace(p.WindowFunction(frame=y @ p.WindowFrame(order_by=()))) -def rewrite_empty_order_by_window(_, y): - import ibis - - return _.copy(frame=y.copy(order_by=(ibis.NA,))) +def rewrite_empty_order_by_window(_, y, **__): + return _.copy(frame=y.copy(order_by=(ops.NULL,))) @replace(p.WindowFunction(p.RowNumber | p.NTile, y)) diff --git a/ibis/backends/datafusion/compiler.py b/ibis/backends/datafusion/compiler.py index 0bd4c005451b..f090819e2976 100644 --- a/ibis/backends/datafusion/compiler.py +++ b/ibis/backends/datafusion/compiler.py @@ -6,6 +6,7 @@ from itertools import starmap import sqlglot as sg +import sqlglot.expressions as sge from sqlglot import exp, transforms from sqlglot.dialects import Postgres from sqlglot.dialects.dialect import rename_func @@ -102,6 +103,8 @@ def visit_NonNullLiteral(self, op, *, value, dtype): return self.f.date_trunc("day", value.isoformat()) elif dtype.is_binary(): return sg.exp.HexString(this=value.hex()) + elif dtype.is_uuid(): + return sge.convert(str(value)) else: return None diff --git a/ibis/backends/impala/__init__.py b/ibis/backends/impala/__init__.py index a4cbb777dfcc..a2142846aa57 100644 --- a/ibis/backends/impala/__init__.py +++ b/ibis/backends/impala/__init__.py @@ -3,23 +3,24 @@ from __future__ import annotations import contextlib -import io import operator -import re +import os from functools import cached_property from typing import TYPE_CHECKING, Any, Literal +from urllib.parse import parse_qs, urlparse +import impala.dbapi as impyla import pandas as pd import sqlglot as sg +import sqlglot.expressions as sge +from impala.error import Error as ImpylaError import ibis.common.exceptions as com import ibis.config import ibis.expr.datatypes as dt -import ibis.expr.rules as rlz import ibis.expr.schema as sch import ibis.expr.types as ir from ibis import util -from ibis.backends.base.sql import BaseSQLBackend from ibis.backends.base.sql.ddl import ( CTAS, CreateDatabase, @@ -30,12 +31,10 @@ DropView, RenameTable, TruncateTable, - fully_qualified_re, - is_fully_qualified, ) +from ibis.backends.base.sqlglot import SQLGlotBackend from ibis.backends.impala import ddl, udf from ibis.backends.impala.client import ImpalaTable -from ibis.backends.impala.compat import ImpylaError, impyla from ibis.backends.impala.compiler import ImpalaCompiler from ibis.backends.impala.udf import ( aggregate_function, @@ -44,14 +43,14 @@ wrap_udf, ) from ibis.config import options -from ibis.formats.pandas import PandasData if TYPE_CHECKING: - from collections.abc import Mapping + from collections.abc import Iterator, Mapping from pathlib import Path import pyarrow as pa + import ibis.expr.operations as ops from ibis.backends.base.sql.compiler import DDL, DML @@ -64,48 +63,11 @@ ) -def _split_signature(x): - name, rest = x.split("(", 1) - return name, rest[:-1] - - -_arg_type = re.compile(r"(.*)\.\.\.|([^\.]*)") - - -class _type_parser: - NORMAL, IN_PAREN = 0, 1 - - def __init__(self, value): - self.value = value - self.state = self.NORMAL - self.buf = io.StringIO() - self.types = [] - for c in value: - self._step(c) - self._push() - - def _push(self): - val = self.buf.getvalue().strip() - if val: - self.types.append(val) - self.buf = io.StringIO() - - def _step(self, c): - if self.state == self.NORMAL: - if c == "(": - self.state = self.IN_PAREN - elif c == ",": - self._push() - return - elif self.state == self.IN_PAREN: - if c == ")": - self.state = self.NORMAL - self.buf.write(c) - - -class Backend(BaseSQLBackend): +class Backend(SQLGlotBackend): name = "impala" - compiler = ImpalaCompiler + compiler = ImpalaCompiler() + + supports_in_memory_tables = True _sqlglot_dialect = "hive" # not 100% accurate, but very close @@ -123,6 +85,50 @@ class Options(ibis.config.Config): temp_db: str = "__ibis_tmp" temp_path: str = "/tmp/__ibis" + def _from_url(self, url: str, **kwargs: Any) -> Backend: + """Connect to a backend using a URL `url`. + + Parameters + ---------- + url + URL with which to connect to a backend. + kwargs + Additional keyword arguments passed to the `connect` method. + + Returns + ------- + BaseBackend + A backend instance + """ + url = urlparse(url) + + for name in ("username", "hostname", "port", "password"): + if value := ( + getattr(url, name, None) + or os.environ.get(f"{self.name.upper()}_{name.upper()}") + ): + kwargs[name] = value + + with contextlib.suppress(KeyError): + kwargs["host"] = kwargs.pop("hostname") + + (database,) = url.path[1:].split("/", 1) + if database: + kwargs["database"] = database + + query_params = parse_qs(url.query) + + for name, value in query_params.items(): + if len(value) > 1: + kwargs[name] = value + elif len(value) == 1: + kwargs[name] = value[0] + else: + raise com.IbisError(f"Invalid URL parameter: {name}") + + self._convert_kwargs(kwargs) + return self.connect(**kwargs) + def do_connect( self, host: str = "localhost", @@ -135,7 +141,6 @@ def do_connect( password: str | None = None, auth_mechanism: Literal["NOSASL", "PLAIN", "GSSAPI", "LDAP"] = "NOSASL", kerberos_service_name: str = "impala", - pool_size: int = 8, **params: Any, ): """Create an Impala `Backend` for use with Ibis. @@ -169,8 +174,6 @@ def do_connect( | `'GSSAPI'` | Kerberos-secured clusters | kerberos_service_name Specify a particular `impalad` service principal. - pool_size - Size of the connection pool. Typically this is not necessary to configure. params Any additional parameters necessary to open a connection to Impala. Please refer to impyla documentation for the full list of @@ -226,16 +229,10 @@ def list_tables(self, like=None, database=None): statement = "SHOW TABLES" if database is not None: statement += f" IN {database}" - if like: - if match := fully_qualified_re.match(like): - database, quoted, unquoted = match.groups() - like = quoted or unquoted - return self.list_tables(like=like, database=database) - statement += f" LIKE '{like}'" with self._safe_raw_sql(statement) as cursor: tables = fetchall(cursor) - return self._filter_with_like(tables.name.tolist()) + return self._filter_with_like(tables.name.tolist(), like=like) def raw_sql(self, query: str): cursor = self.con.cursor() @@ -259,16 +256,21 @@ def raw_sql(self, query: str): return cursor - def fetch_from_cursor(self, cursor, schema): + def _fetch_from_cursor(self, cursor, schema): + from ibis.formats.pandas import PandasData + results = fetchall(cursor) - if schema: - return PandasData.convert_table(results, schema) - return results + return PandasData.convert_table(results, schema) @contextlib.contextmanager def _safe_raw_sql(self, query: str | DDL | DML): if not isinstance(query, str): - query = query.compile() + try: + query = query.sql(dialect=self.compiler.dialect) + except AttributeError: + query = query.compile() + + assert isinstance(query, str), type(query) with contextlib.closing(self.raw_sql(query)) as cur: yield cur @@ -277,18 +279,15 @@ def _safe_exec_sql(self, *args, **kwargs): pass def _fully_qualified_name(self, name, database): - if is_fully_qualified(name): - return name - database = database or self.current_database - return sg.table(name, db=database, quoted=True).sql( - dialect=getattr(self, "_sqlglot_dialect", self.name) + return sg.table(name, db=database, quoted=self.compiler.quoted).sql( + self.compiler.dialect ) @property def current_database(self) -> str: with self._safe_raw_sql("SELECT CURRENT_DATABASE()") as cur: - (db,) = cur.fetchone() + [(db,)] = cur.fetchall() return db def create_database(self, name, path=None, force=False): @@ -353,13 +352,17 @@ def drop_database(self, name, force=False): statement = DropDatabase(name, must_exist=not force) self._safe_exec_sql(statement) - def get_schema(self, table_name: str, database: str | None = None) -> sch.Schema: + def get_schema( + self, table_name: str, schema: str | None = None, database: str | None = None + ) -> sch.Schema: """Return a Schema object for the indicated table and database. Parameters ---------- table_name Table name + schema + Schema name. Unused in the impala backend. database Database name @@ -368,13 +371,44 @@ def get_schema(self, table_name: str, database: str | None = None) -> sch.Schema Schema Ibis schema """ - qualified_name = self._fully_qualified_name(table_name, database) - query = f"DESCRIBE {qualified_name}" + query = sge.Describe( + this=sg.table( + table_name, db=schema, catalog=database, quoted=self.compiler.quoted + ) + ) with self._safe_raw_sql(query) as cur: meta = fetchall(cur) - ibis_types = meta.type.str.lower().map(udf.parse_type) - return sch.Schema(dict(zip(meta.name, ibis_types))) + return sch.Schema.from_tuples( + zip(meta["name"], meta["type"].map(self.compiler.type_mapper.from_string)) + ) + + def _metadata(self, query: str) -> Iterator[tuple[str, dt.DataType]]: + """Return a Schema object for the indicated table and database. + + Parameters + ---------- + query + Query to execute against Impala + + Returns + ------- + Iterator[tuple[str, dt.DataType]] + Iterator of column name and Ibis type pairs + """ + tmpview = util.gen_name("impala_tmpview") + query = f"CREATE VIEW IF NOT EXISTS {tmpview} AS {query}" + + with self._safe_raw_sql(query) as cur: + try: + cur.execute(f"DESCRIBE {tmpview}") + meta = fetchall(cur) + finally: + cur.execute(f"DROP VIEW IF EXISTS {tmpview}") + + return zip( + meta["name"], meta["type"].map(self.compiler.type_mapper.from_string) + ) @property def client_options(self): @@ -401,8 +435,7 @@ def create_view( database: str | None = None, overwrite: bool = False, ) -> ir.Table: - ast = self.compiler.to_ast(obj) - select = ast.queries[0] + select = self.compile(obj) statement = CreateView(name, select, database=database, can_exist=overwrite) self._safe_exec_sql(statement) return self.table(name, database=database) @@ -475,8 +508,9 @@ def create_table( if isinstance(obj, pd.DataFrame): raise NotImplementedError("Pandas DataFrames not yet supported") - ast = self.compiler.to_ast(obj) - select = ast.queries[0] + self._run_pre_execute_hooks(obj) + + select = self.compile(obj) if overwrite: self.drop_table(name, force=True) @@ -485,7 +519,7 @@ def create_table( CTAS( name, select, - database=database, + database=database or self.current_database, format=format, external=True if location is not None else external, partition=partition, @@ -499,14 +533,14 @@ def create_table( CreateTableWithSchema( name, schema if schema is not None else obj.schema(), - database=database, + database=database or self.current_database, format=format, external=external, path=location, partition=partition, ) ) - return self.table(name, database=database) + return self.table(name, database=database or self.current_database) def avro_file( self, directory, avro_schema, name=None, database=None, external=True @@ -600,13 +634,13 @@ def delimited_file( def parquet_file( self, - directory, - schema=None, - name=None, - database=None, - external=True, - like_file=None, - like_table=None, + directory: str | Path, + schema: sch.Schema | None = None, + name: str | None = None, + database: str | None = None, + external: bool = True, + like_file: str | Path | None = None, + like_table: str | None = None, ): """Create an Ibis table from the passed directory of Parquet files. @@ -633,8 +667,8 @@ def parquet_file( Database to create the (possibly temporary) table in external If a table is external, the referenced data will not be deleted - when the table is dropped in Impala. Otherwise (external=False) - Impala takes ownership of the Parquet file. + when the table is dropped in Impala. Otherwise Impala takes + ownership of the Parquet file. Returns ------- @@ -710,6 +744,8 @@ def insert( Completely overwrite contents >>> con.insert(table, table_expr, overwrite=True) # quartodoc: +SKIP # doctest: +SKIP """ + if isinstance(obj, ir.Table): + self._run_pre_execute_hooks(obj) table = self.table(table_name, database=database) return table.insert( obj=obj, @@ -800,12 +836,6 @@ def cache_table(self, table_name, *, database=None, pool="default"): statement = ddl.CacheTable(table_name, database=database, pool=pool) self._safe_exec_sql(statement) - def _get_schema_using_query(self, query): - with self._safe_raw_sql(f"SELECT * FROM ({query}) t0 LIMIT 0") as cur: - ibis_fields = self._adapt_types(cur.description) - - return sch.Schema(ibis_fields) - def create_function(self, func, name=None, database=None): """Create a function within Impala. @@ -931,7 +961,7 @@ def list_udfs(self, database=None, like=None): database = self.current_database statement = ddl.ListFunction(database, like=like, aggregate=False) with self._safe_raw_sql(statement) as cur: - return self._get_udfs(cur, udf.ImpalaUDF) + return self._get_udfs(cur) def list_udas(self, database=None, like=None): """Lists all UDAFs associated with a given database.""" @@ -939,40 +969,29 @@ def list_udas(self, database=None, like=None): database = self.current_database statement = ddl.ListFunction(database, like=like, aggregate=True) with self._safe_raw_sql(statement) as cur: - return self._get_udfs(cur, udf.ImpalaUDA) - - def _get_udfs(self, cur, klass): - def _to_type(x): - ibis_type = udf._impala_type_to_ibis(x.lower()) - return dt.dtype(ibis_type) + return self._get_udfs(cur) + def _get_udfs(self, cur): rows = fetchall(cur) - if not rows.empty: - result = [] - for _, row in rows.iterrows(): - out_type = row["return type"] - sig = row["signature"] - name, types = _split_signature(sig) - types = _type_parser(types).types - - inputs = [] - for arg in types: - argm = _arg_type.match(arg) - var, simple = argm.groups() - if simple: - t = _to_type(simple) - inputs.append(t) - else: - t = _to_type(var) - inputs = rlz.listof(t) - break - - output = udf._impala_type_to_ibis(out_type.lower()) - result.append(klass(inputs, output, name=name)) - return result - else: + + if rows.empty: return [] + current_database = self.current_database + type_mapper = self.compiler.type_mapper + result = [] + for return_type, signature, *_ in rows.itertuples(index=False): + anon = sg.parse_one(signature) + name = anon.this + inputs = [ + type_mapper.from_string(expr.this.this) for expr in anon.expressions + ] + + output = type_mapper.from_string(return_type) + + result.append((current_database, name, tuple(inputs), output)) + return result + def exists_udf(self, name: str, database: str | None = None) -> bool: """Checks if a given UDF exists within a specified database.""" return bool(self.list_udfs(database=database, like=name)) @@ -1106,27 +1125,12 @@ def column_stats(self, name, database=None): def _exec_statement(self, stmt): with self._safe_raw_sql(stmt) as cur: - return self.fetch_from_cursor(cur, schema=None) + return fetchall(cur) def _table_command(self, cmd, name, database=None): qualified_name = self._fully_qualified_name(name, database) return f"{cmd} {qualified_name}" - def _adapt_types(self, descr): - names = [] - adapted_types = [] - for col in descr: - names.append(col[0]) - impala_typename = col[1] - typename = udf._impala_to_ibis_type[impala_typename.lower()] - - if typename == "decimal": - precision, scale = col[4:6] - adapted_types.append(dt.Decimal(precision, scale)) - else: - adapted_types.append(typename) - return dict(zip(names, adapted_types)) - def to_pyarrow( self, expr: ir.Expr, @@ -1139,6 +1143,8 @@ def to_pyarrow( from ibis.formats.pyarrow import PyArrowData + self._run_pre_execute_hooks(expr) + table_expr = expr.as_table() output = pa.Table.from_pandas( self.execute(table_expr, params=params, limit=limit, **kwargs), @@ -1157,6 +1163,8 @@ def to_pyarrow_batches( **kwargs: Any, ) -> pa.ipc.RecordBatchReader: pa = self._import_pyarrow() + self._run_pre_execute_hooks(expr) + pa_table = self.to_pyarrow( expr.as_table(), params=params, limit=limit, **kwargs ) @@ -1177,16 +1185,7 @@ def explain( str Query plan """ - if isinstance(expr, ir.Expr): - context = self.compiler.make_context(params=params) - query_ast = self.compiler.to_ast(expr, context) - if len(query_ast.queries) > 1: - raise Exception("Multi-query expression") - - query = query_ast.queries[0].compile() - else: - query = expr - + query = self.compile(expr, params=params) statement = f"EXPLAIN {query}" with self._safe_raw_sql(statement) as cur: @@ -1194,6 +1193,46 @@ def explain( return "\n".join(["Query:", util.indent(query, 2), "", *results.iloc[:, 0]]) + def _register_in_memory_table(self, op: ops.InMemoryTable) -> None: + schema = op.schema + if null_columns := [col for col, dtype in schema.items() if dtype.is_null()]: + raise com.IbisTypeError( + "Impala cannot yet reliably handle `null` typed columns; " + f"got null typed columns: {null_columns}" + ) + + # only register if we haven't already done so + if (name := op.name) not in self.list_tables(): + type_mapper = self.compiler.type_mapper + quoted = self.compiler.quoted + column_defs = [ + sg.exp.ColumnDef( + this=sg.to_identifier(colname, quoted=quoted), + kind=type_mapper.from_ibis(typ), + # we don't support `NOT NULL` constraints in trino because + # because each trino connector differs in whether it + # supports nullability constraints, and whether the + # connector supports it isn't visible to ibis via a + # metadata query + ) + for colname, typ in schema.items() + ] + + create_stmt = sg.exp.Create( + kind="TABLE", + this=sg.exp.Schema( + this=sg.to_identifier(name, quoted=quoted), expressions=column_defs + ), + ).sql(self.name, pretty=True) + + data = op.data.to_frame().itertuples(index=False) + specs = ", ".join("?" * len(schema)) + table = sg.table(name, quoted=quoted).sql(self.name) + insert_stmt = f"INSERT INTO {table} VALUES ({specs})" + with self._safe_raw_sql(create_stmt) as cur: + for row in data: + cur.execute(insert_stmt, row) + def fetchall(cur): batches = cur.fetchcolumnar() diff --git a/ibis/backends/impala/client.py b/ibis/backends/impala/client.py index b7c49b5fca57..cac294bd5cba 100644 --- a/ibis/backends/impala/client.py +++ b/ibis/backends/impala/client.py @@ -28,34 +28,36 @@ def _client(self): @property def _database(self) -> str: - return self.op().namespace + return self.op().namespace.database def compute_stats(self, incremental=False): """Invoke Impala COMPUTE STATS command on the table.""" - return self._client.compute_stats(self._qualified_name, incremental=incremental) + return self._client.compute_stats( + self.op().name, database=self._database, incremental=incremental + ) def invalidate_metadata(self): - self._client.invalidate_metadata(self._qualified_name) + self._client.invalidate_metadata(self.op().name, database=self._database) def refresh(self): - self._client.refresh(self._qualified_name) + self._client.refresh(self.op().name, database=self._database) def metadata(self): """Return results of `DESCRIBE FORMATTED` statement.""" - return self._client.describe_formatted(self._qualified_name) + return self._client.describe_formatted(self.op().name, database=self._database) describe_formatted = metadata def files(self): """Return results of SHOW FILES statement.""" - return self._client.show_files(self._qualified_name) + return self._client.show_files(self.op().name, database=self._database) def drop(self): """Drop the table from the database.""" - self._client.drop_table_or_view(self._qualified_name) + self._client.drop_table_or_view(self.op().name, database=self._database) def truncate(self): - self._client.truncate_table(self._qualified_name) + self._client.truncate_table(self.op().name, database=self._database) def insert( self, @@ -121,11 +123,9 @@ def insert( else: partition_schema = None - ast = self._client.compiler.to_ast(expr) - select = ast.queries[0] statement = InsertSelect( self._qualified_name, - select, + self._client.compile(expr), partition=partition, partition_schema=partition_schema, overwrite=overwrite, diff --git a/ibis/backends/impala/compat.py b/ibis/backends/impala/compat.py deleted file mode 100644 index 49bcc0991f3b..000000000000 --- a/ibis/backends/impala/compat.py +++ /dev/null @@ -1,24 +0,0 @@ -from __future__ import annotations - -# Copyright 2015 Cloudera Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import impala.dbapi as impyla -from impala.error import Error as ImpylaError -from impala.error import HiveServer2Error as HS2Error - -__all__ = ( - "impyla", - "ImpylaError", - "HS2Error", -) diff --git a/ibis/backends/impala/compiler.py b/ibis/backends/impala/compiler.py index 54fb8f7f3437..2f3386ece696 100644 --- a/ibis/backends/impala/compiler.py +++ b/ibis/backends/impala/compiler.py @@ -1,66 +1,433 @@ from __future__ import annotations +import contextlib +from functools import singledispatchmethod + +import sqlglot as sg +import sqlglot.expressions as sge +from sqlglot.dialects import Hive +from sqlglot.dialects.dialect import rename_func + +import ibis.common.exceptions as com +import ibis.expr.datatypes as dt import ibis.expr.operations as ops -from ibis.backends.base.sql.compiler import Compiler, ExprTranslator, TableSetFormatter -from ibis.backends.base.sql.registry import binary_infix_ops, operation_registry, unary +from ibis import util +from ibis.backends.base.sqlglot.compiler import NULL, STAR, SQLGlotCompiler +from ibis.backends.base.sqlglot.datatypes import ImpalaType +from ibis.backends.base.sqlglot.rewrites import ( + rewrite_empty_order_by_window, + rewrite_first_to_first_value, + rewrite_last_to_last_value, +) from ibis.expr.rewrites import rewrite_sample -class ImpalaTableSetFormatter(TableSetFormatter): - def _get_join_type(self, op): - jname = self._join_names[type(op)] +def _interval(self, e): + """Work around Impala's inability to handle string literals in INTERVAL syntax.""" + arg = e.args["this"].this + with contextlib.suppress(AttributeError): + arg = arg.sql(self.dialect) + res = f"INTERVAL {arg} {e.args['unit']}" + return res - # Impala requires this - if not op.predicates: - jname = self._join_names[ops.CrossJoin] - return jname +class Impala(Hive): + class Generator(Hive.Generator): + TRANSFORMS = Hive.Generator.TRANSFORMS.copy() | { + sge.ApproxDistinct: rename_func("ndv"), + sge.IsNan: rename_func("is_nan"), + sge.IsInf: rename_func("is_inf"), + sge.DayOfWeek: rename_func("dayofweek"), + sge.Interval: _interval, + } - def _format_in_memory_table(self, op): - if op.data: - return super()._format_in_memory_table(op) - schema = op.schema - names = schema.names - types = schema.types - rows = [ - f"{self._translate(ops.Cast(ops.Literal(None, dtype=dtype), to=dtype))} AS {name}" - for name, dtype in zip(map(self._quote_identifier, names), types) - ] - return f"(SELECT * FROM (SELECT {', '.join(rows)}) AS _ LIMIT 0)" +class ImpalaCompiler(SQLGlotCompiler): + __slots__ = () - -class ImpalaExprTranslator(ExprTranslator): - _registry = {**operation_registry, **binary_infix_ops, ops.Hash: unary("fnv_hash")} - _forbids_frame_clause = ( - *ExprTranslator._forbids_frame_clause, - ops.Lag, - ops.Lead, - ops.FirstValue, - ops.LastValue, - ) - _unsupported_reductions = ( - ops.ApproxMedian, - ops.ApproxCountDistinct, - ops.GroupConcat, + dialect = "impala" + type_mapper = ImpalaType + rewrites = ( + rewrite_sample, + rewrite_first_to_first_value, + rewrite_last_to_last_value, + rewrite_empty_order_by_window, + *SQLGlotCompiler.rewrites, ) - _dialect_name = "hive" - _quote_identifiers = True + quoted = True + + def _aggregate(self, funcname: str, *args, where): + if where is not None: + args = tuple(self.if_(where, arg, NULL) for arg in args) + + return self.f[funcname](*args, dialect=self.dialect) + + @staticmethod + def _minimize_spec(start, end, spec): + # start is None means unbounded preceding + if start is None: + # end is None: unbounded following + # end == 0 => current row + # these are treated the same because for the functions where these + # are not allowed they end up behaving the same + # + # I think we're not covering some cases here: + # These will be treated the same, even though they're not + # - window(order_by=x, rows=(None, None)) # should be equivalent to `over ()` + # - window(order_by=x, rows=(None, 0)) # equivalent to a cumulative aggregation + # + # TODO(cpcloud): we need to clean up the semantics of unbounded + # following vs current row at the API level. + # + if end is None or ( + isinstance(getattr(end, "value", None), ops.Literal) + and end.value.value == 0 + and end.following + ): + return None + return spec + + @singledispatchmethod + def visit_node(self, op, **kw): + return super().visit_node(op, **kw) + + @visit_node.register(ops.Literal) + def visit_Literal(self, op, *, value, dtype): + if value is None and dtype.is_binary(): + return NULL + return super().visit_Literal(op, value=value, dtype=dtype) + + @visit_node.register(ops.CountStar) + def visit_CountStar(self, op, *, arg, where): + if where is not None: + return self.f.sum(self.cast(where, op.dtype)) + return self.f.count(STAR) + + @visit_node.register(ops.CountDistinctStar) + def visit_CountDistinctStar(self, op, *, arg, where): + expressions = ( + sg.column(name, table=arg.alias_or_name, quoted=self.quoted) + for name in op.arg.schema.keys() + ) + if where is not None: + expressions = (self.if_(where, expr, NULL) for expr in expressions) + return self.f.count(sge.Distinct(expressions=list(expressions))) + + @visit_node.register(ops.CountDistinct) + def visit_CountDistinct(self, op, *, arg, where): + if where is not None: + arg = self.if_(where, arg, NULL) + return self.f.count(sge.Distinct(expressions=[arg])) + + @visit_node.register(ops.Xor) + def visit_Xor(self, op, *, left, right): + return sg.and_(sg.or_(left, right), sg.not_(sg.and_(left, right))) + + @visit_node.register(ops.RandomScalar) + def visit_RandomScalar(self, op): + return self.f.rand(self.f.utc_to_unix_micros(self.f.utc_timestamp())) + + @visit_node.register(ops.DayOfWeekIndex) + def visit_DayOfWeekIndex(self, op, *, arg): + return self.f.pmod(self.f.dayofweek(arg) - 2, 7) + + @visit_node.register(ops.ExtractMillisecond) + def viist_ExtractMillisecond(self, op, *, arg): + return self.f.extract(self.v.millisecond, arg) % 1_000 + + @visit_node.register(ops.ExtractMicrosecond) + def visit_ExtractMicrosecond(self, op, *, arg): + return self.f.extract(self.v.microsecond, arg) % 1_000_000 + + @visit_node.register(ops.Degrees) + def visit_Degrees(self, op, *, arg): + return 180.0 * arg / self.f.pi() + + @visit_node.register(ops.Radians) + def visit_Radians(self, op, *, arg): + return self.f.pi() * arg / 180.0 + + @visit_node.register(ops.HashBytes) + def visit_HashBytes(self, op, *, arg, how): + if how not in ("md5", "sha1", "sha256", "sha512"): + raise com.UnsupportedOperationError(how) + return self.f[how](arg) + + @visit_node.register(ops.Log) + def visit_Log(self, op, *, arg, base): + if base is None: + return self.f.ln(arg) + return self.f.log(base, arg, dialect=self.dialect) + + @visit_node.register(ops.DateFromYMD) + def visit_DateFromYMD(self, op, *, year, month, day): + return self.cast( + self.f.concat( + self.f.lpad(self.cast(year, dt.string), 4, "0"), + "-", + self.f.lpad(self.cast(month, dt.string), 2, "0"), + "-", + self.f.lpad(self.cast(day, dt.string), 2, "0"), + ), + dt.date, + ) + + def visit_NonNullLiteral(self, op, *, value, dtype): + if dtype.is_date() or dtype.is_timestamp(): + # hack to return a string literal because impala doesn't support a + # wide range of properly-typed date values + # + # the date implementation is very unpolished: some proper dates are + # supported, but only within a certain range, and the + # implementation wraps on over- and underflow + return sge.convert(value.isoformat()) + elif dtype.is_string(): + value = ( + value + # Escape \ first so we don't double escape other characters. + .replace("\\", "\\\\") + # ASCII escape sequences that are recognized in Python: + # https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals + .replace("\a", "\\a") # Bell + .replace("\b", "\\b") # Backspace + .replace("\f", "\\f") # Formfeed + .replace("\n", "\\n") # Newline / Linefeed + .replace("\r", "\\r") # Carriage return + .replace("\t", "\\t") # Tab + .replace("\v", "\\v") # Vertical tab + ) + return sge.convert(value) + elif dtype.is_decimal() and not value.is_finite(): + raise com.UnsupportedOperationError( + f"Non-finite decimal literal values are not supported by Impala; got: {value}" + ) + elif dtype.is_array() or dtype.is_map() or dtype.is_struct(): + raise com.UnsupportedBackendType( + f"Impala does not support {dtype.name.lower()} literals" + ) + elif dtype.is_uuid(): + return sge.convert(str(value)) + return None + + @visit_node.register(ops.Cast) + def visit_Cast(self, op, *, arg, to): + from_ = op.arg.dtype + if from_.is_integer() and to.is_interval(): + return sge.Interval(this=sge.convert(arg), unit=to.unit.singular.upper()) + elif from_.is_temporal() and to.is_integer(): + return 1_000_000 * self.f.unix_timestamp(arg) + return super().visit_Cast(op, arg=arg, to=to) + + @visit_node.register(ops.StartsWith) + def visit_StartsWith(self, op, *, arg, start): + return arg.like(self.f.concat(start, "%")) + + @visit_node.register(ops.EndsWith) + def visit_EndsWith(self, op, *, arg, end): + return arg.like(self.f.concat("%", end)) + + @visit_node.register(ops.FindInSet) + def visit_FindInSet(self, op, *, needle, values): + return self.f.find_in_set(needle, self.f.concat_ws(",", *values)) + + @visit_node.register(ops.ExtractProtocol) + @visit_node.register(ops.ExtractAuthority) + @visit_node.register(ops.ExtractUserInfo) + @visit_node.register(ops.ExtractHost) + @visit_node.register(ops.ExtractFile) + @visit_node.register(ops.ExtractPath) + def visit_ExtractUrlField(self, op, *, arg): + return self.f.parse_url(arg, type(op).__name__[len("Extract") :].upper()) + + @visit_node.register(ops.ExtractQuery) + def visit_ExtractQuery(self, op, *, arg, key): + return self.f.parse_url(*filter(None, (arg, "QUERY", key))) + + @visit_node.register(ops.ExtractFragment) + def visit_ExtractFragment(self, op, *, arg): + return self.f.parse_url(arg, "REF") + + @visit_node.register(ops.StringFind) + def visit_StringFind(self, op, *, arg, substr, start, end): + if start is not None: + return self.f.locate(substr, arg, start + 1) + return self.f.locate(substr, arg) + + @visit_node.register(ops.StringContains) + def visit_StringContains(self, op, *, haystack, needle): + return self.f.locate(needle, haystack) > 0 + + @visit_node.register(ops.TimestampDiff) + def visit_TimestampDiff(self, op, *, left, right): + return self.f.unix_timestamp(left) - self.f.unix_timestamp(right) + + @visit_node.register(ops.Strftime) + def visit_Strftime(self, op, *, arg, format_str): + if not isinstance(op.format_str, ops.Literal): + raise com.UnsupportedOperationError( + "strftime format string must be a literal; " + f"got: {type(op.format_str).__name__}" + ) + format_str = sg.time.format_time( + op.format_str.value, {v: k for k, v in Impala.TIME_MAPPING.items()} + ) + return self.f.from_unixtime( + self.f.unix_timestamp(self.cast(arg, dt.string)), format_str + ) + + @visit_node.register(ops.ExtractWeekOfYear) + def visit_ExtractWeekOfYear(self, op, *, arg): + return self.f.anon.weekofyear(arg) + + @visit_node.register(ops.TimestampTruncate) + def visit_TimestampTruncate(self, op, *, arg, unit): + units = { + "Y": "YEAR", + "M": "MONTH", + "W": "WEEK", + "D": "DAY", + "h": "HOUR", + "m": "MINUTE", + "s": "SECOND", + "ms": "MILLISECONDS", + "us": "MICROSECONDS", + } + if unit.short == "Q": + return self.f.trunc(arg, "Q") + if (impala_unit := units.get(unit.short)) is None: + raise com.UnsupportedOperationError( + f"{unit!r} unit is not supported in timestamp/date truncate" + ) + return self.f.date_trunc(impala_unit, arg) + + @visit_node.register(ops.DateTruncate) + def visit_DateTruncate(self, op, *, arg, unit): + if unit.short == "Q": + return self.f.trunc(arg, "Q") + return self.f.date_trunc(unit.name.upper(), arg) + + @visit_node.register(ops.TimestampFromUNIX) + def visit_TimestampFromUNIX(self, op, *, arg, unit): + arg = self.cast(util.convert_unit(arg, unit.short, "s"), dt.int32) + return self.cast(self.f.from_unixtime(arg, "yyyy-MM-dd HH:mm:ss"), dt.timestamp) + + @visit_node.register(ops.DateAdd) + def visit_DateAdd(self, op, *, left, right): + return self.cast( + super().visit_DateAdd(op, left=self.cast(left, dt.date), right=right), + dt.date, + ) + + @visit_node.register(ops.TimestampAdd) + def visit_TimestampAdd(self, op, *, left, right): + if not isinstance(right, sge.Interval): + raise com.UnsupportedOperationError( + "right operand to timestamp add operation must be a literal" + ) + + return self.cast( + super().visit_TimestampAdd( + op, left=self.cast(left, dt.timestamp), right=right + ), + dt.timestamp, + ) + + @visit_node.register(ops.DateDiff) + def visit_DateDiff(self, op, *, left, right): + return self.f.anon.datediff(left, right) + + @visit_node.register(ops.Date) + def visit_Date(self, op, *, arg): + return self.cast(self.f.to_date(arg), dt.date) + + @visit_node.register(ops.RegexReplace) + def visit_RegexReplace(self, op, *, arg, pattern, replacement): + return self.f.regexp_replace(arg, pattern, replacement, dialect=self.dialect) + + @visit_node.register(ops.Round) + def visit_Round(self, op, *, arg, digits): + rounded = self.f.round(*filter(None, (arg, digits))) + + dtype = op.dtype + if dtype.is_integer(): + return self.cast(rounded, dtype) + return rounded + + @visit_node.register(ops.Sign) + def visit_Sign(self, op, *, arg): + sign = self.f.sign(arg) + dtype = op.dtype + if not dtype.is_float32(): + return self.cast(sign, dtype) + return sign + + @visit_node.register(ops.Arbitrary) + @visit_node.register(ops.ArgMax) + @visit_node.register(ops.ArgMin) + @visit_node.register(ops.ArrayCollect) + @visit_node.register(ops.ArrayColumn) + @visit_node.register(ops.Covariance) + @visit_node.register(ops.DateDelta) + @visit_node.register(ops.ExtractDayOfYear) + @visit_node.register(ops.First) + @visit_node.register(ops.Last) + @visit_node.register(ops.Levenshtein) + @visit_node.register(ops.Map) + @visit_node.register(ops.Median) + @visit_node.register(ops.MultiQuantile) + @visit_node.register(ops.NthValue) + @visit_node.register(ops.Quantile) + @visit_node.register(ops.RegexSplit) + @visit_node.register(ops.RowID) + @visit_node.register(ops.StringSplit) + @visit_node.register(ops.StructColumn) + @visit_node.register(ops.Time) + @visit_node.register(ops.TimeDelta) + @visit_node.register(ops.TimestampBucket) + @visit_node.register(ops.TimestampDelta) + @visit_node.register(ops.Unnest) + def visit_Undefined(self, op, **_): + raise com.OperationNotDefinedError(type(op).__name__) + +_SIMPLE_OPS = { + ops.All: "min", + ops.Any: "max", + ops.ApproxMedian: "appx_median", + ops.BaseConvert: "conv", + ops.BitwiseAnd: "bitand", + ops.BitwiseLeftShift: "shiftleft", + ops.BitwiseNot: "bitnot", + ops.BitwiseOr: "bitor", + ops.BitwiseRightShift: "shiftright", + ops.BitwiseXor: "bitxor", + ops.Cot: "cot", + ops.DayOfWeekName: "dayname", + ops.ExtractEpochSeconds: "unix_timestamp", + ops.Hash: "fnv_hash", + ops.LStrip: "ltrim", + ops.Ln: "ln", + ops.Log10: "log10", + ops.Log2: "log2", + ops.RStrip: "rtrim", + ops.Strip: "trim", + ops.TypeOf: "typeof", +} -rewrites = ImpalaExprTranslator.rewrites +for _op, _name in _SIMPLE_OPS.items(): + assert isinstance(type(_op), type), type(_op) + if issubclass(_op, ops.Reduction): + @ImpalaCompiler.visit_node.register(_op) + def _fmt(self, op, *, _name: str = _name, where, **kw): + return self.agg[_name](*kw.values(), where=where) -@rewrites(ops.FloorDivide) -def _floor_divide(op): - return ops.Floor(ops.Divide(op.left, op.right)) + else: + @ImpalaCompiler.visit_node.register(_op) + def _fmt(self, op, *, _name: str = _name, **kw): + return self.f[_name](*kw.values()) -class ImpalaCompiler(Compiler): - translator_class = ImpalaExprTranslator - table_set_formatter_class = ImpalaTableSetFormatter - rewrites = Compiler.rewrites | rewrite_sample + setattr(ImpalaCompiler, f"visit_{_op.__name__}", _fmt) - # impala supports this but sqlglot fails to parse the aliasing in - # (VALUES (a AS b)) - support_values_syntax_in_select = False +del _op, _name, _fmt diff --git a/ibis/backends/impala/tests/conftest.py b/ibis/backends/impala/tests/conftest.py index a41302f7781c..8cb150ea1988 100644 --- a/ibis/backends/impala/tests/conftest.py +++ b/ibis/backends/impala/tests/conftest.py @@ -13,7 +13,6 @@ import ibis.expr.types as ir from ibis import options, util from ibis.backends.conftest import TEST_TABLES -from ibis.backends.impala.compiler import ImpalaCompiler, ImpalaExprTranslator from ibis.backends.tests.base import BackendTest from ibis.tests.expr.mocks import MockBackend @@ -74,27 +73,29 @@ def preload(self): def _load_data(self, **_: Any) -> None: """Load test data into a backend.""" con = self.connection - con.raw_sql("CREATE DATABASE IF NOT EXISTS ibis_testing") - con.raw_sql("USE ibis_testing") + database = "ibis_testing" + + con.create_database(database, force=True) + con.raw_sql(f"USE {database}") (parquet,) = self.test_files # container path to data prefix = "/user/hive/warehouse/impala/parquet" for dir in parquet.joinpath("parquet").glob("*"): - con.raw_sql(f"DROP TABLE IF EXISTS ibis_testing.{dir.name}") + con.drop_table(dir.name, database=database, force=True) location = f"{prefix}/{dir.name}" first_file = next( itertools.chain(dir.rglob("*.parq"), dir.rglob("*.parquet")) ) - create_query = f""" - CREATE EXTERNAL TABLE IF NOT EXISTS ibis_testing.{dir.name} - LIKE PARQUET '{location}/{first_file.name}' - LOCATION '{location}' - """ - con.raw_sql(create_query) + con.parquet_file( + location, + name=dir.name, + database=database, + like_file=f"{location}/{first_file.name}", + ) con.drop_table("win", database="ibis_testing", force=True) con.create_table( @@ -123,12 +124,9 @@ def connect(*, tmpdir, worker_id, **kw): env = IbisTestEnv() return ibis.impala.connect(host=env.impala_host, port=env.impala_port, **kw) - def _get_original_column_names(self, tablename: str) -> list[str]: - return list(TEST_TABLES[tablename].names) - def _get_renamed_table(self, tablename: str) -> ir.Table: t = self.connection.table(tablename) - original_names = self._get_original_column_names(tablename) + original_names = TEST_TABLES[tablename].names return t.rename(dict(zip(original_names, t.columns))) @property @@ -155,8 +153,9 @@ def impala_port(self): @property def tmp_dir(self): + leaf = util.gen_name("impala_test_tmp_dir") options.impala.temp_path = tmp_dir = os.environ.get( - "IBIS_TEST_TMP_DIR", f"/tmp/__ibis_test_{util.guid()}" + "IBIS_TEST_TMP_DIR", f"/tmp/{leaf}" ) return tmp_dir @@ -212,7 +211,7 @@ def alltypes_df(alltypes): @pytest.fixture def temp_parquet_table_schema(): - return ibis.schema([("id", "int32"), ("name", "string"), ("files", "int32")]) + return ibis.schema(dict(id="int32", name="string", files="int32")) @pytest.fixture @@ -242,7 +241,7 @@ def kudu_table(con, test_data_db): f"""\ CREATE TABLE {test_data_db}.{name} ( a STRING, - PRIMARY KEY(a) + PRIMARY KEY (a) ) PARTITION BY HASH PARTITIONS 2 STORED AS KUDU @@ -257,8 +256,5 @@ def kudu_table(con, test_data_db): con.drop_table(name, database=test_data_db) -def translate(expr, context=None, named=False): - if context is None: - context = ImpalaCompiler.make_context() - translator = ImpalaExprTranslator(expr.op(), context=context, named=named) - return translator.get_result() +def translate(expr): + return ibis.to_sql(expr, dialect="impala") diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/first/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/first/out.sql index f0e93516a778..c6b1bb3235f9 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/first/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/first/out.sql @@ -1 +1,3 @@ -first_value(`double_col`) OVER (ORDER BY `id` ASC) \ No newline at end of file +SELECT + FIRST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC NULLS LAST) AS `First(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_arg/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_arg/out.sql index 7e778d96083a..864b3a2efb6c 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_arg/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_arg/out.sql @@ -1 +1,3 @@ -lag(`string_col`, 2) \ No newline at end of file +SELECT + LAG(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col, 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_default/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_default/out.sql index cb1f9bf529a7..9326b3b54e4c 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_default/out.sql @@ -1 +1,3 @@ -lag(`string_col`) \ No newline at end of file +SELECT + LAG(`t0`.`string_col`) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_explicit_default/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_explicit_default/out.sql index 7a389e6a3e54..1a917ebf03ae 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_explicit_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lag_explicit_default/out.sql @@ -1 +1,3 @@ -lag(`string_col`, 1, 0) \ No newline at end of file +SELECT + LAG(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col, 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/last/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/last/out.sql index 58c72df6a70b..4409732d6cf7 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/last/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/last/out.sql @@ -1 +1,3 @@ -last_value(`double_col`) OVER (ORDER BY `id` ASC) \ No newline at end of file +SELECT + LAST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC NULLS LAST) AS `Last(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_arg/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_arg/out.sql index 7427b71c5cac..0ff670b2a562 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_arg/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_arg/out.sql @@ -1 +1,3 @@ -lead(`string_col`, 2) \ No newline at end of file +SELECT + LEAD(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col, 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_default/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_default/out.sql index 72daf9f7d9d1..f2f42db96f81 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_default/out.sql @@ -1 +1,3 @@ -lead(`string_col`) \ No newline at end of file +SELECT + LEAD(`t0`.`string_col`) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_explicit_default/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_explicit_default/out.sql index 41cd162464d6..4051eb507852 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_explicit_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/lead_explicit_default/out.sql @@ -1 +1,3 @@ -lead(`string_col`, 1, 0) \ No newline at end of file +SELECT + LEAD(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col, 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/ntile/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/ntile/out.sql index e0b6514cbabc..b05add74ff76 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/ntile/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/ntile/out.sql @@ -1 +1,3 @@ -(ntile(3) OVER (ORDER BY `double_col` ASC) - 1) \ No newline at end of file +SELECT + NTILE(3) OVER (ORDER BY `t0`.`double_col` ASC NULLS LAST) - 1 AS `NTile(3)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/percent_rank/out.sql b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/percent_rank/out.sql index 5907b2c45b84..adfc11bd37a6 100644 --- a/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/percent_rank/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_analytic_functions/test_analytic_exprs/percent_rank/out.sql @@ -1 +1,3 @@ -percent_rank() OVER (ORDER BY `double_col` ASC) \ No newline at end of file +SELECT + PERCENT_RANK() OVER (ORDER BY `t0`.`double_col` ASC NULLS LAST) AS `PercentRank()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_assign_labels/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_assign_labels/out.sql index 8f4cd9c30f66..32330b60fdc9 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_assign_labels/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_assign_labels/out.sql @@ -1,20 +1,43 @@ SELECT - CASE t0.`tier` - WHEN 0 THEN 'Under 0' - WHEN 1 THEN '0 to 10' - WHEN 2 THEN '10 to 25' - WHEN 3 THEN '25 to 50' + CASE `t1`.`tier` + WHEN 0 + THEN 'Under 0' + WHEN 1 + THEN '0 to 10' + WHEN 2 + THEN '10 to 25' + WHEN 3 + THEN '25 to 50' ELSE 'error' - END AS `tier2`, t0.`CountStar(alltypes)` + END AS `tier2`, + `t1`.`CountStar()` FROM ( SELECT CASE - WHEN t1.`f` < 0 THEN 0 - WHEN (0 <= t1.`f`) AND (t1.`f` < 10) THEN 1 - WHEN (10 <= t1.`f`) AND (t1.`f` < 25) THEN 2 - WHEN (25 <= t1.`f`) AND (t1.`f` <= 50) THEN 3 - ELSE CAST(NULL AS tinyint) - END AS `tier`, count(1) AS `CountStar(alltypes)` - FROM `alltypes` t1 - GROUP BY 1 -) t0 \ No newline at end of file + WHEN `t0`.`f` < 0 + THEN 0 + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 1 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 2 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 3 + ELSE CAST(NULL AS TINYINT) + END AS `tier`, + COUNT(*) AS `CountStar()` + FROM `alltypes` AS `t0` + GROUP BY + 1 +) AS `t1` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false/out.sql index 7c9a2f700ff9..461a8aa9f242 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false/out.sql @@ -1,6 +1,23 @@ -CASE - WHEN (0 <= `f`) AND (`f` < 10) THEN 0 - WHEN (10 <= `f`) AND (`f` < 25) THEN 1 - WHEN (25 <= `f`) AND (`f` < 50) THEN 2 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 0 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 1 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` < 50 + ) + THEN 2 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_closed_right/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_closed_right/out.sql index 67290ddc413b..06537d8a9463 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_closed_right/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_closed_right/out.sql @@ -1,6 +1,23 @@ -CASE - WHEN (0 < `f`) AND (`f` <= 10) THEN 0 - WHEN (10 < `f`) AND (`f` <= 25) THEN 1 - WHEN (25 < `f`) AND (`f` <= 50) THEN 2 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN ( + 0 < `t0`.`f` + ) AND ( + `t0`.`f` <= 10 + ) + THEN 0 + WHEN ( + 10 < `t0`.`f` + ) AND ( + `t0`.`f` <= 25 + ) + THEN 1 + WHEN ( + 25 < `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 2 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_include_under_include_over/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_include_under_include_over/out.sql index b95638ae45d6..b4aa949c85a5 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_include_under_include_over/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/close_extreme_false_include_under_include_over/out.sql @@ -1,8 +1,27 @@ -CASE - WHEN `f` < 0 THEN 0 - WHEN (0 <= `f`) AND (`f` < 10) THEN 1 - WHEN (10 <= `f`) AND (`f` < 25) THEN 2 - WHEN (25 <= `f`) AND (`f` < 50) THEN 3 - WHEN 50 <= `f` THEN 4 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` < 0 + THEN 0 + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 1 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 2 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` < 50 + ) + THEN 3 + WHEN 50 <= `t0`.`f` + THEN 4 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right/out.sql index 78811483e16c..cf3f70f2d673 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right/out.sql @@ -1,6 +1,23 @@ -CASE - WHEN (0 <= `f`) AND (`f` <= 10) THEN 0 - WHEN (10 < `f`) AND (`f` <= 25) THEN 1 - WHEN (25 < `f`) AND (`f` <= 50) THEN 2 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` <= 10 + ) + THEN 0 + WHEN ( + 10 < `t0`.`f` + ) AND ( + `t0`.`f` <= 25 + ) + THEN 1 + WHEN ( + 25 < `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 2 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_close_extreme_false_include_under/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_close_extreme_false_include_under/out.sql index 1d254824f5c4..d59ea7900f17 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_close_extreme_false_include_under/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_close_extreme_false_include_under/out.sql @@ -1,7 +1,25 @@ -CASE - WHEN `f` <= 0 THEN 0 - WHEN (0 < `f`) AND (`f` <= 10) THEN 1 - WHEN (10 < `f`) AND (`f` <= 25) THEN 2 - WHEN (25 < `f`) AND (`f` <= 50) THEN 3 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` <= 0 + THEN 0 + WHEN ( + 0 < `t0`.`f` + ) AND ( + `t0`.`f` <= 10 + ) + THEN 1 + WHEN ( + 10 < `t0`.`f` + ) AND ( + `t0`.`f` <= 25 + ) + THEN 2 + WHEN ( + 25 < `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 3 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_include_over_include_under/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_include_over_include_under/out.sql index 1649d97034ea..b0f5158c750d 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_include_over_include_under/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/closed_right_include_over_include_under/out.sql @@ -1,5 +1,9 @@ -CASE - WHEN `f` <= 10 THEN 0 - WHEN 10 < `f` THEN 1 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` <= 10 + THEN 0 + WHEN 10 < `t0`.`f` + THEN 1 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/default/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/default/out.sql index ca91f0ba81e1..c9ab2234f883 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/default/out.sql @@ -1,6 +1,23 @@ -CASE - WHEN (0 <= `f`) AND (`f` < 10) THEN 0 - WHEN (10 <= `f`) AND (`f` < 25) THEN 1 - WHEN (25 <= `f`) AND (`f` <= 50) THEN 2 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 0 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 1 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 2 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under0/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under0/out.sql index 1901aa775e98..e6e63f334c08 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under0/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under0/out.sql @@ -1,5 +1,9 @@ -CASE - WHEN `f` < 10 THEN 0 - WHEN 10 <= `f` THEN 1 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` < 10 + THEN 0 + WHEN 10 <= `t0`.`f` + THEN 1 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under1/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under1/out.sql index 0dae0d0438ab..104dcc83014a 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under1/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under1/out.sql @@ -1,5 +1,9 @@ -CAST(CASE - WHEN `f` < 10 THEN 0 - WHEN 10 <= `f` THEN 1 - ELSE CAST(NULL AS tinyint) -END AS int) \ No newline at end of file +SELECT + CAST(CASE + WHEN `t0`.`f` < 10 + THEN 0 + WHEN 10 <= `t0`.`f` + THEN 1 + ELSE CAST(NULL AS TINYINT) + END AS INT) AS `Cast(Bucket(f), int32)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under2/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under2/out.sql index 5b95c1b7cdca..f4661b51024a 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_over_include_under2/out.sql @@ -1,5 +1,9 @@ -CAST(CASE - WHEN `f` < 10 THEN 0 - WHEN 10 <= `f` THEN 1 - ELSE CAST(NULL AS tinyint) -END AS double) \ No newline at end of file +SELECT + CAST(CASE + WHEN `t0`.`f` < 10 + THEN 0 + WHEN 10 <= `t0`.`f` + THEN 1 + ELSE CAST(NULL AS TINYINT) + END AS DOUBLE) AS `Cast(Bucket(f), float64)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under/out.sql index 30b0a9823016..39a83640fe1b 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under/out.sql @@ -1,7 +1,25 @@ -CASE - WHEN `f` < 0 THEN 0 - WHEN (0 <= `f`) AND (`f` < 10) THEN 1 - WHEN (10 <= `f`) AND (`f` < 25) THEN 2 - WHEN (25 <= `f`) AND (`f` <= 50) THEN 3 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` < 0 + THEN 0 + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 1 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 2 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 3 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under_include_over/out.sql b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under_include_over/out.sql index 79a328c92a52..0dda250e0ef1 100644 --- a/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under_include_over/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_bucket_histogram/test_bucket_to_case/include_under_include_over/out.sql @@ -1,8 +1,27 @@ -CASE - WHEN `f` < 0 THEN 0 - WHEN (0 <= `f`) AND (`f` < 10) THEN 1 - WHEN (10 <= `f`) AND (`f` < 25) THEN 2 - WHEN (25 <= `f`) AND (`f` <= 50) THEN 3 - WHEN 50 < `f` THEN 4 - ELSE CAST(NULL AS tinyint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` < 0 + THEN 0 + WHEN ( + 0 <= `t0`.`f` + ) AND ( + `t0`.`f` < 10 + ) + THEN 1 + WHEN ( + 10 <= `t0`.`f` + ) AND ( + `t0`.`f` < 25 + ) + THEN 2 + WHEN ( + 25 <= `t0`.`f` + ) AND ( + `t0`.`f` <= 50 + ) + THEN 3 + WHEN 50 < `t0`.`f` + THEN 4 + ELSE CAST(NULL AS TINYINT) + END AS `Bucket(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice/out.sql index 18d4d73cf05a..4890dcc7d096 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice/out.sql @@ -1 +1,3 @@ -coalesce(`l_extendedprice`, 0) \ No newline at end of file +SELECT + COALESCE(`t0`.`l_extendedprice`, 0) AS `Coalesce()` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice_double/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice_double/out.sql index bb6d9e6dc505..59bd466502bc 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice_double/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_extendedprice_double/out.sql @@ -1 +1,3 @@ -coalesce(`l_extendedprice`, 0.0) \ No newline at end of file +SELECT + COALESCE(`t0`.`l_extendedprice`, 0.0) AS `Coalesce()` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_quantity/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_quantity/out.sql index 38e98e3285da..3fa2c6486406 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_quantity/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_decimal_fillna_cast_arg/fillna_l_quantity/out.sql @@ -1 +1,3 @@ -coalesce(`l_quantity`, 0) \ No newline at end of file +SELECT + COALESCE(`t0`.`l_quantity`, 0) AS `Coalesce()` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to/out.sql index 0565bc3ad7b2..4ec0618d6bde 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to/out.sql @@ -1,2 +1,3 @@ -SELECT t0.`tinyint_col` IS NOT DISTINCT FROM t0.`double_col` AS `tmp` -FROM `functional_alltypes` t0 \ No newline at end of file +SELECT + `t0`.`tinyint_col` IS NOT DISTINCT FROM `t0`.`double_col` AS `tmp` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to_special_case/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to_special_case/out.sql index cc71612458b0..48da5cb117bb 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to_special_case/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_identical_to_special_case/out.sql @@ -1 +1,2 @@ -SELECT TRUE AS `tmp` \ No newline at end of file +SELECT + CAST(NULL AS BIGINT) IS NOT DISTINCT FROM CAST(NULL AS BIGINT) AS `tmp` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_ifelse_use_if/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_ifelse_use_if/out.sql index d82567438333..27e2ebb44fab 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_ifelse_use_if/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_ifelse_use_if/out.sql @@ -1 +1,3 @@ -if(`f` > 0, `e`, `a`) \ No newline at end of file +SELECT + IF(`t0`.`f` > 0, `t0`.`e`, `t0`.`a`) AS `IfElse(Greater(f, 0), e, a)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out1.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out1.sql index 25cdb744423b..9cb074f3c97d 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out1.sql @@ -1 +1,3 @@ -if(`g` IS NULL, 1, 0) \ No newline at end of file +SELECT + IF(`t0`.`g` IS NULL, 1, 0) AS `IfElse(IsNull(g), 1, 0)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out2.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out2.sql index eeff1bc1fe6f..03c9edf98286 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_isnull_1_0/out2.sql @@ -1 +1,3 @@ -sum(if(`g` IS NULL, 1, 0)) \ No newline at end of file +SELECT + SUM(IF(`t0`.`g` IS NULL, 1, 0)) AS `Sum(IfElse(IsNull(g), 1, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_boolean/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_boolean/out.sql index 540ae2672d19..fefaae99655a 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_boolean/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_boolean/out.sql @@ -1 +1,3 @@ -nullif(`l_quantity` = 0, `l_quantity` = 0) \ No newline at end of file +SELECT + NULLIF(`t0`.`l_quantity` = 0, `t0`.`l_quantity` = 0) AS `NullIf(Equals(l_quantity, 0), Equals(l_quantity, 0))` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_input/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_input/out.sql index 54e0e8065bb4..dadef905f39d 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_input/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_input/out.sql @@ -1 +1,3 @@ -nullif(`l_quantity`, `l_quantity`) \ No newline at end of file +SELECT + NULLIF(`t0`.`l_quantity`, `t0`.`l_quantity`) AS `NullIf(l_quantity, l_quantity)` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_negate_boolean/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_negate_boolean/out.sql index a79bfc504605..5a986e7ddb3e 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_negate_boolean/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_nullif_ifnull/nullif_negate_boolean/out.sql @@ -1 +1,3 @@ -nullif(`l_quantity` != 0, `l_quantity` = 0) \ No newline at end of file +SELECT + NULLIF(`t0`.`l_quantity` <> 0, `t0`.`l_quantity` = 0) AS `NullIf(NotEquals(l_quantity, 0), Equals(l_quantity, 0))` +FROM `tpch_lineitem` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_search_case/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_search_case/out.sql index f4ee943f9d48..086867ecdd77 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_search_case/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_search_case/out.sql @@ -1,5 +1,9 @@ -CASE - WHEN `f` > 0 THEN `d` * 2 - WHEN `c` < 0 THEN `a` * 2 - ELSE CAST(NULL AS bigint) -END \ No newline at end of file +SELECT + CASE + WHEN `t0`.`f` > 0 + THEN `t0`.`d` * 2 + WHEN `t0`.`c` < 0 + THEN `t0`.`a` * 2 + ELSE CAST(NULL AS BIGINT) + END AS `SearchedCase(Cast(None, int64))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_simple_case/out.sql b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_simple_case/out.sql index 56a1c8ac9b31..bb9300299c72 100644 --- a/ibis/backends/impala/tests/snapshots/test_case_exprs/test_simple_case/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_case_exprs/test_simple_case/out.sql @@ -1,5 +1,3 @@ -CASE `g` - WHEN 'foo' THEN 'bar' - WHEN 'baz' THEN 'qux' - ELSE 'default' -END \ No newline at end of file +SELECT + CASE `t0`.`g` WHEN 'foo' THEN 'bar' WHEN 'baz' THEN 'qux' ELSE 'default' END AS `SimpleCase(g, 'default')` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_columns/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_columns/out.sql index 11470952abab..37a2675f2b39 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_columns/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_columns/out.sql @@ -1 +1,3 @@ -coalesce(`int_col`, `bigint_col`) \ No newline at end of file +SELECT + COALESCE(`t0`.`int_col`, `t0`.`bigint_col`) AS `Coalesce()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_scalar/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_scalar/out.sql index 7d545f322a6f..d0f093f98b7a 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_scalar/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/coalesce_scalar/out.sql @@ -1 +1,3 @@ -coalesce(`string_col`, 'foo') \ No newline at end of file +SELECT + COALESCE(`t0`.`string_col`, 'foo') AS `Coalesce()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_columns/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_columns/out.sql index 82e0083716de..d667c8a69296 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_columns/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_columns/out.sql @@ -1 +1,3 @@ -greatest(`int_col`, `bigint_col`) \ No newline at end of file +SELECT + GREATEST(`t0`.`int_col`, `t0`.`bigint_col`) AS `Greatest()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_scalar/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_scalar/out.sql index 98df465a098c..693db916250b 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_scalar/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/greatest_scalar/out.sql @@ -1 +1,3 @@ -greatest(`string_col`, 'foo') \ No newline at end of file +SELECT + GREATEST(`t0`.`string_col`, 'foo') AS `Greatest()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_columns/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_columns/out.sql index 4458c9aee386..90f4b2d35f1c 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_columns/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_columns/out.sql @@ -1 +1,3 @@ -least(`int_col`, `bigint_col`) \ No newline at end of file +SELECT + LEAST(`t0`.`int_col`, `t0`.`bigint_col`) AS `Least()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_scalar/out.sql b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_scalar/out.sql index 563206d70430..8260947a866e 100644 --- a/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_scalar/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_coalesce_greater_least/test_varargs_functions/least_scalar/out.sql @@ -1 +1,3 @@ -least(`string_col`, 'foo') \ No newline at end of file +SELECT + LEAST(`t0`.`string_col`, 'foo') AS `Least()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_avro_other_formats/out.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_avro_other_formats/out.sql index 0609f60905c4..da51b1c54307 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_avro_other_formats/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_avro_other_formats/out.sql @@ -1,5 +1,6 @@ CREATE TABLE IF NOT EXISTS `tname` STORED AS AVRO AS -SELECT t0.* -FROM `functional_alltypes` t0 \ No newline at end of file +SELECT + * +FROM `functional_alltypes` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_external_table_as/out.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_external_table_as/out.sql index ce648de38dd2..273b2045aa34 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_external_table_as/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_external_table_as/out.sql @@ -2,5 +2,6 @@ CREATE EXTERNAL TABLE `foo`.`another_table` STORED AS PARQUET LOCATION '/path/to/table' AS -SELECT t0.* -FROM `test1` t0 \ No newline at end of file +SELECT + * +FROM `test1` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_table_parquet/out.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_table_parquet/out.sql index 9eb1ba2b3ea6..c786bd23a9a3 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_table_parquet/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_create_table_parquet/out.sql @@ -1,6 +1,20 @@ CREATE TABLE `bar`.`some_table` STORED AS PARQUET AS -SELECT t0.* -FROM `functional_alltypes` t0 -WHERE t0.`bigint_col` > 0 \ No newline at end of file +SELECT + `t0`.`id`, + `t0`.`bool_col`, + `t0`.`tinyint_col`, + `t0`.`smallint_col`, + `t0`.`int_col`, + `t0`.`bigint_col`, + `t0`.`float_col`, + `t0`.`double_col`, + `t0`.`date_string_col`, + `t0`.`string_col`, + `t0`.`timestamp_col`, + `t0`.`year`, + `t0`.`month` +FROM `functional_alltypes` AS `t0` +WHERE + `t0`.`bigint_col` > 0 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_no_overwrite/out.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_no_overwrite/out.sql index 22dbd3b0ec32..21655b333d8f 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_no_overwrite/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_no_overwrite/out.sql @@ -1,6 +1,20 @@ CREATE TABLE IF NOT EXISTS `tname` STORED AS PARQUET AS -SELECT t0.* -FROM `functional_alltypes` t0 -WHERE t0.`bigint_col` > 0 \ No newline at end of file +SELECT + `t0`.`id`, + `t0`.`bool_col`, + `t0`.`tinyint_col`, + `t0`.`smallint_col`, + `t0`.`int_col`, + `t0`.`bigint_col`, + `t0`.`float_col`, + `t0`.`double_col`, + `t0`.`date_string_col`, + `t0`.`string_col`, + `t0`.`timestamp_col`, + `t0`.`year`, + `t0`.`month` +FROM `functional_alltypes` AS `t0` +WHERE + `t0`.`bigint_col` > 0 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out1.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out1.sql index 38de0f178cfd..7a42f5244dd1 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out1.sql @@ -1,4 +1,5 @@ INSERT INTO `foo`.`testing123456` -SELECT t0.* -FROM `functional_alltypes` t0 +SELECT + * +FROM `functional_alltypes` AS `t0` LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out2.sql b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out2.sql index 32eb8fd6e9e9..6dcec22f28c0 100644 --- a/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_ddl_compilation/test_select_basics/out2.sql @@ -1,4 +1,5 @@ INSERT OVERWRITE `foo`.`testing123456` -SELECT t0.* -FROM `functional_alltypes` t0 +SELECT + * +FROM `functional_alltypes` AS `t0` LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_exprs/test_filter_with_analytic/out.sql b/ibis/backends/impala/tests/snapshots/test_exprs/test_filter_with_analytic/out.sql index 22bce18c3ec9..3174e14dfa1e 100644 --- a/ibis/backends/impala/tests/snapshots/test_exprs/test_filter_with_analytic/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_exprs/test_filter_with_analytic/out.sql @@ -1,18 +1,16 @@ -WITH t0 AS ( - SELECT t4.`col`, NULL AS `filter` - FROM `x` t4 -), -t1 AS ( - SELECT t0.* - FROM t0 - WHERE t0.`filter` IS NULL -), -t2 AS ( - SELECT t1.`col`, t1.`filter` - FROM t1 -) -SELECT t3.`col`, t3.`analytic` +SELECT + `t2`.`col`, + `t2`.`analytic` FROM ( - SELECT t2.`col`, count(1) OVER () AS `analytic` - FROM t2 -) t3 \ No newline at end of file + SELECT + `t1`.`col`, + COUNT(*) OVER (ORDER BY NULL ASC NULLS LAST) AS `analytic` + FROM ( + SELECT + `t0`.`col`, + NULL AS `filter` + FROM `x` AS `t0` + WHERE + NULL IS NULL + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/abc.sql b/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/abc.sql index c283f69194a7..084d6ae3fcc9 100644 --- a/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/abc.sql +++ b/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/abc.sql @@ -1,4 +1,17 @@ -SELECT t0.`key`, sum(((t0.`value` + 1) + 2) + 3) AS `abc` -FROM `t0` t0 -WHERE t0.`value` = 42 -GROUP BY 1 \ No newline at end of file +SELECT + `t1`.`key`, + SUM(( + ( + `t1`.`value` + 1 + ) + 2 + ) + 3) AS `abc` +FROM ( + SELECT + `t0`.`key`, + `t0`.`value` + FROM `t0` AS `t0` + WHERE + `t0`.`value` = 42 +) AS `t1` +GROUP BY + 1 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/foo.sql b/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/foo.sql index 7dbaca888a9f..e49a2c885636 100644 --- a/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/foo.sql +++ b/ibis/backends/impala/tests/snapshots/test_exprs/test_named_from_filter_group_by/foo.sql @@ -1,4 +1,17 @@ -SELECT t0.`key`, sum(((t0.`value` + 1) + 2) + 3) AS `foo` -FROM `t0` t0 -WHERE t0.`value` = 42 -GROUP BY 1 \ No newline at end of file +SELECT + `t1`.`key`, + SUM(( + ( + `t1`.`value` + 1 + ) + 2 + ) + 3) AS `foo` +FROM ( + SELECT + `t0`.`key`, + `t0`.`value` + FROM `t0` AS `t0` + WHERE + `t0`.`value` = 42 +) AS `t1` +GROUP BY + 1 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_exprs/test_nunique_where/out.sql b/ibis/backends/impala/tests/snapshots/test_exprs/test_nunique_where/out.sql index df7409ce4a9b..b9962ec6e33c 100644 --- a/ibis/backends/impala/tests/snapshots/test_exprs/test_nunique_where/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_exprs/test_nunique_where/out.sql @@ -1,2 +1,3 @@ -SELECT count(DISTINCT if(t0.`value` >= 1.0, t0.`key`, NULL)) AS `CountDistinct(key, GreaterEqual(value, 1.0))` -FROM `t0` t0 \ No newline at end of file +SELECT + COUNT(DISTINCT IF(`t0`.`value` >= 1.0, `t0`.`key`, NULL)) AS `CountDistinct(key, GreaterEqual(value, 1.0))` +FROM `t0` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_exprs/test_where_with_timestamp/out.sql b/ibis/backends/impala/tests/snapshots/test_exprs/test_where_with_timestamp/out.sql index b812ca961326..9265a674c3c3 100644 --- a/ibis/backends/impala/tests/snapshots/test_exprs/test_where_with_timestamp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_exprs/test_where_with_timestamp/out.sql @@ -1,3 +1,6 @@ -SELECT t0.`uuid`, min(if(t0.`search_level` = 1, t0.`ts`, NULL)) AS `min_date` -FROM `t` t0 -GROUP BY 1 \ No newline at end of file +SELECT + `t0`.`uuid`, + MIN(IF(`t0`.`search_level` = 1, `t0`.`ts`, NULL)) AS `min_date` +FROM `t` AS `t0` +GROUP BY + 1 \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/isin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/isin/out.sql index ac7a1c815743..d0c44759597f 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/isin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/isin/out.sql @@ -1 +1,3 @@ -`g` IN ('foo', 'bar', 'baz') \ No newline at end of file +SELECT + `t0`.`g` IN ('foo', 'bar', 'baz') AS `InValues(g)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/notin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/notin/out.sql index 38443dc2a049..1962710dd06e 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/notin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_field_in_literals/notin/out.sql @@ -1 +1,5 @@ -NOT `g` IN ('foo', 'bar', 'baz') \ No newline at end of file +SELECT + NOT ( + `t0`.`g` IN ('foo', 'bar', 'baz') + ) AS `Not(InValues(g))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/isin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/isin/out.sql index c407478b5bc8..4a7728cdd59e 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/isin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/isin/out.sql @@ -1,3 +1,15 @@ -SELECT t0.* -FROM `alltypes` t0 -WHERE t0.`g` IN ('foo', 'bar') \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k` +FROM `alltypes` AS `t0` +WHERE + `t0`.`g` IN ('foo', 'bar') \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/notin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/notin/out.sql index 64e7f906868c..164b3a38338e 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/notin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_isin_notin_in_select/notin/out.sql @@ -1,3 +1,17 @@ -SELECT t0.* -FROM `alltypes` t0 -WHERE NOT t0.`g` IN ('foo', 'bar') \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k` +FROM `alltypes` AS `t0` +WHERE + NOT ( + `t0`.`g` IN ('foo', 'bar') + ) \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/isin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/isin/out.sql index 24cb73205760..5e82e8ab1e24 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/isin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/isin/out.sql @@ -1 +1,3 @@ -2 IN (`a`, `b`, `c`) \ No newline at end of file +SELECT + 2 IN (`t0`.`a`, `t0`.`b`, `t0`.`c`) AS `InValues(2)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/notin/out.sql b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/notin/out.sql index ca2178c7fcd7..5eb7de11190a 100644 --- a/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/notin/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_in_not_in/test_literal_in_fields/notin/out.sql @@ -1 +1,5 @@ -NOT 2 IN (`a`, `b`, `c`) \ No newline at end of file +SELECT + NOT ( + 2 IN (`t0`.`a`, `t0`.`b`, `t0`.`c`) + ) AS `Not(InValues(2))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_group_by_with_window_preserves_range/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_group_by_with_window_preserves_range/out.sql index a0de577d9d19..28c6528bec63 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_group_by_with_window_preserves_range/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_group_by_with_window_preserves_range/out.sql @@ -1,3 +1,6 @@ -SELECT t0.*, - sum(t0.`two`) OVER (PARTITION BY t0.`three` ORDER BY t0.`one` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `four` -FROM `my_data` t0 \ No newline at end of file +SELECT + `t0`.`one`, + `t0`.`two`, + `t0`.`three`, + SUM(`t0`.`two`) OVER (PARTITION BY `t0`.`three` ORDER BY `t0`.`one` ASC NULLS LAST) AS `four` +FROM `my_data` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/isnull/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/isnull/out.sql index 6dcf3cf96553..034d6a342694 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/isnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/isnull/out.sql @@ -1,3 +1,6 @@ -SELECT t0.* -FROM `table` t0 -WHERE (t0.`a` IS NULL) = (t0.`b` IS NULL) \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b` +FROM `table` AS `t0` +WHERE + `t0`.`a` IS NULL = `t0`.`b` IS NULL \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/notnull/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/notnull/out.sql index 7ab93d396b71..e34061596c65 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/notnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens/notnull/out.sql @@ -1,3 +1,6 @@ -SELECT t0.* -FROM `table` t0 -WHERE (t0.`a` IS NOT NULL) = (t0.`b` IS NOT NULL) \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b` +FROM `table` AS `t0` +WHERE + NOT `t0`.`a` IS NULL = NOT `t0`.`b` IS NULL \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens_identical_to/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens_identical_to/out.sql index a596fec7d727..9080afdaec50 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens_identical_to/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_is_parens_identical_to/out.sql @@ -1,3 +1,6 @@ -SELECT t0.* -FROM `table` t0 -WHERE (t0.`a` IS NOT DISTINCT FROM NULL) = (t0.`b` IS NOT DISTINCT FROM NULL) \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b` +FROM `table` AS `t0` +WHERE + `t0`.`a` IS NOT DISTINCT FROM NULL = `t0`.`b` IS NOT DISTINCT FROM NULL \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_aliasing/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_aliasing/out.sql index 125984a40369..e74367136685 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_aliasing/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_aliasing/out.sql @@ -1,39 +1,87 @@ -WITH t0 AS ( - SELECT t7.*, t7.`a` + 20 AS `d` - FROM `test_table` t7 -), -t1 AS ( - SELECT t0.`d`, t0.`c` - FROM t0 -), -t2 AS ( - SELECT t1.`d`, CAST(t1.`d` / 15 AS bigint) AS `idx`, t1.`c`, - count(1) AS `row_count` - FROM t1 - GROUP BY 1, 2, 3 -), -t3 AS ( - SELECT t2.`d`, sum(t2.`row_count`) AS `total` - FROM t2 - GROUP BY 1 -), -t4 AS ( - SELECT t2.*, t3.`total` - FROM t2 - INNER JOIN t3 - ON t2.`d` = t3.`d` -), -t5 AS ( - SELECT t4.* - FROM t4 - WHERE t4.`row_count` < (t4.`total` / 2) -) -SELECT t6.*, t5.`total` +SELECT + `t6`.`d`, + `t6`.`b`, + `t6`.`count`, + `t6`.`unique`, + `t13`.`total` FROM ( - SELECT t0.`d`, t0.`b`, count(1) AS `count`, - count(DISTINCT t0.`c`) AS `unique` - FROM t0 - GROUP BY 1, 2 -) t6 - INNER JOIN t5 - ON t6.`d` = t5.`d` \ No newline at end of file + SELECT + `t1`.`d`, + `t1`.`b`, + COUNT(*) AS `count`, + COUNT(DISTINCT `t1`.`c`) AS `unique` + FROM ( + SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`a` + 20 AS `d` + FROM `test_table` AS `t0` + ) AS `t1` + GROUP BY + 1, + 2 +) AS `t6` +INNER JOIN ( + SELECT + `t11`.`d`, + `t11`.`idx`, + `t11`.`c`, + `t11`.`row_count`, + `t11`.`total` + FROM ( + SELECT + `t7`.`d`, + `t7`.`idx`, + `t7`.`c`, + `t7`.`row_count`, + `t9`.`total` + FROM ( + SELECT + `t2`.`d`, + CAST(`t2`.`d` / 15 AS BIGINT) AS `idx`, + `t2`.`c`, + COUNT(*) AS `row_count` + FROM ( + SELECT + `t0`.`a` + 20 AS `d`, + `t0`.`c` + FROM `test_table` AS `t0` + ) AS `t2` + GROUP BY + 1, + 2, + 3 + ) AS `t7` + INNER JOIN ( + SELECT + `t5`.`d`, + SUM(`t5`.`row_count`) AS `total` + FROM ( + SELECT + `t2`.`d`, + CAST(`t2`.`d` / 15 AS BIGINT) AS `idx`, + `t2`.`c`, + COUNT(*) AS `row_count` + FROM ( + SELECT + `t0`.`a` + 20 AS `d`, + `t0`.`c` + FROM `test_table` AS `t0` + ) AS `t2` + GROUP BY + 1, + 2, + 3 + ) AS `t5` + GROUP BY + 1 + ) AS `t9` + ON `t7`.`d` = `t9`.`d` + ) AS `t11` + WHERE + `t11`.`row_count` < ( + `t11`.`total` / 2 + ) +) AS `t13` + ON `t6`.`d` = `t13`.`d` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name/out.sql index 4bb710c4adae..865f638ff542 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name/out.sql @@ -1,32 +1,118 @@ -WITH t0 AS ( - SELECT t5.*, t3.`r_name` AS `region`, t6.`o_totalprice`, - CAST(t6.`o_orderdate` AS timestamp) AS `odate` - FROM `tpch_region` t3 - INNER JOIN `tpch_nation` t4 - ON t3.`r_regionkey` = t4.`n_regionkey` - INNER JOIN `tpch_customer` t5 - ON t5.`c_nationkey` = t4.`n_nationkey` - INNER JOIN `tpch_orders` t6 - ON t6.`o_custkey` = t5.`c_custkey` -), -t1 AS ( - SELECT extract(t0.`odate`, 'year') AS `year`, count(1) AS `CountStar()` - FROM t0 - WHERE t0.`o_totalprice` > ( - SELECT avg(t3.`o_totalprice`) AS `Mean(o_totalprice)` - FROM t0 t3 - WHERE t3.`region` = t0.`region` - ) - GROUP BY 1 -), -t2 AS ( - SELECT extract(t0.`odate`, 'year') AS `year`, count(1) AS `CountStar()` - FROM t0 - GROUP BY 1 -) -SELECT t2.`year`, t2.`CountStar()` AS `pre_count`, - t1.`CountStar()` AS `post_count`, - t1.`CountStar()` / CAST(t2.`CountStar()` AS double) AS `fraction` -FROM t2 - INNER JOIN t1 - ON t2.`year` = t1.`year` \ No newline at end of file +SELECT + `t14`.`year`, + `t14`.`CountStar()` AS `pre_count`, + `t19`.`CountStar()` AS `post_count`, + `t19`.`CountStar()` / CAST(`t14`.`CountStar()` AS DOUBLE) AS `fraction` +FROM ( + SELECT + EXTRACT(year FROM `t11`.`odate`) AS `year`, + COUNT(*) AS `CountStar()` + FROM ( + SELECT + `t6`.`c_custkey`, + `t6`.`c_name`, + `t6`.`c_address`, + `t6`.`c_nationkey`, + `t6`.`c_phone`, + `t6`.`c_acctbal`, + `t6`.`c_mktsegment`, + `t6`.`c_comment`, + `t4`.`r_name` AS `region`, + `t7`.`o_totalprice`, + CAST(`t7`.`o_orderdate` AS TIMESTAMP) AS `odate` + FROM `tpch_region` AS `t4` + INNER JOIN `tpch_nation` AS `t5` + ON `t4`.`r_regionkey` = `t5`.`n_regionkey` + INNER JOIN `tpch_customer` AS `t6` + ON `t6`.`c_nationkey` = `t5`.`n_nationkey` + INNER JOIN `tpch_orders` AS `t7` + ON `t7`.`o_custkey` = `t6`.`c_custkey` + ) AS `t11` + GROUP BY + 1 +) AS `t14` +INNER JOIN ( + SELECT + EXTRACT(year FROM `t17`.`odate`) AS `year`, + COUNT(*) AS `CountStar()` + FROM ( + SELECT + `t11`.`c_custkey`, + `t11`.`c_name`, + `t11`.`c_address`, + `t11`.`c_nationkey`, + `t11`.`c_phone`, + `t11`.`c_acctbal`, + `t11`.`c_mktsegment`, + `t11`.`c_comment`, + `t11`.`region`, + `t11`.`o_totalprice`, + `t11`.`odate` + FROM ( + SELECT + `t6`.`c_custkey`, + `t6`.`c_name`, + `t6`.`c_address`, + `t6`.`c_nationkey`, + `t6`.`c_phone`, + `t6`.`c_acctbal`, + `t6`.`c_mktsegment`, + `t6`.`c_comment`, + `t4`.`r_name` AS `region`, + `t7`.`o_totalprice`, + CAST(`t7`.`o_orderdate` AS TIMESTAMP) AS `odate` + FROM `tpch_region` AS `t4` + INNER JOIN `tpch_nation` AS `t5` + ON `t4`.`r_regionkey` = `t5`.`n_regionkey` + INNER JOIN `tpch_customer` AS `t6` + ON `t6`.`c_nationkey` = `t5`.`n_nationkey` + INNER JOIN `tpch_orders` AS `t7` + ON `t7`.`o_custkey` = `t6`.`c_custkey` + ) AS `t11` + WHERE + `t11`.`o_totalprice` > ( + SELECT + AVG(`t15`.`o_totalprice`) AS `Mean(o_totalprice)` + FROM ( + SELECT + `t12`.`c_custkey`, + `t12`.`c_name`, + `t12`.`c_address`, + `t12`.`c_nationkey`, + `t12`.`c_phone`, + `t12`.`c_acctbal`, + `t12`.`c_mktsegment`, + `t12`.`c_comment`, + `t12`.`region`, + `t12`.`o_totalprice`, + `t12`.`odate` + FROM ( + SELECT + `t6`.`c_custkey`, + `t6`.`c_name`, + `t6`.`c_address`, + `t6`.`c_nationkey`, + `t6`.`c_phone`, + `t6`.`c_acctbal`, + `t6`.`c_mktsegment`, + `t6`.`c_comment`, + `t4`.`r_name` AS `region`, + `t7`.`o_totalprice`, + CAST(`t7`.`o_orderdate` AS TIMESTAMP) AS `odate` + FROM `tpch_region` AS `t4` + INNER JOIN `tpch_nation` AS `t5` + ON `t4`.`r_regionkey` = `t5`.`n_regionkey` + INNER JOIN `tpch_customer` AS `t6` + ON `t6`.`c_nationkey` = `t5`.`n_nationkey` + INNER JOIN `tpch_orders` AS `t7` + ON `t7`.`o_custkey` = `t6`.`c_custkey` + ) AS `t12` + WHERE + `t12`.`region` = `t11`.`region` + ) AS `t15` + ) + ) AS `t17` + GROUP BY + 1 +) AS `t19` + ON `t14`.`year` = `t19`.`year` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name2/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name2/out.sql index 7063b0417815..5d6f63cb5b69 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name2/out.sql @@ -1,21 +1,61 @@ -WITH t0 AS ( - SELECT t5.*, t3.`r_name` AS `region`, t6.`o_totalprice`, - CAST(t6.`o_orderdate` AS timestamp) AS `odate` - FROM `tpch_region` t3 - INNER JOIN `tpch_nation` t4 - ON t3.`r_regionkey` = t4.`n_regionkey` - INNER JOIN `tpch_customer` t5 - ON t5.`c_nationkey` = t4.`n_nationkey` - INNER JOIN `tpch_orders` t6 - ON t6.`o_custkey` = t5.`c_custkey` -), -t1 AS ( - SELECT extract(t0.`odate`, 'year') AS `year`, count(1) AS `CountStar()` - FROM t0 - GROUP BY 1 -) -SELECT t1.`year`, t1.`CountStar()` AS `pre_count`, - t2.`CountStar()` AS `post_count` -FROM t1 - INNER JOIN t1 t2 - ON t1.`year` = t2.`year` \ No newline at end of file +SELECT + `t13`.`year`, + `t13`.`CountStar()` AS `pre_count`, + `t15`.`CountStar()` AS `post_count` +FROM ( + SELECT + EXTRACT(year FROM `t11`.`odate`) AS `year`, + COUNT(*) AS `CountStar()` + FROM ( + SELECT + `t6`.`c_custkey`, + `t6`.`c_name`, + `t6`.`c_address`, + `t6`.`c_nationkey`, + `t6`.`c_phone`, + `t6`.`c_acctbal`, + `t6`.`c_mktsegment`, + `t6`.`c_comment`, + `t4`.`r_name` AS `region`, + `t7`.`o_totalprice`, + CAST(`t7`.`o_orderdate` AS TIMESTAMP) AS `odate` + FROM `tpch_region` AS `t4` + INNER JOIN `tpch_nation` AS `t5` + ON `t4`.`r_regionkey` = `t5`.`n_regionkey` + INNER JOIN `tpch_customer` AS `t6` + ON `t6`.`c_nationkey` = `t5`.`n_nationkey` + INNER JOIN `tpch_orders` AS `t7` + ON `t7`.`o_custkey` = `t6`.`c_custkey` + ) AS `t11` + GROUP BY + 1 +) AS `t13` +INNER JOIN ( + SELECT + EXTRACT(year FROM `t11`.`odate`) AS `year`, + COUNT(*) AS `CountStar()` + FROM ( + SELECT + `t6`.`c_custkey`, + `t6`.`c_name`, + `t6`.`c_address`, + `t6`.`c_nationkey`, + `t6`.`c_phone`, + `t6`.`c_acctbal`, + `t6`.`c_mktsegment`, + `t6`.`c_comment`, + `t4`.`r_name` AS `region`, + `t7`.`o_totalprice`, + CAST(`t7`.`o_orderdate` AS TIMESTAMP) AS `odate` + FROM `tpch_region` AS `t4` + INNER JOIN `tpch_nation` AS `t5` + ON `t4`.`r_regionkey` = `t5`.`n_regionkey` + INNER JOIN `tpch_customer` AS `t6` + ON `t6`.`c_nationkey` = `t5`.`n_nationkey` + INNER JOIN `tpch_orders` AS `t7` + ON `t7`.`o_custkey` = `t6`.`c_custkey` + ) AS `t11` + GROUP BY + 1 +) AS `t15` + ON `t13`.`year` = `t15`.`year` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/cross_join/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/cross_join/out.sql index 2c27c805038b..51bc5cb4ec76 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/cross_join/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/cross_join/out.sql @@ -1,3 +1,7 @@ -SELECT t0.* -FROM `star1` t0 - CROSS JOIN `star2` t1 \ No newline at end of file +SELECT + `t2`.`c`, + `t2`.`f`, + `t2`.`foo_id`, + `t2`.`bar_id` +FROM `star1` AS `t2` +CROSS JOIN `star2` AS `t3` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/inner_join/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/inner_join/out.sql index 2c27c805038b..3a2417b3c9d2 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/inner_join/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/inner_join/out.sql @@ -1,3 +1,8 @@ -SELECT t0.* -FROM `star1` t0 - CROSS JOIN `star2` t1 \ No newline at end of file +SELECT + `t2`.`c`, + `t2`.`f`, + `t2`.`foo_id`, + `t2`.`bar_id` +FROM `star1` AS `t2` +INNER JOIN `star2` AS `t3` + ON TRUE \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/left_join/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/left_join/out.sql index 2c27c805038b..4fca9e6c563c 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/left_join/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/left_join/out.sql @@ -1,3 +1,8 @@ -SELECT t0.* -FROM `star1` t0 - CROSS JOIN `star2` t1 \ No newline at end of file +SELECT + `t2`.`c`, + `t2`.`f`, + `t2`.`foo_id`, + `t2`.`bar_id` +FROM `star1` AS `t2` +LEFT OUTER JOIN `star2` AS `t3` + ON TRUE \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/outer_join/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/outer_join/out.sql index 2c27c805038b..51f3450f16ad 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/outer_join/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_no_predicates_for_impala/outer_join/out.sql @@ -1,3 +1,8 @@ -SELECT t0.* -FROM `star1` t0 - CROSS JOIN `star2` t1 \ No newline at end of file +SELECT + `t2`.`c`, + `t2`.`f`, + `t2`.`foo_id`, + `t2`.`bar_id` +FROM `star1` AS `t2` +FULL OUTER JOIN `star2` AS `t3` + ON TRUE \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_or_condition/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_or_condition/out.sql index 2b2706c2b4bc..dda0c97b4843 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_or_condition/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_or_condition/out.sql @@ -1,5 +1,13 @@ -SELECT t0.* -FROM `t` t0 - INNER JOIN `t` t1 - ON (t0.`a` = t1.`a`) AND - ((t0.`a` != t1.`b`) OR (t0.`b` != t1.`a`)) \ No newline at end of file +SELECT + `t1`.`a`, + `t1`.`b` +FROM `t` AS `t1` +INNER JOIN `t` AS `t3` + ON `t1`.`a` = `t3`.`a` + AND ( + ( + `t1`.`a` <> `t3`.`b` + ) OR ( + `t1`.`b` <> `t3`.`a` + ) + ) \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_xor_condition/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_xor_condition/out.sql index 42dfe3e6a41b..22c41b392f86 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_xor_condition/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_join_with_nested_xor_condition/out.sql @@ -1,5 +1,14 @@ -SELECT t0.* -FROM `t` t0 - INNER JOIN `t` t1 - ON (t0.`a` = t1.`a`) AND - (((t0.`a` != t1.`b`) OR (t0.`b` != t1.`a`)) AND NOT ((t0.`a` != t1.`b`) AND (t0.`b` != t1.`a`))) \ No newline at end of file +SELECT + `t1`.`a`, + `t1`.`b` +FROM `t` AS `t1` +INNER JOIN `t` AS `t3` + ON `t1`.`a` = `t3`.`a` + AND ( + ( + `t1`.`a` <> `t3`.`b` OR `t1`.`b` <> `t3`.`a` + ) + AND NOT ( + `t1`.`a` <> `t3`.`b` AND `t1`.`b` <> `t3`.`a` + ) + ) \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_limit_cte_extract/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_limit_cte_extract/out.sql index 2f11e9a2ac66..b408d5a00767 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_limit_cte_extract/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_limit_cte_extract/out.sql @@ -1,8 +1,27 @@ -WITH t0 AS ( - SELECT t2.* - FROM `functional_alltypes` t2 +SELECT + `t2`.`id`, + `t2`.`bool_col`, + `t2`.`tinyint_col`, + `t2`.`smallint_col`, + `t2`.`int_col`, + `t2`.`bigint_col`, + `t2`.`float_col`, + `t2`.`double_col`, + `t2`.`date_string_col`, + `t2`.`string_col`, + `t2`.`timestamp_col`, + `t2`.`year`, + `t2`.`month` +FROM ( + SELECT + * + FROM `functional_alltypes` AS `t0` LIMIT 100 -) -SELECT t0.* -FROM t0 - CROSS JOIN t0 t1 \ No newline at end of file +) AS `t2` +INNER JOIN ( + SELECT + * + FROM `functional_alltypes` AS `t0` + LIMIT 100 +) AS `t4` + ON TRUE \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_logically_negate_complex_boolean_expr/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_logically_negate_complex_boolean_expr/out.sql index 06566cbf9c18..8d93c3148789 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_logically_negate_complex_boolean_expr/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_logically_negate_complex_boolean_expr/out.sql @@ -1,2 +1,5 @@ -SELECT NOT (t0.`a` IN ('foo') AND (t0.`c` IS NOT NULL)) AS `tmp` -FROM `t` t0 \ No newline at end of file +SELECT + NOT ( + `t0`.`a` IN ('foo') AND NOT `t0`.`c` IS NULL + ) AS `tmp` +FROM `t` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters/out.sql index 4ebc521ad039..54573e65ff5c 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters/out.sql @@ -1,8 +1,18 @@ -SELECT t0.* -FROM `t0` t0 -WHERE (t0.`a` < 100) AND - (t0.`a` = ( - SELECT max(t0.`a`) AS `Max(a)` - FROM `t0` t0 - WHERE t0.`a` < 100 -)) \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b` +FROM `t0` AS `t0` +WHERE + `t0`.`a` < 100 + AND `t0`.`a` = ( + SELECT + MAX(`t1`.`a`) AS `Max(a)` + FROM ( + SELECT + `t0`.`a`, + `t0`.`b` + FROM `t0` AS `t0` + WHERE + `t0`.`a` < 100 + ) AS `t1` + ) \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters2/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters2/out.sql index f2a3ae74e8c7..ca8b8101a9c6 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_multiple_filters2/out.sql @@ -1,9 +1,19 @@ -SELECT t0.* -FROM `t0` t0 -WHERE (t0.`a` < 100) AND - (t0.`a` = ( - SELECT max(t0.`a`) AS `Max(a)` - FROM `t0` t0 - WHERE t0.`a` < 100 -)) AND - (t0.`b` = 'a') \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b` +FROM `t0` AS `t0` +WHERE + `t0`.`a` < 100 + AND `t0`.`a` = ( + SELECT + MAX(`t1`.`a`) AS `Max(a)` + FROM ( + SELECT + `t0`.`a`, + `t0`.`b` + FROM `t0` AS `t0` + WHERE + `t0`.`a` < 100 + ) AS `t1` + ) + AND `t0`.`b` = 'a' \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_base/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_base/out.sql index 08a1b2731c0e..0afadafb7be9 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_base/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_base/out.sql @@ -1,14 +1,27 @@ -WITH t0 AS ( - SELECT t2.`uuid`, count(1) AS `CountStar(t)` - FROM `t` t2 - GROUP BY 1 -), -t1 AS ( - SELECT t0.`uuid`, max(t0.`CountStar(t)`) AS `max_count` - FROM t0 - GROUP BY 1 -) -SELECT t0.* -FROM t1 - LEFT OUTER JOIN t0 - ON t1.`uuid` = t0.`uuid` \ No newline at end of file +SELECT + `t4`.`uuid`, + `t2`.`CountStar()` +FROM ( + SELECT + `t1`.`uuid`, + MAX(`t1`.`CountStar()`) AS `max_count` + FROM ( + SELECT + `t0`.`uuid`, + COUNT(*) AS `CountStar()` + FROM `t` AS `t0` + GROUP BY + 1 + ) AS `t1` + GROUP BY + 1 +) AS `t4` +LEFT OUTER JOIN ( + SELECT + `t0`.`uuid`, + COUNT(*) AS `CountStar()` + FROM `t` AS `t0` + GROUP BY + 1 +) AS `t2` + ON `t4`.`uuid` = `t2`.`uuid` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_multiple_ctes/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_multiple_ctes/out.sql index 74bb1229da66..5a4bca2f68ab 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_multiple_ctes/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_join_multiple_ctes/out.sql @@ -1,30 +1,61 @@ -WITH t0 AS ( - SELECT t2.* - FROM t2 - WHERE (t2.`userid` = 118205) AND - (extract(t2.`datetime`, 'year') > 2001) AND - (t2.`userid` = 118205) AND - (extract(t2.`datetime`, 'year') < 2009) -), -t1 AS ( - SELECT t3.`userid`, t3.`movieid`, t3.`rating`, - CAST(t3.`timestamp` AS timestamp) AS `datetime` - FROM `ratings` t3 -), -t2 AS ( - SELECT t1.*, t3.`title` - FROM t1 - INNER JOIN `movies` t3 - ON t1.`movieid` = t3.`movieid` -) -SELECT t2.* -FROM t2 -WHERE (t2.`userid` = 118205) AND - (extract(t2.`datetime`, 'year') > 2001) AND - (t2.`movieid` IN ( - SELECT t3.`movieid` +SELECT + `t7`.`userid`, + `t7`.`movieid`, + `t7`.`rating`, + `t7`.`datetime`, + `t7`.`title` +FROM ( + SELECT + `t6`.`userid`, + `t6`.`movieid`, + `t6`.`rating`, + `t6`.`datetime`, + `t6`.`title` FROM ( - SELECT t0.`movieid` - FROM t0 - ) t3 -)) \ No newline at end of file + SELECT + `t4`.`userid`, + `t4`.`movieid`, + `t4`.`rating`, + `t4`.`datetime`, + `t2`.`title` + FROM ( + SELECT + `t0`.`userid`, + `t0`.`movieid`, + `t0`.`rating`, + CAST(`t0`.`timestamp` AS TIMESTAMP) AS `datetime` + FROM `ratings` AS `t0` + ) AS `t4` + INNER JOIN `movies` AS `t2` + ON `t4`.`movieid` = `t2`.`movieid` + ) AS `t6` + WHERE + `t6`.`userid` = 118205 AND EXTRACT(year FROM `t6`.`datetime`) > 2001 +) AS `t7` +WHERE + `t7`.`movieid` IN ( + SELECT + `t6`.`movieid` + FROM ( + SELECT + `t4`.`userid`, + `t4`.`movieid`, + `t4`.`rating`, + `t4`.`datetime`, + `t2`.`title` + FROM ( + SELECT + `t0`.`userid`, + `t0`.`movieid`, + `t0`.`rating`, + CAST(`t0`.`timestamp` AS TIMESTAMP) AS `datetime` + FROM `ratings` AS `t0` + ) AS `t4` + INNER JOIN `movies` AS `t2` + ON `t4`.`movieid` = `t2`.`movieid` + ) AS `t6` + WHERE + `t6`.`userid` = 118205 + AND EXTRACT(year FROM `t6`.`datetime`) > 2001 + AND EXTRACT(year FROM `t6`.`datetime`) < 2009 + ) \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_joins_single_cte/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_joins_single_cte/out.sql index fb84b7aed87c..95e2f8ad4d5b 100644 --- a/ibis/backends/impala/tests/snapshots/test_sql/test_nested_joins_single_cte/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_sql/test_nested_joins_single_cte/out.sql @@ -1,26 +1,37 @@ -WITH t0 AS ( - SELECT t4.`uuid`, count(1) AS `CountStar(t)` - FROM `t` t4 - GROUP BY 1 -), -t1 AS ( - SELECT t0.`uuid`, max(t0.`CountStar(t)`) AS `max_count` - FROM t0 - GROUP BY 1 -), -t2 AS ( - SELECT t4.`uuid`, max(t4.`ts`) AS `last_visit` - FROM `t` t4 - GROUP BY 1 -), -t3 AS ( - SELECT t0.* - FROM t1 - LEFT OUTER JOIN t0 - ON (t1.`uuid` = t0.`uuid`) AND - (t1.`max_count` = t0.`CountStar(t)`) -) -SELECT t3.*, t2.`last_visit` -FROM t3 - LEFT OUTER JOIN t2 - ON t3.`uuid` = t2.`uuid` \ No newline at end of file +SELECT + `t6`.`uuid`, + `t2`.`CountStar()`, + `t4`.`last_visit` +FROM ( + SELECT + `t1`.`uuid`, + MAX(`t1`.`CountStar()`) AS `max_count` + FROM ( + SELECT + `t0`.`uuid`, + COUNT(*) AS `CountStar()` + FROM `t` AS `t0` + GROUP BY + 1 + ) AS `t1` + GROUP BY + 1 +) AS `t6` +LEFT OUTER JOIN ( + SELECT + `t0`.`uuid`, + COUNT(*) AS `CountStar()` + FROM `t` AS `t0` + GROUP BY + 1 +) AS `t2` + ON `t6`.`uuid` = `t2`.`uuid` AND `t6`.`max_count` = `t2`.`CountStar()` +LEFT OUTER JOIN ( + SELECT + `t0`.`uuid`, + MAX(`t0`.`ts`) AS `last_visit` + FROM `t` AS `t0` + GROUP BY + 1 +) AS `t4` + ON `t6`.`uuid` = `t4`.`uuid` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_find/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_find/out.sql index 931850b2c67b..1ea36d138126 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_find/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_find/out.sql @@ -1 +1,3 @@ -locate('a', `string_col`, `tinyint_col` + 1) - 1 \ No newline at end of file +SELECT + LOCATE('a', `t0`.`string_col`, `t0`.`tinyint_col` + 1) - 1 AS `StringFind(string_col, 'a', tinyint_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/ascii_str/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/ascii_str/out.sql index 7ef218478bd7..325872e8165c 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/ascii_str/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/ascii_str/out.sql @@ -1 +1,3 @@ -ascii(`string_col`) \ No newline at end of file +SELECT + ASCII(`t0`.`string_col`) AS `StringAscii(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/capitalize/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/capitalize/out.sql index c57891147a73..d23a9119ada0 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/capitalize/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/capitalize/out.sql @@ -1 +1,3 @@ -initcap(`string_col`) \ No newline at end of file +SELECT + INITCAP(`t0`.`string_col`) AS `Capitalize(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/extract_host/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/extract_host/out.sql index a863c53f5ade..6146d224587b 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/extract_host/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/extract_host/out.sql @@ -1 +1,3 @@ -parse_url(`string_col`, 'HOST') \ No newline at end of file +SELECT + PARSE_URL(`t0`.`string_col`, 'HOST') AS `ExtractHost(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find/out.sql index 0db084cf43ce..ed76d18fd686 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find/out.sql @@ -1 +1,3 @@ -locate('a', `string_col`) - 1 \ No newline at end of file +SELECT + LOCATE('a', `t0`.`string_col`) - 1 AS `StringFind(string_col, 'a')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_multiple/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_multiple/out.sql index 2904c469455c..614cf9e0c23c 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_multiple/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_multiple/out.sql @@ -1 +1,3 @@ -find_in_set(`string_col`, 'a,b') - 1 \ No newline at end of file +SELECT + FIND_IN_SET(`t0`.`string_col`, CONCAT_WS(',', 'a', 'b')) - 1 AS `FindInSet(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_single/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_single/out.sql index 8f691abdb529..1affe459d9a1 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_single/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_in_set_single/out.sql @@ -1 +1,3 @@ -find_in_set(`string_col`, 'a') - 1 \ No newline at end of file +SELECT + FIND_IN_SET(`t0`.`string_col`, CONCAT_WS(',', 'a')) - 1 AS `FindInSet(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_with_offset/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_with_offset/out.sql index 717a9cb020a2..93e63cc0d06b 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_with_offset/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/find_with_offset/out.sql @@ -1 +1,3 @@ -locate('a', `string_col`, 3) - 1 \ No newline at end of file +SELECT + LOCATE('a', `t0`.`string_col`, 2 + 1) - 1 AS `StringFind(string_col, 'a', 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/length/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/length/out.sql index 1e0744be0de5..8d6c4bdca3ea 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/length/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/length/out.sql @@ -1 +1,3 @@ -length(`string_col`) \ No newline at end of file +SELECT + LENGTH(`t0`.`string_col`) AS `StringLength(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like/out.sql index 39c5029114fe..b3c468b064bc 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like/out.sql @@ -1 +1,3 @@ -`string_col` LIKE 'foo%' \ No newline at end of file +SELECT + `t0`.`string_col` LIKE 'foo%' AS `StringSQLLike(string_col, 'foo%')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like_multiple/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like_multiple/out.sql index 13127122bbb3..b599e8873296 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like_multiple/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/like_multiple/out.sql @@ -1 +1,3 @@ -`string_col` LIKE 'foo%' OR `string_col` LIKE '%bar' \ No newline at end of file +SELECT + `t0`.`string_col` LIKE 'foo%' OR `t0`.`string_col` LIKE '%bar' AS `Or(StringSQLLike(string_col, 'foo%'), StringSQLLike(string_col, '%bar'))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lower/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lower/out.sql index 0edad56fc694..4cfba200403e 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lower/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lower/out.sql @@ -1 +1,3 @@ -lower(`string_col`) \ No newline at end of file +SELECT + LOWER(`t0`.`string_col`) AS `Lowercase(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_char/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_char/out.sql index aeb12d288947..83db8a156a2f 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_char/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_char/out.sql @@ -1 +1,3 @@ -lpad(`string_col`, 1, 'a') \ No newline at end of file +SELECT + LPAD(`t0`.`string_col`, 1, 'a') AS `LPad(string_col, 1, 'a')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_default/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_default/out.sql index 5fd117829c59..8776196103c9 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lpad_default/out.sql @@ -1 +1,3 @@ -lpad(`string_col`, 25, ' ') \ No newline at end of file +SELECT + LPAD(`t0`.`string_col`, 25, ' ') AS `LPad(string_col, 25, ' ')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lstrip/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lstrip/out.sql index c4aa27fec27a..f4ce746edd1d 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lstrip/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/lstrip/out.sql @@ -1 +1,3 @@ -ltrim(`string_col`) \ No newline at end of file +SELECT + LTRIM(`t0`.`string_col`) AS `LStrip(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_extract/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_extract/out.sql index a0c1030f8b35..76df41ef3249 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_extract/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_extract/out.sql @@ -1 +1,3 @@ -regexp_extract(`string_col`, '[\\d]+', 0) \ No newline at end of file +SELECT + REGEXP_EXTRACT(`t0`.`string_col`, '[\\d]+', 0) AS `RegexExtract(string_col, '[\\d]+', 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_replace/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_replace/out.sql index bcf6bf242b75..194115208582 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_replace/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_replace/out.sql @@ -1 +1,3 @@ -regexp_replace(`string_col`, '[\\d]+', 'aaa') \ No newline at end of file +SELECT + REGEXP_REPLACE(`t0`.`string_col`, '[\\d]+', 'aaa') AS `RegexReplace(string_col, '[\\d]+', 'aaa')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_search/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_search/out.sql index bd5b241c04f4..b8f2e9ad9c4a 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_search/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/re_search/out.sql @@ -1 +1,3 @@ -regexp_like(`string_col`, '[\\d]+') \ No newline at end of file +SELECT + `t0`.`string_col` RLIKE '[\\d]+' AS `RegexSearch(string_col, '[\\d]+')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/repeat/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/repeat/out.sql index 659b7785e0bc..8701c0d8b670 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/repeat/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/repeat/out.sql @@ -1 +1,3 @@ -repeat(`string_col`, 2) \ No newline at end of file +SELECT + REPEAT(`t0`.`string_col`, 2) AS `Repeat(string_col, 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/reverse/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/reverse/out.sql index 8a2d1509e518..4fa987fde0e7 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/reverse/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/reverse/out.sql @@ -1 +1,3 @@ -reverse(`string_col`) \ No newline at end of file +SELECT + REVERSE(`t0`.`string_col`) AS `Reverse(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rlike/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rlike/out.sql index bd5b241c04f4..b8f2e9ad9c4a 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rlike/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rlike/out.sql @@ -1 +1,3 @@ -regexp_like(`string_col`, '[\\d]+') \ No newline at end of file +SELECT + `t0`.`string_col` RLIKE '[\\d]+' AS `RegexSearch(string_col, '[\\d]+')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_char/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_char/out.sql index 6799fb1000f4..23314bf1cafa 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_char/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_char/out.sql @@ -1 +1,3 @@ -rpad(`string_col`, 1, 'a') \ No newline at end of file +SELECT + RPAD(`t0`.`string_col`, 1, 'a') AS `RPad(string_col, 1, 'a')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_default/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_default/out.sql index 3353a8f7c1ee..c2f18f32a5ce 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rpad_default/out.sql @@ -1 +1,3 @@ -rpad(`string_col`, 25, ' ') \ No newline at end of file +SELECT + RPAD(`t0`.`string_col`, 25, ' ') AS `RPad(string_col, 25, ' ')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rstrip/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rstrip/out.sql index 7cb8c95a18f1..825a36325c6c 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rstrip/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/rstrip/out.sql @@ -1 +1,3 @@ -rtrim(`string_col`) \ No newline at end of file +SELECT + RTRIM(`t0`.`string_col`) AS `RStrip(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strip/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strip/out.sql index 3b74aded9106..a3e2c1476733 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strip/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strip/out.sql @@ -1 +1,3 @@ -trim(`string_col`) \ No newline at end of file +SELECT + TRIM(`t0`.`string_col`) AS `Strip(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strright/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strright/out.sql index 8bb8e51bc07b..72f21e0b1f06 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strright/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/strright/out.sql @@ -1 +1,5 @@ -strright(`string_col`, 4) \ No newline at end of file +SELECT + SUBSTRING(`t0`.`string_col`, LENGTH(`t0`.`string_col`) - ( + 4 - 1 + )) AS `StrRight(string_col, 4)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_0_3/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_0_3/out.sql index ddc149a06a5a..1ecb1c5ff111 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_0_3/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_0_3/out.sql @@ -1 +1,9 @@ -substr(`string_col`, 0 + 1, 3) \ No newline at end of file +SELECT + IF( + ( + 0 + 1 + ) >= 1, + SUBSTRING(`t0`.`string_col`, 0 + 1, 3), + SUBSTRING(`t0`.`string_col`, 0 + 1 + LENGTH(`t0`.`string_col`), 3) + ) AS `Substring(string_col, 0, 3)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_2/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_2/out.sql index 359297f9a27a..08c2cd1ee1eb 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/substr_2/out.sql @@ -1 +1,9 @@ -substr(`string_col`, 2 + 1) \ No newline at end of file +SELECT + IF( + ( + 2 + 1 + ) >= 1, + SUBSTRING(`t0`.`string_col`, 2 + 1), + SUBSTRING(`t0`.`string_col`, 2 + 1 + LENGTH(`t0`.`string_col`)) + ) AS `Substring(string_col, 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/translate/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/translate/out.sql index 684f47fe7375..56e8f09fe492 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/translate/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/translate/out.sql @@ -1 +1,3 @@ -translate(`string_col`, 'a', 'b') \ No newline at end of file +SELECT + TRANSLATE(`t0`.`string_col`, 'a', 'b') AS `Translate(string_col, 'a', 'b')` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/upper/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/upper/out.sql index 946d3f8bdeff..51f7c7961559 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/upper/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_builtins/upper/out.sql @@ -1 +1,3 @@ -upper(`string_col`) \ No newline at end of file +SELECT + UPPER(`t0`.`string_col`) AS `Uppercase(string_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_join/out.sql b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_join/out.sql index 3bf4c101fd3a..495885e4d146 100644 --- a/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_join/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_string_builtins/test_string_join/out.sql @@ -1 +1,2 @@ -concat_ws(',', 'a', 'b') \ No newline at end of file +SELECT + CONCAT_WS(',', 'a', 'b') AS `StringJoin(',')` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation/out.sql b/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation/out.sql index 30b16fc26974..6ae4e58e0380 100644 --- a/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation/out.sql @@ -1 +1,2 @@ -SELECT udf_testing.identity('hello world') AS `UDF_Tester('hello world')` \ No newline at end of file +SELECT + UDF_TESTING.IDENTITY('hello world') AS `identity('hello world')` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation_from_infoclass/out.sql b/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation_from_infoclass/out.sql index 16e8b29a90ef..7331927594aa 100644 --- a/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation_from_infoclass/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_udf/test_sql_generation_from_infoclass/out.sql @@ -1 +1,2 @@ -SELECT udf_testing.info_test('hello world') AS `tmp` \ No newline at end of file +SELECT + UDF_TESTING.INFO_TEST('hello world') AS `tmp` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_hash/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_hash/out.sql index 994e8535524e..0e1a518d861a 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_hash/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_hash/out.sql @@ -1 +1,3 @@ -fnv_hash(`int_col`) \ No newline at end of file +SELECT + FNV_HASH(`t0`.`int_col`) AS `Hash(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/log_with_base/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/log_with_base/out.sql index 0ddbc401afb6..2238b9b6689a 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/log_with_base/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/log_with_base/out.sql @@ -1 +1,3 @@ -log(5, `double_col`) \ No newline at end of file +SELECT + LOG(5, `t0`.`double_col`) AS `Log(double_col, 5)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_expr/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_expr/out.sql index 89bf6b7e1e7f..28e045098b09 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_expr/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_expr/out.sql @@ -1 +1,3 @@ -round(`double_col`, `tinyint_col`) \ No newline at end of file +SELECT + ROUND(`t0`.`double_col`, `t0`.`tinyint_col`) AS `Round(double_col, tinyint_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_no_args/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_no_args/out.sql index d5f8e2bbfbda..8acebb77ef31 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_no_args/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_no_args/out.sql @@ -1 +1,3 @@ -cast(round(`double_col`) AS BIGINT) \ No newline at end of file +SELECT + CAST(ROUND(`t0`.`double_col`) AS BIGINT) AS `Round(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_two/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_two/out.sql index 8a47c0984f28..61400c7e45a3 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_two/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_two/out.sql @@ -1 +1,3 @@ -round(`double_col`, 2) \ No newline at end of file +SELECT + ROUND(`t0`.`double_col`, 2) AS `Round(double_col, 2)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_zero/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_zero/out.sql index 7fb9eaf37aaf..5454c320029e 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_zero/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/round_zero/out.sql @@ -1 +1,3 @@ -round(`double_col`, 0) \ No newline at end of file +SELECT + ROUND(`t0`.`double_col`, 0) AS `Round(double_col, 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_double/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_double/out.sql index 72a6377e9981..1ac9e131c659 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_double/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_double/out.sql @@ -1 +1,3 @@ -CAST(sign(`double_col`) AS double) \ No newline at end of file +SELECT + CAST(SIGN(`t0`.`double_col`) AS DOUBLE) AS `Sign(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_float/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_float/out.sql index f3e012c490c0..32291b80199a 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_float/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_float/out.sql @@ -1 +1,3 @@ -sign(`float_col`) \ No newline at end of file +SELECT + SIGN(`t0`.`float_col`) AS `Sign(float_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_tinyint/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_tinyint/out.sql index 286c57270265..aeab3363194a 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_tinyint/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric/sign_tinyint/out.sql @@ -1 +1,3 @@ -CAST(sign(`tinyint_col`) AS tinyint) \ No newline at end of file +SELECT + CAST(SIGN(`t0`.`tinyint_col`) AS TINYINT) AS `Sign(tinyint_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-abs/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-abs/out.sql index 1e825cc95736..6a5fbd114957 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-abs/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-abs/out.sql @@ -1 +1,3 @@ -abs(`double_col`) \ No newline at end of file +SELECT + ABS(`t0`.`double_col`) AS `Abs(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_median/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_median/out.sql index 7c6259d1f207..1b8952091788 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_median/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_median/out.sql @@ -1 +1,3 @@ -appx_median(`double_col`) \ No newline at end of file +SELECT + APPX_MEDIAN(`t0`.`double_col`) AS `ApproxMedian(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_nunique/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_nunique/out.sql index bbd86f78c7b2..8b6a9a30cd5e 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_nunique/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-approx_nunique/out.sql @@ -1 +1,3 @@ -ndv(`double_col`) \ No newline at end of file +SELECT + NDV(`t0`.`double_col`) AS `ApproxCountDistinct(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ceil/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ceil/out.sql index 34b44958f5b2..e1d4ccc8bfc8 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ceil/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ceil/out.sql @@ -1 +1,3 @@ -cast(ceil(`double_col`) AS BIGINT) \ No newline at end of file +SELECT + CAST(CEIL(`t0`.`double_col`) AS BIGINT) AS `Ceil(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-exp/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-exp/out.sql index 3fcad3b1277a..901825a56673 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-exp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-exp/out.sql @@ -1 +1,3 @@ -exp(`double_col`) \ No newline at end of file +SELECT + EXP(`t0`.`double_col`) AS `Exp(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-floor/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-floor/out.sql index 5c9398c38a57..ce08c79223ee 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-floor/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-floor/out.sql @@ -1 +1,3 @@ -cast(floor(`double_col`) AS BIGINT) \ No newline at end of file +SELECT + CAST(FLOOR(`t0`.`double_col`) AS BIGINT) AS `Floor(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ln/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ln/out.sql index d877e8555ef2..054c37c01e12 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ln/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-ln/out.sql @@ -1 +1,3 @@ -ln(`double_col`) \ No newline at end of file +SELECT + LN(`t0`.`double_col`) AS `Ln(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log/out.sql index d877e8555ef2..3ab583ef1b1e 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log/out.sql @@ -1 +1,3 @@ -ln(`double_col`) \ No newline at end of file +SELECT + LN(`t0`.`double_col`) AS `Log(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log10/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log10/out.sql index 21221b5e1e77..3855ea62162b 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log10/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log10/out.sql @@ -1 +1,3 @@ -log10(`double_col`) \ No newline at end of file +SELECT + LOG10(`t0`.`double_col`) AS `Log10(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log2/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log2/out.sql index 4bc576e89d92..95fa9de02cd7 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-log2/out.sql @@ -1 +1,3 @@ -log2(`double_col`) \ No newline at end of file +SELECT + LOG2(`t0`.`double_col`) AS `Log2(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-nullif_zero/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-nullif_zero/out.sql index 692f32c5426b..9ec19055a585 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-nullif_zero/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-nullif_zero/out.sql @@ -1 +1,3 @@ -nullif(`double_col`, 0) \ No newline at end of file +SELECT + NULLIF(`t0`.`double_col`, 0) AS `NullIf(double_col, 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-sqrt/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-sqrt/out.sql index 014bda7b6ce8..a97c5b3d9c41 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-sqrt/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-sqrt/out.sql @@ -1 +1,3 @@ -sqrt(`double_col`) \ No newline at end of file +SELECT + SQRT(`t0`.`double_col`) AS `Sqrt(double_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-zero_ifnull/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-zero_ifnull/out.sql index b13fcb27c9c0..50332619efc8 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-zero_ifnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/double_col-zero_ifnull/out.sql @@ -1 +1,3 @@ -coalesce(`double_col`, 0) \ No newline at end of file +SELECT + COALESCE(`t0`.`double_col`, 0) AS `Coalesce()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-abs/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-abs/out.sql index 981659054851..47bbebc076ad 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-abs/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-abs/out.sql @@ -1 +1,3 @@ -abs(`int_col`) \ No newline at end of file +SELECT + ABS(`t0`.`int_col`) AS `Abs(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_median/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_median/out.sql index 78a2961d5bdc..f4aa84e0340d 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_median/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_median/out.sql @@ -1 +1,3 @@ -appx_median(`int_col`) \ No newline at end of file +SELECT + APPX_MEDIAN(`t0`.`int_col`) AS `ApproxMedian(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_nunique/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_nunique/out.sql index ae7d5abebd59..61bf77ff6b36 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_nunique/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-approx_nunique/out.sql @@ -1 +1,3 @@ -ndv(`int_col`) \ No newline at end of file +SELECT + NDV(`t0`.`int_col`) AS `ApproxCountDistinct(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ceil/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ceil/out.sql index ad631e5f0301..9719624e9899 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ceil/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ceil/out.sql @@ -1 +1,3 @@ -cast(ceil(`int_col`) AS BIGINT) \ No newline at end of file +SELECT + CAST(CEIL(`t0`.`int_col`) AS BIGINT) AS `Ceil(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-exp/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-exp/out.sql index 3dfb7771b2b0..8fc65dc0bcf7 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-exp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-exp/out.sql @@ -1 +1,3 @@ -exp(`int_col`) \ No newline at end of file +SELECT + EXP(`t0`.`int_col`) AS `Exp(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-floor/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-floor/out.sql index 2c1c3b987be9..c1176e87d5ca 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-floor/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-floor/out.sql @@ -1 +1,3 @@ -cast(floor(`int_col`) AS BIGINT) \ No newline at end of file +SELECT + CAST(FLOOR(`t0`.`int_col`) AS BIGINT) AS `Floor(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ln/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ln/out.sql index b8f0063ba5cc..0d28cf45d8d0 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ln/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-ln/out.sql @@ -1 +1,3 @@ -ln(`int_col`) \ No newline at end of file +SELECT + LN(`t0`.`int_col`) AS `Ln(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log/out.sql index b8f0063ba5cc..445d79468855 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log/out.sql @@ -1 +1,3 @@ -ln(`int_col`) \ No newline at end of file +SELECT + LN(`t0`.`int_col`) AS `Log(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log10/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log10/out.sql index 523571bfbda5..f70ec7877869 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log10/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log10/out.sql @@ -1 +1,3 @@ -log10(`int_col`) \ No newline at end of file +SELECT + LOG10(`t0`.`int_col`) AS `Log10(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log2/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log2/out.sql index 802aca35efb1..85c0ab5865db 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-log2/out.sql @@ -1 +1,3 @@ -log2(`int_col`) \ No newline at end of file +SELECT + LOG2(`t0`.`int_col`) AS `Log2(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-nullif_zero/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-nullif_zero/out.sql index b5728635f362..189059ca5eec 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-nullif_zero/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-nullif_zero/out.sql @@ -1 +1,3 @@ -nullif(`int_col`, 0) \ No newline at end of file +SELECT + NULLIF(`t0`.`int_col`, 0) AS `NullIf(int_col, 0)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-sqrt/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-sqrt/out.sql index f16508299bb0..66207d0c3bfb 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-sqrt/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-sqrt/out.sql @@ -1 +1,3 @@ -sqrt(`int_col`) \ No newline at end of file +SELECT + SQRT(`t0`.`int_col`) AS `Sqrt(int_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-zero_ifnull/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-zero_ifnull/out.sql index fe70093ef8b6..98cd6d13641f 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-zero_ifnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_numeric_unary_builtins/int_col-zero_ifnull/out.sql @@ -1 +1,3 @@ -coalesce(`int_col`, 0) \ No newline at end of file +SELECT + COALESCE(`t0`.`int_col`, 0) AS `Coalesce()` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/avg/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/avg/out.sql index e8a6fda0c3c3..a77ec0333df1 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/avg/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/avg/out.sql @@ -1 +1,3 @@ -avg(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + AVG(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Mean(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/count/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/count/out.sql index d16ebdb59378..f1c9820372f8 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/count/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/count/out.sql @@ -1 +1,3 @@ -count(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + COUNT(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Count(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/max/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/max/out.sql index 1177c7248f3a..201339f34a34 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/max/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/max/out.sql @@ -1 +1,3 @@ -max(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + MAX(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Max(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/min/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/min/out.sql index ef78e51fd300..3d7b4c2b6338 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/min/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/min/out.sql @@ -1 +1,3 @@ -min(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + MIN(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Min(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_pop/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_pop/out.sql index db9bd6952bbe..904bd3cedb82 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_pop/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_pop/out.sql @@ -1 +1,3 @@ -stddev_pop(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + STDDEV_POP(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `StandardDev(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_samp/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_samp/out.sql index a99c13b7aa32..5441b3e8a148 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_samp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/stddev_samp/out.sql @@ -1 +1,3 @@ -stddev_samp(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + STDDEV_SAMP(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `StandardDev(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/sum/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/sum/out.sql index fe67276335ab..2e5f42ac441b 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/sum/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/sum/out.sql @@ -1 +1,3 @@ -sum(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + SUM(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Sum(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_pop/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_pop/out.sql index 1c4cc2673fca..6f8f349f6dea 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_pop/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_pop/out.sql @@ -1 +1,3 @@ -var_pop(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + VARIANCE_POP(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Variance(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_samp/out.sql b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_samp/out.sql index eb78e2ad5fcc..687ec674190a 100644 --- a/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_samp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_unary_builtins/test_reduction_where/var_samp/out.sql @@ -1 +1,3 @@ -var_samp(if(`bigint_col` < 70, `double_col`, NULL)) \ No newline at end of file +SELECT + VARIANCE(IF(`t0`.`bigint_col` < 70, `t0`.`double_col`, NULL)) AS `Variance(double_col, Less(bigint_col, 70))` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/all/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/all/out.sql index 5ce0bf8a7908..b3c01f218e9c 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/all/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/all/out.sql @@ -1 +1,3 @@ -min(`f` = 0) \ No newline at end of file +SELECT + MIN(`t0`.`f` = 0) AS `All(Equals(f, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/any/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/any/out.sql index 99666cb4f85e..3603a3775525 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/any/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/any/out.sql @@ -1 +1,3 @@ -max(`f` = 0) \ No newline at end of file +SELECT + MAX(`t0`.`f` = 0) AS `Any(Equals(f, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_all/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_all/out.sql index 6a728d740a87..a8dddedc924a 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_all/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_all/out.sql @@ -1 +1,5 @@ -NOT min(`f` = 0) \ No newline at end of file +SELECT + NOT ( + MIN(`t0`.`f` = 0) + ) AS `Not(All(Equals(f, 0)))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_any/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_any/out.sql index acf6c77d626b..f34b0119dd6a 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_any/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_any_all/not_any/out.sql @@ -1 +1,5 @@ -NOT max(`f` = 0) \ No newline at end of file +SELECT + NOT ( + MAX(`t0`.`f` = 0) + ) AS `Not(Any(Equals(f, 0)))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_between/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_between/out.sql index ad73d2ff66b9..074d1cf7504a 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_between/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_between/out.sql @@ -1 +1,3 @@ -`f` BETWEEN 0 AND 1 \ No newline at end of file +SELECT + `t0`.`f` BETWEEN 0 AND 1 AS `Between(f, 0, 1)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/add/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/add/out.sql index de42587aa531..c75bfca19b2e 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/add/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/add/out.sql @@ -1 +1,3 @@ -`a` + `b` \ No newline at end of file +SELECT + `t0`.`a` + `t0`.`b` AS `Add(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/and/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/and/out.sql index e7a19d915a4d..62490957d853 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/and/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/and/out.sql @@ -1 +1,5 @@ -`h` AND (`a` > 0) \ No newline at end of file +SELECT + `t0`.`h` AND ( + `t0`.`a` > 0 + ) AS `And(h, Greater(a, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/div/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/div/out.sql index 738f82062003..ff486466e25d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/div/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/div/out.sql @@ -1 +1,3 @@ -`a` / `b` \ No newline at end of file +SELECT + `t0`.`a` / `t0`.`b` AS `Divide(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/eq/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/eq/out.sql index f63b650bb512..7cd246375633 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/eq/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/eq/out.sql @@ -1 +1,3 @@ -`a` = `b` \ No newline at end of file +SELECT + `t0`.`a` = `t0`.`b` AS `Equals(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ge/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ge/out.sql index d082c8a0f7b1..2886b762bb3c 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ge/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ge/out.sql @@ -1 +1,3 @@ -`a` >= `b` \ No newline at end of file +SELECT + `t0`.`a` >= `t0`.`b` AS `GreaterEqual(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/gt/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/gt/out.sql index 5dbacd9aeacb..2de270e4e888 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/gt/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/gt/out.sql @@ -1 +1,3 @@ -`a` > `b` \ No newline at end of file +SELECT + `t0`.`a` > `t0`.`b` AS `Greater(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/le/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/le/out.sql index 3af3232deda5..539f4c941b99 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/le/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/le/out.sql @@ -1 +1,3 @@ -`a` <= `b` \ No newline at end of file +SELECT + `t0`.`a` <= `t0`.`b` AS `LessEqual(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/lt/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/lt/out.sql index cd59403991fd..d6a149a69a6d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/lt/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/lt/out.sql @@ -1 +1,3 @@ -`a` < `b` \ No newline at end of file +SELECT + `t0`.`a` < `t0`.`b` AS `Less(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/mul/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/mul/out.sql index 377ffe5d81a9..0082b5406b2a 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/mul/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/mul/out.sql @@ -1 +1,3 @@ -`a` * `b` \ No newline at end of file +SELECT + `t0`.`a` * `t0`.`b` AS `Multiply(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ne/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ne/out.sql index 4859254caf16..43510c0f6f20 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ne/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/ne/out.sql @@ -1 +1,3 @@ -`a` != `b` \ No newline at end of file +SELECT + `t0`.`a` <> `t0`.`b` AS `NotEquals(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/or/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/or/out.sql index 4ee3468ac338..f0934f0d1e85 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/or/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/or/out.sql @@ -1 +1,5 @@ -`h` OR (`a` > 0) \ No newline at end of file +SELECT + `t0`.`h` OR ( + `t0`.`a` > 0 + ) AS `Or(h, Greater(a, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/pow/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/pow/out.sql index e03a233264b7..e6692989f4ed 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/pow/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/pow/out.sql @@ -1 +1,3 @@ -pow(`a`, `b`) \ No newline at end of file +SELECT + POWER(`t0`.`a`, `t0`.`b`) AS `Power(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/sub/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/sub/out.sql index eef355b72f37..61ca4f714055 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/sub/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/sub/out.sql @@ -1 +1,3 @@ -`a` - `b` \ No newline at end of file +SELECT + `t0`.`a` - `t0`.`b` AS `Subtract(a, b)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/xor/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/xor/out.sql index be15c73a65d9..3d40e7082127 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/xor/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_operators/xor/out.sql @@ -1 +1,7 @@ -(`h` OR (`a` > 0)) AND NOT (`h` AND (`a` > 0)) \ No newline at end of file +SELECT + ( + `t0`.`h` OR `t0`.`a` > 0 + ) AND NOT ( + `t0`.`h` AND `t0`.`a` > 0 + ) AS `Xor(h, Greater(a, 0))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/function_call/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/function_call/out.sql index 01d8d54ab171..0a0acb3d3916 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/function_call/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/function_call/out.sql @@ -1 +1,3 @@ -ln(`a`) + `c` \ No newline at end of file +SELECT + LN(`t0`.`a`) + `t0`.`c` AS `Add(Log(a), c)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/negation/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/negation/out.sql index d3ddcdaf596c..57843a872be2 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/negation/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/negation/out.sql @@ -1 +1,5 @@ -`b` + (-(`a` + `c`)) \ No newline at end of file +SELECT + `t0`.`b` + -( + `t0`.`a` + `t0`.`c` + ) AS `Add(b, Negate(Add(a, c)))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/parens_left/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/parens_left/out.sql index 6ae6e64d1587..5129499fb406 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/parens_left/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_binary_infix_parenthesization/parens_left/out.sql @@ -1 +1,5 @@ -(`a` + `b`) + `c` \ No newline at end of file +SELECT + ( + `t0`.`a` + `t0`.`b` + ) + `t0`.`c` AS `Add(Add(a, b), c)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int16/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int16/out.sql index e8acf4f526ac..704a46db2ab0 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int16/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int16/out.sql @@ -1 +1,3 @@ -CAST(`a` AS smallint) \ No newline at end of file +SELECT + CAST(`t0`.`a` AS SMALLINT) AS `Cast(a, int16)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int32/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int32/out.sql index 009f91e4dff7..3600cc467680 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int32/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int32/out.sql @@ -1 +1,3 @@ -CAST(`a` AS int) \ No newline at end of file +SELECT + CAST(`t0`.`a` AS INT) AS `Cast(a, int32)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int64/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int64/out.sql index f8908356c41a..754de6351cb3 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int64/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-int64/out.sql @@ -1 +1,3 @@ -CAST(`a` AS bigint) \ No newline at end of file +SELECT + CAST(`t0`.`a` AS BIGINT) AS `Cast(a, int64)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-string/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-string/out.sql index 532de8e0c518..5a81bd7a8fb5 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-string/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/a-string/out.sql @@ -1 +1,3 @@ -CAST(`a` AS string) \ No newline at end of file +SELECT + CAST(`t0`.`a` AS STRING) AS `Cast(a, string)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/d-int8/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/d-int8/out.sql index 05775da9ff65..3c9cacaea43d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/d-int8/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/d-int8/out.sql @@ -1 +1,3 @@ -CAST(`d` AS tinyint) \ No newline at end of file +SELECT + CAST(`t0`.`d` AS TINYINT) AS `Cast(d, int8)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-double/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-double/out.sql index 16885af75ca0..bcc0c2a4bf5f 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-double/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-double/out.sql @@ -1 +1,3 @@ -CAST(`g` AS double) \ No newline at end of file +SELECT + CAST(`t0`.`g` AS DOUBLE) AS `Cast(g, float64)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-timestamp/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-timestamp/out.sql index 2eac75bda518..e3b96a62dfa1 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-timestamp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_casts/g-timestamp/out.sql @@ -1 +1,3 @@ -CAST(`g` AS timestamp) \ No newline at end of file +SELECT + CAST(`t0`.`g` AS TIMESTAMP) AS `Cast(g, timestamp)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_column_ref_table_aliases/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_column_ref_table_aliases/out.sql deleted file mode 100644 index 720bb988d4ce..000000000000 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_column_ref_table_aliases/out.sql +++ /dev/null @@ -1 +0,0 @@ -t0.`value1` - t1.`value and2` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out1.sql new file mode 100644 index 000000000000..037d0612d48b --- /dev/null +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out1.sql @@ -0,0 +1,15 @@ +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k` +FROM `alltypes` AS `t0` +WHERE + `t0`.`g` = `t1`.`g` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out2.sql new file mode 100644 index 000000000000..1f4705a4b3f4 --- /dev/null +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_correlated_predicate_subquery/out2.sql @@ -0,0 +1,15 @@ +SELECT + `t1`.`a`, + `t1`.`b`, + `t1`.`c`, + `t1`.`d`, + `t1`.`e`, + `t1`.`f`, + `t1`.`g`, + `t1`.`h`, + `t1`.`i`, + `t1`.`j`, + `t1`.`k` +FROM `alltypes` AS `t1` +WHERE + `t0`.`g` = `t1`.`g` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/column/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/column/out.sql index 8bd09e13e15a..d64f9372d0d0 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/column/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/column/out.sql @@ -1 +1,3 @@ -CAST(`f` AS decimal(12, 2)) \ No newline at end of file +SELECT + CAST(`t0`.`f` AS DECIMAL(12, 2)) AS `Cast(f, decimal(12, 2))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/literal/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/literal/out.sql index d1714725990c..2cf3990f2dff 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/literal/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_decimal_casts/literal/out.sql @@ -1 +1,2 @@ -CAST('9.9999999' AS decimal(38, 5)) \ No newline at end of file +SELECT + CAST('9.9999999' AS DECIMAL(38, 5)) AS `Cast('9.9999999', decimal(38, 5))` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/compound_isnull/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/compound_isnull/out.sql index 7b86eb84d3ca..7448f99b030a 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/compound_isnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/compound_isnull/out.sql @@ -1 +1,5 @@ -`a` + `b` IS NULL \ No newline at end of file +SELECT + ( + `t0`.`a` + `t0`.`b` + ) IS NULL AS `IsNull(Add(a, b))` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/isnull/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/isnull/out.sql index 1cc4e78d323f..95a4553c56f8 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/isnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/isnull/out.sql @@ -1 +1,3 @@ -`g` IS NULL \ No newline at end of file +SELECT + `t0`.`g` IS NULL AS `IsNull(g)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/notnull/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/notnull/out.sql index cf5142f9ff8d..e73b0f80ce14 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/notnull/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_isnull_notnull/notnull/out.sql @@ -1 +1,3 @@ -`a` IS NOT NULL \ No newline at end of file +SELECT + NOT `t0`.`a` IS NULL AS `NotNull(a)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_double_quote/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_double_quote/out.sql index 7ec9ac6b2e01..3925c3655429 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_double_quote/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_double_quote/out.sql @@ -1 +1,2 @@ -'An "escape"' \ No newline at end of file +SELECT + 'An "escape"' AS `'An "escape"'` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_single_quote/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_single_quote/out.sql index de1ddacc9239..47f1d01c628c 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_single_quote/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/embedded_single_quote/out.sql @@ -1 +1,2 @@ -'I can\'t' \ No newline at end of file +SELECT + 'I can\'t' AS `"I can't"` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/false/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/false/out.sql index 5a03bd3f56c5..d651d2b7b227 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/false/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/false/out.sql @@ -1 +1,2 @@ -FALSE \ No newline at end of file +SELECT + FALSE AS `False` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/float/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/float/out.sql index 400122e60f59..961eaa4da513 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/float/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/float/out.sql @@ -1 +1,2 @@ -1.5 \ No newline at end of file +SELECT + 1.5 AS `1.5` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/int/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/int/out.sql index 7813681f5b41..f9e238629c44 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/int/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/int/out.sql @@ -1 +1,2 @@ -5 \ No newline at end of file +SELECT + 5 AS `5` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/simple/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/simple/out.sql index 271237e4c2bc..56d5f0cd08ab 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/simple/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/simple/out.sql @@ -1 +1,2 @@ -'simple' \ No newline at end of file +SELECT + 'simple' AS `'simple'` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/true/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/true/out.sql index 51cb8b0f7c29..0872d8303204 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/true/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_literals/true/out.sql @@ -1 +1,2 @@ -TRUE \ No newline at end of file +SELECT + TRUE AS `True` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_misc_conditionals/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_misc_conditionals/out.sql index 85bacbbef964..d5c70b443e78 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_misc_conditionals/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_misc_conditionals/out.sql @@ -1 +1,3 @@ -nullif(`a`, 0) \ No newline at end of file +SELECT + NULLIF(`t0`.`a`, 0) AS `NullIf(a, 0)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/cast/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/cast/out.sql index ce4aafe52ec2..0a301bc6cdcd 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/cast/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/cast/out.sql @@ -1 +1,3 @@ -CAST(`g` AS double) AS `g_dub` \ No newline at end of file +SELECT + CAST(`t0`.`g` AS DOUBLE) AS `g_dub` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/compound_expr/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/compound_expr/out.sql index 2778f0de3244..8fb6371ac2b7 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/compound_expr/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/compound_expr/out.sql @@ -1 +1,5 @@ -(`a` - `b`) * `a` AS `expr` \ No newline at end of file +SELECT + ( + `t0`.`a` - `t0`.`b` + ) * `t0`.`a` AS `expr` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/spaces/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/spaces/out.sql index 2b69e2760caf..dcdbc154e1a0 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/spaces/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_named_expressions/spaces/out.sql @@ -1 +1,3 @@ -`g` AS `has a space` \ No newline at end of file +SELECT + `t0`.`g` AS `has a space` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/a/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/a/out.sql index ddbd6aba9757..6d8d3bffa41b 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/a/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/a/out.sql @@ -1 +1,5 @@ --`a` \ No newline at end of file +SELECT + -( + `t0`.`a` + ) AS `Negate(a)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/f/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/f/out.sql index fc80397e5fb8..9816ef075d8b 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/f/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/f/out.sql @@ -1 +1,5 @@ --`f` \ No newline at end of file +SELECT + -( + `t0`.`f` + ) AS `Negate(f)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/h/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/h/out.sql index 09b4c8e4209b..522c778fade2 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/h/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_negate/h/out.sql @@ -1 +1,5 @@ -NOT `h` \ No newline at end of file +SELECT + NOT ( + `t0`.`h` + ) AS `Not(h)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_sql_extract/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_sql_extract/out.sql index 6615fd983818..618635097742 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_sql_extract/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_sql_extract/out.sql @@ -1,3 +1,5 @@ -SELECT extract(t0.`i`, 'year') AS `year`, extract(t0.`i`, 'month') AS `month`, - extract(t0.`i`, 'day') AS `day` -FROM `alltypes` t0 \ No newline at end of file +SELECT + EXTRACT(year FROM `t0`.`i`) AS `year`, + EXTRACT(month FROM `t0`.`i`) AS `month`, + EXTRACT(day FROM `t0`.`i`) AS `day` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/full_name/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/full_name/out.sql index 9c4297e0fb82..a984be382ea8 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/full_name/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/full_name/out.sql @@ -1 +1,2 @@ -dayname('2015-09-01T01:00:23') \ No newline at end of file +SELECT + DAYNAME('2015-09-01T01:00:23') AS `DayOfWeekName(datetime.datetime(2015, 9, 1, 1, 0, 23))` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/index/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/index/out.sql index fc166ccac8c2..9a26667a72fa 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/index/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_day_of_week/index/out.sql @@ -1 +1,2 @@ -pmod(dayofweek('2015-09-01T01:00:23') - 2, 7) \ No newline at end of file +SELECT + PMOD(DAY_OF_WEEK('2015-09-01T01:00:23') - 2, 7) AS `DayOfWeekIndex(datetime.datetime(2015, 9, 1, 1, 0, 23))` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out1.sql index 9c6a6f3f3f4e..7237d7b9004d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 DAY) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' DAY AS TIMESTAMP) AS `TimestampAdd(i, 5D)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out2.sql index c180d3bf65cd..eb169d991d79 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/days/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 DAY) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' DAY AS `TimestampSub(i, 5D)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out1.sql index 0fcb7a0d5199..328d2ef5a820 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 HOUR) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' HOUR AS TIMESTAMP) AS `TimestampAdd(i, 5h)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out2.sql index 7402f369a533..86951b1a52ab 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/hours/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 HOUR) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' HOUR AS `TimestampSub(i, 5h)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out1.sql index b7096d5ba4be..a97e1fda3fb7 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 MINUTE) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' MINUTE AS TIMESTAMP) AS `TimestampAdd(i, 5m)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out2.sql index e7a3872edc48..9646ba677e2f 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/minutes/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 MINUTE) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' MINUTE AS `TimestampSub(i, 5m)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out1.sql index 32421590426e..2f2d23da1686 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 MONTH) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' MONTH AS TIMESTAMP) AS `TimestampAdd(i, 5M)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out2.sql index a71b731d050e..fc1911b370cb 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/months/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 MONTH) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' MONTH AS `TimestampSub(i, 5M)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out1.sql index f15d5d5ece75..9fb8b0686200 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 SECOND) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' SECOND AS TIMESTAMP) AS `TimestampAdd(i, 5s)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out2.sql index b3cc2bded61a..8f89c57c0e98 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/seconds/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 SECOND) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' SECOND AS `TimestampSub(i, 5s)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out1.sql index 676ba865764e..2ee339b0a84e 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 WEEK) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' WEEK AS TIMESTAMP) AS `TimestampAdd(i, 5W)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out2.sql index c494e3d406eb..92b9cfeda5ba 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/weeks/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 WEEK) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' WEEK AS `TimestampSub(i, 5W)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out1.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out1.sql index b79ad3f637f1..b0bbfd8bd6ca 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out1.sql @@ -1 +1,3 @@ -date_add(cast(`i` as timestamp), INTERVAL 5 YEAR) \ No newline at end of file +SELECT + CAST(CAST(`t0`.`i` AS TIMESTAMP) + INTERVAL '5' YEAR AS TIMESTAMP) AS `TimestampAdd(i, 5Y)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out2.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out2.sql index 8096bbacd63f..0778cd8b068e 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_deltas/years/out2.sql @@ -1 +1,3 @@ -date_sub(cast(`i` as timestamp), INTERVAL 5 YEAR) \ No newline at end of file +SELECT + `t0`.`i` - INTERVAL '5' YEAR AS `TimestampSub(i, 5Y)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/day/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/day/out.sql index bb6eb1e9743e..7d48d45ef57d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/day/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/day/out.sql @@ -1 +1,3 @@ -extract(`i`, 'day') \ No newline at end of file +SELECT + EXTRACT(day FROM `t0`.`i`) AS `ExtractDay(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/hour/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/hour/out.sql index aee2ae57deb3..7b40771226a7 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/hour/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/hour/out.sql @@ -1 +1,3 @@ -extract(`i`, 'hour') \ No newline at end of file +SELECT + EXTRACT(hour FROM `t0`.`i`) AS `ExtractHour(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/microsecond/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/microsecond/out.sql index cfbd2bf17deb..581fbe79370d 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/microsecond/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/microsecond/out.sql @@ -1 +1,3 @@ -extract(`i`, 'microsecond') % 1000000 \ No newline at end of file +SELECT + EXTRACT(microsecond FROM `t0`.`i`) % 1000000 AS `ExtractMicrosecond(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/millisecond/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/millisecond/out.sql index ccc6e55c3369..8ec3fd789ebd 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/millisecond/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/millisecond/out.sql @@ -1 +1,3 @@ -extract(`i`, 'millisecond') % 1000 \ No newline at end of file +SELECT + EXTRACT(millisecond FROM `t0`.`i`) % 1000 AS `ExtractMillisecond(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/minute/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/minute/out.sql index f02e4f778cc4..ad23d825b136 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/minute/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/minute/out.sql @@ -1 +1,3 @@ -extract(`i`, 'minute') \ No newline at end of file +SELECT + EXTRACT(minute FROM `t0`.`i`) AS `ExtractMinute(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/month/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/month/out.sql index 057f3677f3ce..0464f32264b0 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/month/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/month/out.sql @@ -1 +1,3 @@ -extract(`i`, 'month') \ No newline at end of file +SELECT + EXTRACT(month FROM `t0`.`i`) AS `ExtractMonth(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/second/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/second/out.sql index c2cfcf566b93..415228f0ac53 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/second/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/second/out.sql @@ -1 +1,3 @@ -extract(`i`, 'second') \ No newline at end of file +SELECT + EXTRACT(second FROM `t0`.`i`) AS `ExtractSecond(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/year/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/year/out.sql index c9e4e97df7b7..559c7e58f189 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/year/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_extract_field/year/out.sql @@ -1 +1,3 @@ -extract(`i`, 'year') \ No newline at end of file +SELECT + EXTRACT(year FROM `t0`.`i`) AS `ExtractYear(i)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/default/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/default/out.sql index e400a829e547..fe7e222fd8c7 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/default/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/default/out.sql @@ -1 +1,3 @@ -CAST(from_unixtime(`c`, "yyyy-MM-dd HH:mm:ss") AS timestamp) \ No newline at end of file +SELECT + CAST(FROM_UNIXTIME(CAST(`t0`.`c` AS INT)) AS TIMESTAMP) AS `TimestampFromUNIX(c)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/ms/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/ms/out.sql index 41cc7d327cb1..c03300822962 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/ms/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/ms/out.sql @@ -1 +1,3 @@ -CAST(from_unixtime(CAST(cast(floor(`c` / 1000) AS BIGINT) AS int), "yyyy-MM-dd HH:mm:ss") AS timestamp) \ No newline at end of file +SELECT + CAST(FROM_UNIXTIME(CAST(CAST(`t0`.`c` / 1000 AS INT) AS INT)) AS TIMESTAMP) AS `TimestampFromUNIX(c)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/us/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/us/out.sql index bcff6c32c5a6..50128d971354 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/us/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_from_integer/us/out.sql @@ -1 +1,3 @@ -CAST(from_unixtime(CAST(cast(floor(`c` / 1000000) AS BIGINT) AS int), "yyyy-MM-dd HH:mm:ss") AS timestamp) \ No newline at end of file +SELECT + CAST(FROM_UNIXTIME(CAST(CAST(`t0`.`c` / 1000000 AS INT) AS INT)) AS TIMESTAMP) AS `TimestampFromUNIX(c)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pd_timestamp/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pd_timestamp/out.sql index 40caefedf273..f8d8c3ecd268 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pd_timestamp/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pd_timestamp/out.sql @@ -1 +1,2 @@ -'2015-01-01T12:34:56' \ No newline at end of file +SELECT + '2015-01-01T12:34:56' AS `datetime.datetime(2015, 1, 1, 12, 34, 56)` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pydatetime/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pydatetime/out.sql index 40caefedf273..f8d8c3ecd268 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pydatetime/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/pydatetime/out.sql @@ -1 +1,2 @@ -'2015-01-01T12:34:56' \ No newline at end of file +SELECT + '2015-01-01T12:34:56' AS `datetime.datetime(2015, 1, 1, 12, 34, 56)` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/timestamp_function/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/timestamp_function/out.sql index 40caefedf273..f8d8c3ecd268 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/timestamp_function/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_literals/timestamp_function/out.sql @@ -1 +1,2 @@ -'2015-01-01T12:34:56' \ No newline at end of file +SELECT + '2015-01-01T12:34:56' AS `datetime.datetime(2015, 1, 1, 12, 34, 56)` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_now/out.sql b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_now/out.sql index 53945a84effc..4e6e8f3efaa7 100644 --- a/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_now/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_value_exprs/test_timestamp_now/out.sql @@ -1 +1,2 @@ -now() \ No newline at end of file +SELECT + CURRENT_TIMESTAMP() AS `TimestampNow()` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_add_default_order_by/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_add_default_order_by/out.sql index 5ca27037145c..7aca02887dac 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_add_default_order_by/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_add_default_order_by/out.sql @@ -1,7 +1,18 @@ -SELECT t0.*, - lag(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) AS `lag`, - lead(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) - t0.`f` AS `fwd_diff`, - first_value(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) AS `first`, - last_value(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) AS `last`, - lag(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`d` ASC) AS `lag2` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k`, + LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `lag`, + LEAD(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) - `t0`.`f` AS `fwd_diff`, + FIRST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g`) AS `first`, + LAST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g`) AS `last`, + LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`d` ASC NULLS LAST) AS `lag2` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_aggregate_in_projection/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_aggregate_in_projection/out.sql index eac69a8de4eb..f1f482ce6b36 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_aggregate_in_projection/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_aggregate_in_projection/out.sql @@ -1,2 +1,14 @@ -SELECT t0.*, t0.`f` / sum(t0.`f`) OVER () AS `normed_f` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k`, + `t0`.`f` / SUM(`t0`.`f`) OVER (ORDER BY NULL ASC NULLS LAST) AS `normed_f` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out1.sql index e4d6a93a43cb..94b0b10ea0c5 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out1.sql @@ -1,2 +1,3 @@ -SELECT max(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out2.sql index e4d6a93a43cb..94b0b10ea0c5 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/max/out2.sql @@ -1,2 +1,3 @@ -SELECT max(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out1.sql index 8df3c5d8d98f..183b589665ac 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out1.sql @@ -1,2 +1,3 @@ -SELECT avg(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out2.sql index 8df3c5d8d98f..183b589665ac 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/mean/out2.sql @@ -1,2 +1,3 @@ -SELECT avg(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out1.sql index debaa216f1c1..8fe0142ae10e 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out1.sql @@ -1,2 +1,3 @@ -SELECT min(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out2.sql index debaa216f1c1..8fe0142ae10e 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/min/out2.sql @@ -1,2 +1,3 @@ -SELECT min(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out1.sql index 4ac5a6cc4bd8..ab0a805400b4 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out1.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out2.sql index 4ac5a6cc4bd8..ab0a805400b4 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_cumulative_functions/sum/out2.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`f`) OVER (ORDER BY t0.`d` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_multiple_windows/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_multiple_windows/out.sql index a0e24423bb33..ba464a7151de 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_multiple_windows/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_multiple_windows/out.sql @@ -1,3 +1,4 @@ -SELECT t0.`g`, - sum(t0.`f`) OVER (PARTITION BY t0.`g`) - sum(t0.`f`) OVER () AS `result` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`g`, + SUM(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) - SUM(`t0`.`f`) OVER (ORDER BY NULL ASC NULLS LAST) AS `result` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_nested_analytic_function/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_nested_analytic_function/out.sql index 535ce547cfcf..706a705bf519 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_nested_analytic_function/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_nested_analytic_function/out.sql @@ -1,2 +1,3 @@ -SELECT lag(t0.`f` - lag(t0.`f`) OVER (ORDER BY t0.`f` ASC)) OVER (ORDER BY t0.`f` ASC) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + LAG(`t0`.`f` - LAG(`t0`.`f`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST)) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out1.sql index 4c951c7cca15..5692444e6ef9 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out1.sql @@ -1,2 +1,4 @@ -SELECT t0.`f`, (row_number() OVER (ORDER BY t0.`f` DESC) - 1) AS `revrank` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`f`, + ROW_NUMBER() OVER (ORDER BY `t0`.`f` DESC) - 1 AS `revrank` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out2.sql index 9cc34ab06aa9..fd79e6972531 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_order_by_desc/out2.sql @@ -1,3 +1,4 @@ -SELECT lag(t0.`d`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` DESC) AS `foo`, - max(t0.`a`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` DESC) AS `Max(a)` -FROM `alltypes` t0 \ No newline at end of file +SELECT + LAG(`t0`.`d`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC) AS `foo`, + MAX(`t0`.`a`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC) AS `Max(a)` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_propagate_nested_windows/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_propagate_nested_windows/out.sql index f9bfe6018076..96f8ae2f0e6c 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_propagate_nested_windows/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_propagate_nested_windows/out.sql @@ -1,2 +1,5 @@ -SELECT lag(t0.`f` - lag(t0.`f`) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC)) OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + LAG( + `t0`.`f` - LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST) + ) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_rank_functions/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_rank_functions/out.sql index 6e1c60b61afe..92c9d14f20b5 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_rank_functions/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_rank_functions/out.sql @@ -1,3 +1,5 @@ -SELECT t0.`g`, (rank() OVER (ORDER BY t0.`f` ASC) - 1) AS `minr`, - (dense_rank() OVER (ORDER BY t0.`f` ASC) - 1) AS `denser` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`g`, + RANK() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `minr`, + DENSE_RANK() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `denser` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out1.sql b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out1.sql index 7b0d0695d2eb..d4075f13c006 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out1.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out1.sql @@ -1,2 +1,14 @@ -SELECT t0.*, (row_number() OVER (PARTITION BY t0.`g`) - 1) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k`, + ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out2.sql b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out2.sql index fab4205d6c77..c423c5e14049 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out2.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_does_not_require_order_by/out2.sql @@ -1,3 +1,14 @@ -SELECT t0.*, - (row_number() OVER (PARTITION BY t0.`g` ORDER BY t0.`f` ASC) - 1) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k`, + ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_properly_composes_with_arithmetic/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_properly_composes_with_arithmetic/out.sql index d3e80ddcd836..47864c94d3db 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_row_number_properly_composes_with_arithmetic/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_row_number_properly_composes_with_arithmetic/out.sql @@ -1,2 +1,16 @@ -SELECT t0.*, (row_number() OVER (ORDER BY t0.`f` ASC) - 1) / 2 AS `new` -FROM `alltypes` t0 \ No newline at end of file +SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`c`, + `t0`.`d`, + `t0`.`e`, + `t0`.`f`, + `t0`.`g`, + `t0`.`h`, + `t0`.`i`, + `t0`.`j`, + `t0`.`k`, + ( + ROW_NUMBER() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1 + ) / 2 AS `new` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/cumulative/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/cumulative/out.sql index 2df1a73b376b..fb0afc364573 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/cumulative/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/cumulative/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_0/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_0/out.sql index 2df1a73b376b..fb0afc364573 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_0/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_0/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_10_5/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_10_5/out.sql index fd7db32b7434..0c5d75598474 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_10_5/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_10_5/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 10 PRECEDING AND 5 PRECEDING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 10 preceding AND 5 preceding) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2/out.sql index f7699801c4f8..b2c51c37cdd4 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND 2 following) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2_prec_0/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2_prec_0/out.sql index 19cb117aee8d..133948c9fac3 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2_prec_0/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_2_prec_0/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN CURRENT ROW AND 2 following) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_5_10/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_5_10/out.sql index 8512e0762038..66299747e54f 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_5_10/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/foll_5_10/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 following AND 10 following) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_0/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_0/out.sql index 29a0f6f63dc8..77b80b90de80 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_0/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_0/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5/out.sql index 69569d915f04..72fbc24d4f8b 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 5 PRECEDING AND UNBOUNDED FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND UNBOUNDED FOLLOWING) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_0/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_0/out.sql index e8649012e560..a7b4b896db68 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_0/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_0/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND CURRENT ROW) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_2/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_2/out.sql index 58bb52bbe936..15f6313e751c 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_2/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/prec_5_foll_2/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 5 PRECEDING AND 2 FOLLOWING) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND 2 following) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/trailing_10/out.sql b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/trailing_10/out.sql index 911a39e3a00d..e7baeb238d4d 100644 --- a/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/trailing_10/out.sql +++ b/ibis/backends/impala/tests/snapshots/test_window/test_window_frame_specs/trailing_10/out.sql @@ -1,2 +1,3 @@ -SELECT sum(t0.`d`) OVER (ORDER BY t0.`f` ASC ROWS BETWEEN 10 PRECEDING AND CURRENT ROW) AS `foo` -FROM `alltypes` t0 \ No newline at end of file +SELECT + SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 10 preceding AND CURRENT ROW) AS `foo` +FROM `alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/impala/tests/test_bucket_histogram.py b/ibis/backends/impala/tests/test_bucket_histogram.py index 75ca56224189..4e630f5912bb 100644 --- a/ibis/backends/impala/tests/test_bucket_histogram.py +++ b/ibis/backends/impala/tests/test_bucket_histogram.py @@ -87,4 +87,4 @@ def test_bucket_assign_labels(table, snapshot): ).name("tier2") expr = size[labelled, size[1]] - snapshot.assert_match(ImpalaCompiler.to_sql(expr), "out.sql") + snapshot.assert_match(translate(expr), "out.sql") diff --git a/ibis/backends/impala/tests/test_case_exprs.py b/ibis/backends/impala/tests/test_case_exprs.py index d5263f1e5f51..e559517e8864 100644 --- a/ibis/backends/impala/tests/test_case_exprs.py +++ b/ibis/backends/impala/tests/test_case_exprs.py @@ -95,11 +95,11 @@ def test_decimal_fillna_cast_arg(tpch_lineitem, expr_fn, snapshot): def test_identical_to(mockcon, snapshot): t = mockcon.table("functional_alltypes") expr = t.tinyint_col.identical_to(t.double_col).name("tmp") - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") def test_identical_to_special_case(snapshot): expr = ibis.NA.cast("int64").identical_to(ibis.NA.cast("int64")).name("tmp") - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") diff --git a/ibis/backends/impala/tests/test_client.py b/ibis/backends/impala/tests/test_client.py index 4f92f3d06937..e1050a1c9698 100644 --- a/ibis/backends/impala/tests/test_client.py +++ b/ibis/backends/impala/tests/test_client.py @@ -234,4 +234,4 @@ def test_list_databases(con): def test_list_tables(con, test_data_db): assert con.list_tables(database=test_data_db) - assert con.list_tables(like="*nat*", database=test_data_db) + assert con.list_tables(like=".*nat.*", database=test_data_db) diff --git a/ibis/backends/impala/tests/test_ddl.py b/ibis/backends/impala/tests/test_ddl.py index 774a72cdfa3c..822f801ec973 100644 --- a/ibis/backends/impala/tests/test_ddl.py +++ b/ibis/backends/impala/tests/test_ddl.py @@ -14,7 +14,8 @@ from ibis.tests.util import assert_equal pytest.importorskip("impala") -from ibis.backends.impala.compat import HS2Error # noqa: E402 + +from impala.error import HiveServer2Error # noqa: E402 @pytest.fixture @@ -71,7 +72,7 @@ def test_create_table_with_location_execute( def test_drop_table_not_exist(con): non_existent_table = f"ibis_table_{util.guid()}" - with pytest.raises(HS2Error): + with pytest.raises(HiveServer2Error): con.drop_table(non_existent_table) con.drop_table(non_existent_table, force=True) @@ -83,7 +84,7 @@ def test_truncate_table(con, alltypes, temp_table): try: con.truncate_table(temp_table) - except HS2Error as e: + except HiveServer2Error as e: if "AnalysisException" in e.args[0]: pytest.skip("TRUNCATE not available in this version of Impala") diff --git a/ibis/backends/impala/tests/test_ddl_compilation.py b/ibis/backends/impala/tests/test_ddl_compilation.py index 953b3cd43398..4b96400e6e8f 100644 --- a/ibis/backends/impala/tests/test_ddl_compilation.py +++ b/ibis/backends/impala/tests/test_ddl_compilation.py @@ -10,7 +10,6 @@ InsertSelect, ) from ibis.backends.impala import ddl -from ibis.backends.impala.compiler import ImpalaCompiler @pytest.fixture @@ -32,8 +31,8 @@ def test_select_basics(t, snapshot): name = "testing123456" expr = t.limit(10) - select, _ = _get_select(expr) + select = str(ibis.to_sql(expr, "impala")) stmt = InsertSelect(name, select, database="foo") result = stmt.compile() snapshot.assert_match(result, "out1.sql") @@ -174,7 +173,7 @@ def expr(t): def test_create_external_table_as(mockcon, snapshot): path = "/path/to/table" - select, _ = _get_select(mockcon.table("test1")) + select = ibis.to_sql(mockcon.table("test1"), "impala") statement = CTAS( "another_table", select, @@ -328,20 +327,7 @@ def test_avro_other_formats(t, snapshot): def _create_table(table_name, expr, database=None, can_exist=False, format="parquet"): - ast = ImpalaCompiler.to_ast(expr) - select = ast.queries[0] - statement = CTAS( - table_name, - select, - database=database, - format=format, - can_exist=can_exist, + select = str(ibis.to_sql(expr, dialect="impala")) + return CTAS( + table_name, select, database=database, format=format, can_exist=can_exist ) - return statement - - -def _get_select(expr, context=None): - ast = ImpalaCompiler.to_ast(expr, context) - select = ast.queries[0] - context = ast.context - return select, context diff --git a/ibis/backends/impala/tests/test_exprs.py b/ibis/backends/impala/tests/test_exprs.py index 01dc5f08ccd9..34aa186bbda7 100644 --- a/ibis/backends/impala/tests/test_exprs.py +++ b/ibis/backends/impala/tests/test_exprs.py @@ -5,12 +5,12 @@ import pandas as pd import pandas.testing as tm import pytest +from impala.error import HiveServer2Error from pytest import param import ibis import ibis.expr.types as ir from ibis import literal as L -from ibis.backends.impala.compiler import ImpalaCompiler from ibis.expr import api @@ -141,7 +141,7 @@ def test_builtins(con, alltypes): def _check_impala_output_types_match(con, table): - query = ImpalaCompiler.to_sql(table) + query = ibis.to_sql(table, dialect="impala") t = con.sql(query) left_schema, right_schema = t.schema(), table.schema() @@ -169,7 +169,7 @@ def _check_impala_output_types_match(con, table): ) def test_int_builtins(con, expr, expected): result = con.execute(expr) - assert result == expected, ImpalaCompiler.to_sql(expr) + assert result == expected, ibis.to_sql(expr, dialect="impala") @pytest.mark.parametrize( @@ -226,7 +226,7 @@ def test_column_types(alltypes_df, col, expected): ) def test_timestamp_builtins(con, expr, expected): result = con.execute(expr) - assert result == expected, ImpalaCompiler.to_sql(expr) + assert result == expected, ibis.to_sql(expr, dialect="impala") @pytest.mark.parametrize( @@ -245,7 +245,7 @@ def test_timestamp_builtins(con, expr, expected): ) def test_decimal_builtins(con, expr, expected): result = con.execute(expr) - assert result == expected, ImpalaCompiler.to_sql(expr) + assert result == expected, ibis.to_sql(expr, dialect="impala") def approx_equal(a, b, eps): @@ -586,7 +586,11 @@ def test_tpch_correlated_subquery_failure(con): amount_filter = tpch.amount > conditional_avg expr = tpch[amount_filter].limit(0) - con.explain(expr) + + # impala can't plan this because its correlated subquery implementation is + # broken: it cannot detect the outer reference inside the inner query + with pytest.raises(HiveServer2Error, match="Could not resolve .+ reference"): + con.explain(expr) def test_non_equijoin(con): diff --git a/ibis/backends/impala/tests/test_in_not_in.py b/ibis/backends/impala/tests/test_in_not_in.py index fb76bd919096..ceeb3aebe002 100644 --- a/ibis/backends/impala/tests/test_in_not_in.py +++ b/ibis/backends/impala/tests/test_in_not_in.py @@ -3,7 +3,6 @@ import pytest from ibis import literal as L -from ibis.backends.impala.compiler import ImpalaCompiler from ibis.backends.impala.tests.conftest import translate @@ -35,5 +34,5 @@ def test_isin_notin_in_select(table, method_name, snapshot): values = ["foo", "bar"] method = getattr(table.g, method_name) filtered = table[method(values)] - result = ImpalaCompiler.to_sql(filtered) + result = translate(filtered) snapshot.assert_match(result, "out.sql") diff --git a/ibis/backends/impala/tests/test_parquet_ddl.py b/ibis/backends/impala/tests/test_parquet_ddl.py index fda0c24e8403..86ed5250c02e 100644 --- a/ibis/backends/impala/tests/test_parquet_ddl.py +++ b/ibis/backends/impala/tests/test_parquet_ddl.py @@ -9,7 +9,7 @@ pytest.importorskip("impala") -from ibis.backends.impala.compat import HS2Error # noqa: E402 +from impala.error import HiveServer2Error # noqa: E402 def test_parquet_file_with_name(con, test_data_dir, temp_table): @@ -91,5 +91,5 @@ def test_create_table_persist_fails_if_called_twice(con, temp_table, test_data_d hdfs_path = pjoin(test_data_dir, "impala/parquet/region") con.parquet_file(hdfs_path, like_table="region", name=temp_table) - with pytest.raises(HS2Error): + with pytest.raises(HiveServer2Error): con.parquet_file(hdfs_path, like_table="region", name=temp_table) diff --git a/ibis/backends/impala/tests/test_partition.py b/ibis/backends/impala/tests/test_partition.py index ae096654c677..4549ae4652a2 100644 --- a/ibis/backends/impala/tests/test_partition.py +++ b/ibis/backends/impala/tests/test_partition.py @@ -13,7 +13,7 @@ pytest.importorskip("impala") -from ibis.backends.impala.compat import ImpylaError # noqa: E402 +from impala.error import Error as ImpylaError # noqa: E402 @pytest.fixture diff --git a/ibis/backends/impala/tests/test_sql.py b/ibis/backends/impala/tests/test_sql.py index 53b811273a90..93f0a5f9600e 100644 --- a/ibis/backends/impala/tests/test_sql.py +++ b/ibis/backends/impala/tests/test_sql.py @@ -30,13 +30,13 @@ def test_join_no_predicates_for_impala(con, join_type, snapshot): t2 = con.table("star2") joined = getattr(t1, join_type)(t2)[[t1]] - result = ImpalaCompiler.to_sql(joined) + result = ibis.to_sql(joined, dialect="impala") snapshot.assert_match(result, "out.sql") def test_limit_cte_extract(limit_cte_extract, snapshot): case = limit_cte_extract - result = ImpalaCompiler.to_sql(case) + result = ibis.to_sql(case, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -45,7 +45,7 @@ def test_nested_join_base(snapshot): counts = t.group_by("uuid").size() max_counts = counts.group_by("uuid").aggregate(max_count=lambda x: x[1].max()) result = max_counts.left_join(counts, "uuid").select(counts) - compiled_result = ImpalaCompiler.to_sql(result) + compiled_result = ibis.to_sql(result, dialect="impala") snapshot.assert_match(compiled_result, "out.sql") @@ -65,7 +65,7 @@ def test_nested_joins_single_cte(snapshot): result = main_kw.left_join(last_visit, "uuid").select( main_kw, last_visit.last_visit ) - compiled_result = ImpalaCompiler.to_sql(result) + compiled_result = ibis.to_sql(result, dialect="impala") snapshot.assert_match(compiled_result, "out.sql") @@ -87,7 +87,7 @@ def test_nested_join_multiple_ctes(snapshot): # that for now see issue #1295 cond = joined3.movieid.isin(top_user_old_movie_ids.movieid) result = joined3[cond] - compiled_result = ImpalaCompiler.to_sql(result) + compiled_result = ibis.to_sql(result, dialect="impala") snapshot.assert_match(compiled_result, "out.sql") @@ -101,7 +101,7 @@ def f(t): return t.a.isin(["foo"]) & t.c.notnull() expr = (~f(t)).name("tmp") - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -111,7 +111,7 @@ def test_join_with_nested_or_condition(snapshot): joined = t1.join(t2, [t1.a == t2.a, (t1.a != t2.b) | (t1.b != t2.a)]) expr = joined[t1] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -121,7 +121,7 @@ def test_join_with_nested_xor_condition(snapshot): joined = t1.join(t2, [t1.a == t2.a, (t1.a != t2.b) ^ (t1.b != t2.a)]) expr = joined[t1] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -131,7 +131,7 @@ def test_is_parens(method, snapshot): func = operator.methodcaller(method) expr = t[func(t.a) == func(t.b)] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -139,7 +139,7 @@ def test_is_parens_identical_to(snapshot): t = ibis.table([("a", "string"), ("b", "string")], "table") expr = t[t.a.identical_to(None) == t.b.identical_to(None)] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -162,7 +162,7 @@ def test_join_aliasing(snapshot): .view() ) result = agg.join(test5, agg.d == test5.d)[agg, test5.total] - result = ImpalaCompiler.to_sql(result) + result = ibis.to_sql(result, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -170,7 +170,7 @@ def test_multiple_filters(snapshot): t = ibis.table([("a", "int64"), ("b", "string")], name="t0") filt = t[t.a < 100] expr = filt[filt.a == filt.a.max()] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -179,7 +179,7 @@ def test_multiple_filters2(snapshot): filt = t[t.a < 100] expr = filt[filt.a == filt.a.max()] expr = expr[expr.b == "a"] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") diff --git a/ibis/backends/impala/tests/test_udf.py b/ibis/backends/impala/tests/test_udf.py index ba489522f180..5891df86dc53 100644 --- a/ibis/backends/impala/tests/test_udf.py +++ b/ibis/backends/impala/tests/test_udf.py @@ -97,18 +97,24 @@ def all_cols(i8, i16, i32, i64, d, f, dec, s, b, t): def test_sql_generation(snapshot): - func = api.scalar_function(["string"], "string", name="Tester") - func.register("identity", "udf_testing") - + func = api.scalar_function( + ["string"], "string", name="identity", database="udf_testing" + ) result = func("hello world") snapshot.assert_match(ibis.impala.compile(result), "out.sql") def test_sql_generation_from_infoclass(snapshot): - func = api.wrap_udf("test.so", ["string"], "string", "info_test") + func = api.wrap_udf( + "test.so", + ["string"], + "string", + "info_test", + name="info_test", + database="udf_testing", + ) repr(func) - func.register("info_test", "udf_testing") result = func("hello world").name("tmp") snapshot.assert_match(ibis.impala.compile(result), "out.sql") @@ -242,14 +248,12 @@ def test_mult_args(i32, d, s, b, t): def _register_udf(inputs, output, name): - func = api.scalar_function(inputs, output, name=name) - func.register(name, "ibis_testing") + func = api.scalar_function(inputs, output, name=name, database="ibis_testing") return func def _register_uda(inputs, output, name): - func = api.aggregate_function(inputs, output, name=name) - func.register(name, "ibis_testing") + func = api.aggregate_function(inputs, output, name=name, database="ibis_testing") return func @@ -438,8 +442,9 @@ def test_udf_varargs(con, alltypes, udf_ll, test_data_db): name = f"add_numbers_{util.guid()[:4]}" input_sig = rules.varargs(rules.double) - func = api.wrap_udf(udf_ll, input_sig, "double", "AddNumbers", name=name) - func.register(name, test_data_db) + func = api.wrap_udf( + udf_ll, input_sig, "double", "AddNumbers", name=name, database=test_data_db + ) con.create_function(func, database=test_data_db) expr = func(t.double_col, t.double_col) @@ -459,12 +464,10 @@ def test_drop_uda_not_exists(con): def udf_creation_to_op(udf_ll, con, test_data_db, name, symbol, inputs, output): - func = api.wrap_udf(udf_ll, inputs, output, symbol, name) + func = api.wrap_udf(udf_ll, inputs, output, symbol, name, database=test_data_db) con.create_function(func, database=test_data_db) - func.register(name, test_data_db) - assert con.exists_udf(name, test_data_db) return func @@ -492,18 +495,18 @@ def conforming_wrapper(where, inputs, output, prefix, serialize=True, name=None) @pytest.fixture -def wrapped_count_uda(uda_so): +def wrapped_count_uda(uda_so, test_data_db): name = f"user_count_{util.guid()}" - return api.wrap_uda(uda_so, ["int32"], "int64", "CountUpdate", name=name) + return api.wrap_uda( + uda_so, ["int32"], "int64", "CountUpdate", name=name, database=test_data_db + ) def test_count_uda(con, alltypes, test_data_db, wrapped_count_uda): - func = wrapped_count_uda - func.register(func.name, test_data_db) - con.create_function(func, database=test_data_db) + con.create_function(wrapped_count_uda, database=test_data_db) # it works! - func(alltypes.int_col).execute() + wrapped_count_uda(alltypes.int_col).execute() def test_list_udas(con, wrapped_count_uda): @@ -512,10 +515,12 @@ def test_list_udas(con, wrapped_count_uda): funcs = con.list_udas() - (f,) = (ff for ff in funcs if func.name == ff.name) - assert f.name == func.name - assert f.inputs == func.inputs - assert f.output == func.output + ((name, inputs, output),) = ( + (name, inputs, output) for _, name, inputs, output in funcs if func.name == name + ) + assert func.name == name + assert func.inputs == inputs + assert func.output == output @pytest.fixture diff --git a/ibis/backends/impala/tests/test_value_exprs.py b/ibis/backends/impala/tests/test_value_exprs.py index a4f75ff4673a..406581936b15 100644 --- a/ibis/backends/impala/tests/test_value_exprs.py +++ b/ibis/backends/impala/tests/test_value_exprs.py @@ -5,8 +5,8 @@ from pytest import param import ibis +import ibis.common.exceptions as com from ibis import literal as L -from ibis.backends.impala.compiler import ImpalaCompiler from ibis.backends.impala.tests.conftest import translate @@ -33,33 +33,14 @@ def test_literals(value, snapshot): snapshot.assert_match(result, "out.sql") -def test_column_ref_table_aliases(snapshot): - context = ImpalaCompiler.make_context() - +def test_column_ref_table_aliases(): table1 = ibis.table([("key1", "string"), ("value1", "double")]) - table2 = ibis.table([("key2", "string"), ("value and2", "double")]) - context.set_ref(table1.op(), "t0") - context.set_ref(table2.op(), "t1") - expr = table1["value1"] - table2["value and2"] - result = translate(expr, context=context) - snapshot.assert_match(result, "out.sql") - - -def test_column_ref_quoting(): - schema = [("has a space", "double")] - table = ibis.table(schema) - translate(table["has a space"], named="`has a space`") - - -def test_identifier_quoting(): - schema = [("date", "double"), ("table", "string")] - table = ibis.table(schema) - translate(table["date"], named="`date`") - translate(table["table"], named="`table`") + with pytest.raises(com.RelationError, match="multiple base table references"): + translate(expr) @pytest.mark.parametrize( @@ -73,7 +54,7 @@ def test_identifier_quoting(): ) def test_named_expressions(table, expr_fn, snapshot): expr = expr_fn(table) - result = translate(expr, named=True) + result = translate(expr) snapshot.assert_match(result, "out.sql") @@ -200,7 +181,7 @@ def test_sql_extract(table, snapshot): table.i.day().name("day"), ] - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, "out.sql") @@ -270,18 +251,12 @@ def test_correlated_predicate_subquery(table, snapshot): t0 = table t1 = t0.view() - expr = t0.g == t1.g + # both are valid constructions + expr1 = t0[t0.g == t1.g] + expr2 = t1[t0.g == t1.g] - ctx = ImpalaCompiler.make_context() - ctx.make_alias(t0.op()) - - # Grab alias from parent context - subctx = ctx.subcontext() - subctx.make_alias(t1.op()) - subctx.make_alias(t0.op()) - - result = translate(expr, context=subctx) - snapshot.assert_match(result, "out.sql") + snapshot.assert_match(translate(expr1), "out1.sql") + snapshot.assert_match(translate(expr2), "out2.sql") @pytest.mark.parametrize( diff --git a/ibis/backends/impala/tests/test_window.py b/ibis/backends/impala/tests/test_window.py index a3c1aca3b1d7..5f0451f16adf 100644 --- a/ibis/backends/impala/tests/test_window.py +++ b/ibis/backends/impala/tests/test_window.py @@ -18,7 +18,7 @@ def alltypes(mockcon): def assert_sql_equal(expr, snapshot, out="out.sql"): - result = ImpalaCompiler.to_sql(expr) + result = ibis.to_sql(expr, dialect="impala") snapshot.assert_match(result, out) @@ -71,7 +71,7 @@ def test_window_rows_with_max_lookback(alltypes): w = ibis.trailing_window(mlb, order_by=t.i) expr = t.a.sum().over(w) with pytest.raises(NotImplementedError): - ImpalaCompiler.to_sql(expr) + ibis.to_sql(expr, dialect="impala") @pytest.mark.parametrize("name", ["sum", "min", "max", "mean"]) @@ -148,19 +148,6 @@ def test_row_number_properly_composes_with_arithmetic(alltypes, snapshot): assert_sql_equal(expr, snapshot) -@pytest.mark.parametrize( - ["column", "op"], - [("f", "approx_nunique"), ("f", "approx_median"), ("g", "group_concat")], -) -def test_unsupported_aggregate_functions(alltypes, column, op): - t = alltypes - w = ibis.window(order_by=t.d) - expr = getattr(t[column], op)() - proj = t.select(foo=expr.over(w)) - with pytest.raises(com.TranslationError): - ImpalaCompiler.to_sql(proj) - - def test_propagate_nested_windows(alltypes, snapshot): # GH #469 t = alltypes diff --git a/ibis/backends/impala/udf.py b/ibis/backends/impala/udf.py index 100a41791f30..7fc21d1fb31c 100644 --- a/ibis/backends/impala/udf.py +++ b/ibis/backends/impala/udf.py @@ -14,31 +14,22 @@ from __future__ import annotations import abc -import re +import inspect import ibis.common.exceptions as com import ibis.expr.datatypes as dt import ibis.expr.operations as ops -import ibis.expr.rules as rlz from ibis import util -from ibis.backends.base.sql.registry import fixed_arity, sql_type_names -from ibis.backends.impala.compiler import ImpalaExprTranslator -from ibis.legacy.udf.validate import validate_output_type -__all__ = [ - "add_operation", - "scalar_function", - "aggregate_function", - "wrap_udf", - "wrap_uda", -] +__all__ = ["scalar_function", "aggregate_function", "wrap_udf", "wrap_uda"] -class Function(metaclass=abc.ABCMeta): - def __init__(self, inputs, output, name): +class Function(abc.ABC): + def __init__(self, inputs, output, name, database): self.inputs = tuple(map(dt.dtype, inputs)) self.output = dt.dtype(output) self.name = name or util.guid() + self.database = database self._klass = self._create_operation_class() @abc.abstractmethod @@ -46,38 +37,50 @@ def _create_operation_class(self): pass def __repr__(self): - klass = type(self).__name__ - return f"{klass}({self.name}, {self.inputs!r}, {self.output!r})" + ident = ".".join(filter(None, (self.database, self.name))) + return f"{ident}({self.inputs!r}, {self.output!r})" def __call__(self, *args): - return self._klass(*args).to_expr() + return self._klass(*args) - def register(self, name: str, database: str) -> None: - """Register the given operation. + def _make_fn(self): + def fn(*args, **kwargs): + ... - Parameters - ---------- - name - Used in issuing statements to SQL engine - database - Database the relevant operator is registered to - """ - add_operation(self._klass, name, database) + fn.__name__ = self.name + fn.__signature__ = inspect.Signature( + parameters=[ + inspect.Parameter( + f"input{i:d}", + annotation=input, + kind=inspect.Parameter.POSITIONAL_ONLY, + ) + for i, input in enumerate(self.inputs) + ], + return_annotation=self.output, + ) + + return fn class ScalarFunction(Function): def _create_operation_class(self): - fields = {f"_{i}": rlz.ValueOf(dtype) for i, dtype in enumerate(self.inputs)} - fields["dtype"] = self.output - fields["shape"] = rlz.shape_like("args") - return type(f"UDF_{self.name}", (ops.Value,), fields) + return ops.scalar.builtin( + fn=self._make_fn(), + name=self.name, + signature=(self.inputs, self.output), + schema=self.database, + ) class AggregateFunction(Function): def _create_operation_class(self): - fields = {f"_{i}": rlz.ValueOf(dtype) for i, dtype in enumerate(self.inputs)} - fields["dtype"] = self.output - return type(f"UDA_{self.name}", (ops.Reduction,), fields) + return ops.agg.builtin( + fn=self._make_fn(), + name=self.name, + signature=(self.inputs, self.output), + schema=self.database, + ) class ImpalaFunction: @@ -93,28 +96,19 @@ def _check_library(self): if suffix not in [".so", ".ll"]: raise ValueError("Invalid file type. Must be .so or .ll ") - def hash(self): - raise NotImplementedError - class ImpalaUDF(ScalarFunction, ImpalaFunction): """Feel free to customize my __doc__ or wrap in a nicer user API.""" - def __init__(self, inputs, output, so_symbol=None, lib_path=None, name=None): + def __init__( + self, inputs, output, so_symbol=None, lib_path=None, name=None, database=None + ): + from ibis.legacy.udf.validate import validate_output_type + validate_output_type(output) self.so_symbol = so_symbol ImpalaFunction.__init__(self, name=name, lib_path=lib_path) - ScalarFunction.__init__(self, inputs, output, name=self.name) - - def hash(self): - # TODO: revisit this later - # from hashlib import sha1 - # val = self.so_symbol - # for in_type in self.inputs: - # val += in_type.name() - - # return sha1(val).hexdigest() - pass + ScalarFunction.__init__(self, inputs, output, name=self.name, database=database) class ImpalaUDA(AggregateFunction, ImpalaFunction): @@ -129,6 +123,7 @@ def __init__( serialize_fn=None, lib_path=None, name=None, + database=None, ): self.init_fn = init_fn self.update_fn = update_fn @@ -136,10 +131,14 @@ def __init__( self.finalize_fn = finalize_fn self.serialize_fn = serialize_fn + from ibis.legacy.udf.validate import validate_output_type + validate_output_type(output) ImpalaFunction.__init__(self, name=name, lib_path=lib_path) - AggregateFunction.__init__(self, inputs, output, name=self.name) + AggregateFunction.__init__( + self, inputs, output, name=self.name, database=database + ) def _check_library(self): suffix = self.lib_path[-3:] @@ -159,6 +158,7 @@ def wrap_uda( finalize_fn: str | None = None, serialize_fn: str | None = None, name: str | None = None, + database: str | None = None, ): """Creates a callable aggregation function object. @@ -185,10 +185,8 @@ def wrap_uda( UDAs. name Used internally to track function - - Returns - ------- - container : UDA object + database + Name of database """ return ImpalaUDA( inputs, @@ -200,10 +198,11 @@ def wrap_uda( serialize_fn=serialize_fn, name=name, lib_path=hdfs_file, + database=database, ) -def wrap_udf(hdfs_file, inputs, output, so_symbol, name=None): +def wrap_udf(hdfs_file, inputs, output, so_symbol, name=None, database=None): """Creates a callable scalar function object. Must be created in Impala to be used. @@ -220,13 +219,17 @@ def wrap_udf(hdfs_file, inputs, output, so_symbol, name=None): C++ function name for relevant UDF name Used internally to track function + database + Name of database """ - func = ImpalaUDF(inputs, output, so_symbol, name=name, lib_path=hdfs_file) + func = ImpalaUDF( + inputs, output, so_symbol, name=name, lib_path=hdfs_file, database=database + ) return func -def scalar_function(inputs, output, name=None): - """Creates an operator class that can be passed to add_operation(). +def scalar_function(inputs, output, name=None, database=None): + """Create an operator class. Parameters ---------- @@ -236,96 +239,24 @@ def scalar_function(inputs, output, name=None): Ibis data type name Used internally to track function + database + Name of database """ - return ScalarFunction(inputs, output, name=name) + return ScalarFunction(inputs, output, name=name, database=database) -def aggregate_function(inputs, output, name=None): - """Creates an operator class that can be passed to add_operation(). +def aggregate_function(inputs, output, name=None, database=None): + """Create an operator class. Parameters ---------- - inputs: list of strings - Ibis data type names - output: string - Ibis data type - name: string, optional + inputs + Ibis data type names + output + Ibis data type + name Used internally to track function + database + Name of database """ - return AggregateFunction(inputs, output, name=name) - - -def add_operation(op, func_name, db): - """Registers the given operation within the Ibis SQL translation toolchain. - - Parameters - ---------- - op - operator class - func_name - used in issuing statements to SQL engine - db - database the relevant operator is registered to - """ - full_name = f"{db}.{func_name}" - arity = len(op.__signature__.parameters) - translator = fixed_arity(full_name, arity) - - ImpalaExprTranslator._registry[op] = translator - - -def parse_type(t): - t = t.lower() - if t in _impala_to_ibis_type: - return _impala_to_ibis_type[t] - elif "varchar" in t or "char" in t: - return "string" - elif "decimal" in t: - result = dt.dtype(t) - if result: - return t - else: - return ValueError(t) - else: - raise Exception(t) - - -_VARCHAR_RE = re.compile(r"varchar\((\d+)\)") - - -def _parse_varchar(t): - m = _VARCHAR_RE.match(t) - if m: - return "string" - return None - - -def _impala_type_to_ibis(tval): - if tval in _impala_to_ibis_type: - return _impala_to_ibis_type[tval] - return tval - - -def _ibis_string_to_impala(tval): - if tval in sql_type_names: - return sql_type_names[tval] - result = dt.validate_type(tval) - return repr(result) if result else None - - -_impala_to_ibis_type = { - "boolean": "boolean", - "tinyint": "int8", - "smallint": "int16", - "int": "int32", - "bigint": "int64", - "float": "float32", - "double": "float64", - "string": "string", - "varchar": "string", - "char": "string", - "timestamp": "timestamp", - "decimal": "decimal", - "date": "date", - "void": "null", -} + return AggregateFunction(inputs, output, name=name, database=database) diff --git a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/impala/out.sql new file mode 100644 index 000000000000..f63de03c314a --- /dev/null +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/impala/out.sql @@ -0,0 +1,5 @@ +SELECT + `t0`.`id`, + `t0`.`bool_col` +FROM `functional_alltypes` AS `t0` +LIMIT 11 \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/impala/out.sql new file mode 100644 index 000000000000..f63de03c314a --- /dev/null +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/impala/out.sql @@ -0,0 +1,5 @@ +SELECT + `t0`.`id`, + `t0`.`bool_col` +FROM `functional_alltypes` AS `t0` +LIMIT 11 \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/impala/out.sql new file mode 100644 index 000000000000..d8a9c4090dc1 --- /dev/null +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/impala/out.sql @@ -0,0 +1,3 @@ +SELECT + SUM(`t0`.`bigint_col`) AS `Sum(bigint_col)` +FROM `functional_alltypes` AS `t0` \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/impala/out.sql new file mode 100644 index 000000000000..d4b1b19815b0 --- /dev/null +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/impala/out.sql @@ -0,0 +1,10 @@ +SELECT + * +FROM ( + SELECT + `t0`.`id`, + `t0`.`bool_col` + FROM `functional_alltypes` AS `t0` + LIMIT 10 +) AS `t2` +LIMIT 11 \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_sql/test_group_by_has_index/impala/out.sql b/ibis/backends/tests/snapshots/test_sql/test_group_by_has_index/impala/out.sql index f1c63ad8f7e4..ac006b1d5f25 100644 --- a/ibis/backends/tests/snapshots/test_sql/test_group_by_has_index/impala/out.sql +++ b/ibis/backends/tests/snapshots/test_sql/test_group_by_has_index/impala/out.sql @@ -1,5 +1,5 @@ SELECT - CASE t0.`continent` + CASE `t0`.`continent` WHEN 'NA' THEN 'North America' WHEN 'SA' @@ -16,7 +16,7 @@ SELECT THEN 'Antarctica' ELSE 'Unknown continent' END AS `cont`, - SUM(t0.`population`) AS `total_pop` -FROM `countries` AS t0 + SUM(`t0`.`population`) AS `total_pop` +FROM `countries` AS `t0` GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_sql/test_isin_bug/impala/out.sql b/ibis/backends/tests/snapshots/test_sql/test_isin_bug/impala/out.sql index 409cf82c7981..db5ddb124e86 100644 --- a/ibis/backends/tests/snapshots/test_sql/test_isin_bug/impala/out.sql +++ b/ibis/backends/tests/snapshots/test_sql/test_isin_bug/impala/out.sql @@ -1,13 +1,9 @@ SELECT - t0.`x` IN ( + `t0`.`x` IN ( SELECT - t1.`x` - FROM ( - SELECT - t0.* - FROM `t` AS t0 - WHERE - t0.`x` > 2 - ) AS t1 - ) AS `InColumn(x, x)` -FROM `t` AS t0 \ No newline at end of file + `t0`.`x` + FROM `t` AS `t0` + WHERE + `t0`.`x` > 2 + ) AS `InSubquery(x)` +FROM `t` AS `t0` \ No newline at end of file diff --git a/ibis/backends/tests/test_aggregation.py b/ibis/backends/tests/test_aggregation.py index d36d2017f8b6..8104fb670471 100644 --- a/ibis/backends/tests/test_aggregation.py +++ b/ibis/backends/tests/test_aggregation.py @@ -18,6 +18,7 @@ ClickHouseDatabaseError, ExaQueryError, GoogleBadRequest, + ImpalaHiveServer2Error, MySQLNotSupportedError, PolarsInvalidOperationError, Py4JError, @@ -807,7 +808,7 @@ def test_reduction_ops( reason="backend doesn't support count distinct with multiple columns", ) @pytest.mark.notyet( - ["datafusion", "impala"], + ["datafusion"], raises=com.OperationNotDefinedError, reason="no one has attempted implementation yet", ) @@ -877,7 +878,6 @@ def test_count_distinct_star(alltypes, df, ibis_cond, pandas_cond): "bigquery", "dask", "datafusion", - "impala", "mssql", "polars", "sqlite", @@ -887,7 +887,9 @@ def test_count_distinct_star(alltypes, df, ibis_cond, pandas_cond): ], raises=com.OperationNotDefinedError, ), - pytest.mark.notyet(["mysql"], raises=com.UnsupportedBackendType), + pytest.mark.notyet( + ["mysql", "impala"], raises=com.UnsupportedBackendType + ), pytest.mark.notyet( ["snowflake"], reason="backend doesn't implement array of quantiles as input", @@ -1527,7 +1529,8 @@ def test_grouped_case(backend, con): reason="Dask does not windowize this operation correctly", raises=AssertionError, ) -@pytest.mark.notyet(["impala", "flink"], raises=com.UnsupportedOperationError) +@pytest.mark.notyet(["flink"], raises=com.UnsupportedOperationError) +@pytest.mark.notyet(["impala"], raises=ImpalaHiveServer2Error) @pytest.mark.notyet(["clickhouse"], raises=ClickHouseDatabaseError) @pytest.mark.notyet(["druid"], raises=PyDruidProgrammingError) @pytest.mark.notyet(["snowflake"], raises=SnowflakeProgrammingError) diff --git a/ibis/backends/tests/test_array.py b/ibis/backends/tests/test_array.py index 603123fd6299..ba95de31c325 100644 --- a/ibis/backends/tests/test_array.py +++ b/ibis/backends/tests/test_array.py @@ -19,6 +19,7 @@ from ibis.backends.tests.errors import ( ClickHouseDatabaseError, GoogleBadRequest, + ImpalaHiveServer2Error, MySQLOperationalError, PolarsComputeError, PsycoPg2IndeterminateDatatype, @@ -34,7 +35,15 @@ reason="No array support", raises=Exception, ), - pytest.mark.notyet(["impala"], reason="No array support", raises=Exception), + pytest.mark.notyet( + ["impala"], + reason="No array support", + raises=( + com.UnsupportedBackendType, + com.OperationNotDefinedError, + ImpalaHiveServer2Error, + ), + ), pytest.mark.notimpl(["druid", "oracle"], raises=Exception), ] @@ -372,7 +381,7 @@ def test_array_slice(backend, start, stop): @builtin_array @pytest.mark.notimpl( - ["datafusion", "impala", "mssql", "polars", "snowflake", "sqlite"], + ["datafusion", "mssql", "polars", "snowflake", "sqlite"], raises=com.OperationNotDefinedError, ) @pytest.mark.notimpl( @@ -416,7 +425,7 @@ def test_array_map(con, input, output): @builtin_array @pytest.mark.notimpl( - ["dask", "datafusion", "impala", "mssql", "pandas", "polars", "snowflake"], + ["dask", "datafusion", "mssql", "pandas", "polars", "snowflake"], raises=com.OperationNotDefinedError, ) @pytest.mark.notimpl( @@ -461,7 +470,6 @@ def test_array_filter(con, input, output): @builtin_array @pytest.mark.notimpl(["mssql", "polars"], raises=com.OperationNotDefinedError) @pytest.mark.notimpl(["dask"], raises=com.OperationNotDefinedError) -@pytest.mark.never(["impala"], reason="array_types table isn't defined") def test_array_contains(backend, con): t = backend.array_types expr = t.x.contains(1) @@ -471,9 +479,7 @@ def test_array_contains(backend, con): @builtin_array -@pytest.mark.notimpl( - ["dask", "impala", "mssql", "polars"], raises=com.OperationNotDefinedError -) +@pytest.mark.notimpl(["dask", "mssql", "polars"], raises=com.OperationNotDefinedError) @pytest.mark.broken( ["datafusion"], reason="internal error as of 34.0.0", raises=Exception ) @@ -486,9 +492,7 @@ def test_array_position(backend, con): @builtin_array -@pytest.mark.notimpl( - ["dask", "impala", "mssql", "polars"], raises=com.OperationNotDefinedError -) +@pytest.mark.notimpl(["dask", "mssql", "polars"], raises=com.OperationNotDefinedError) def test_array_remove(con): t = ibis.memtable({"a": [[3, 2], [], [42, 2], [2, 2], []]}) expr = t.a.remove(2) @@ -499,8 +503,7 @@ def test_array_remove(con): @builtin_array @pytest.mark.notimpl( - ["dask", "datafusion", "impala", "mssql", "polars"], - raises=com.OperationNotDefinedError, + ["dask", "datafusion", "mssql", "polars"], raises=com.OperationNotDefinedError ) @pytest.mark.notimpl( ["sqlite"], raises=NotImplementedError, reason="Unsupported type: Array..." @@ -545,8 +548,7 @@ def test_array_unique(con, input, expected): @builtin_array @pytest.mark.notimpl( - ["dask", "datafusion", "impala", "mssql", "polars"], - raises=com.OperationNotDefinedError, + ["dask", "datafusion", "mssql", "polars"], raises=com.OperationNotDefinedError ) def test_array_sort(backend, con): t = ibis.memtable({"a": [[3, 2], [], [42, 42], []], "id": range(4)}) @@ -558,8 +560,7 @@ def test_array_sort(backend, con): @builtin_array @pytest.mark.notimpl( - ["dask", "datafusion", "impala", "mssql", "polars"], - raises=com.OperationNotDefinedError, + ["dask", "datafusion", "mssql", "polars"], raises=com.OperationNotDefinedError ) @pytest.mark.notyet( ["bigquery"], @@ -578,7 +579,7 @@ def test_array_union(con): @builtin_array @pytest.mark.notimpl( - ["dask", "datafusion", "impala", "mssql", "pandas", "polars", "flink"], + ["dask", "datafusion", "mssql", "pandas", "polars", "flink"], raises=com.OperationNotDefinedError, ) @pytest.mark.notimpl( @@ -639,7 +640,7 @@ def test_unnest_struct(con): @builtin_array @pytest.mark.never( - ["impala", "mssql"], raises=com.OperationNotDefinedError, reason="no array support" + ["mssql"], raises=com.OperationNotDefinedError, reason="no array support" ) @pytest.mark.notimpl( ["dask", "datafusion", "druid", "oracle", "pandas", "polars", "postgres"], @@ -869,16 +870,7 @@ def test_unnest_empty_array(con): @builtin_array @pytest.mark.notimpl( - [ - "datafusion", - "impala", - "mssql", - "polars", - "snowflake", - "sqlite", - "dask", - "pandas", - ], + ["datafusion", "mssql", "polars", "snowflake", "sqlite", "dask", "pandas"], raises=com.OperationNotDefinedError, ) @pytest.mark.notimpl(["sqlite"], raises=NotImplementedError) @@ -894,16 +886,7 @@ def test_array_map_with_conflicting_names(backend, con): @builtin_array @pytest.mark.notimpl( - [ - "datafusion", - "impala", - "mssql", - "polars", - "snowflake", - "sqlite", - "dask", - "pandas", - ], + ["datafusion", "mssql", "polars", "snowflake", "sqlite", "dask", "pandas"], raises=com.OperationNotDefinedError, ) def test_complex_array_map(con): @@ -1050,6 +1033,9 @@ def test_timestamp_range_zero_step(con, start, stop, step, tzinfo): @pytest.mark.notimpl(["flink"], raises=Py4JJavaError) +@pytest.mark.notimpl( + ["impala"], raises=AssertionError, reason="backend doesn't support arrays" +) def test_repr_timestamp_array(con, monkeypatch): monkeypatch.setattr(ibis.options, "interactive", True) assert ibis.options.interactive is True diff --git a/ibis/backends/tests/test_asof_join.py b/ibis/backends/tests/test_asof_join.py index 6846bf96b4d0..a0a67a36c687 100644 --- a/ibis/backends/tests/test_asof_join.py +++ b/ibis/backends/tests/test_asof_join.py @@ -81,7 +81,16 @@ def time_keyed_right(time_keyed_df2): ("direction", "op"), [("backward", operator.ge), ("forward", operator.le)] ) @pytest.mark.notyet( - ["datafusion", "snowflake", "trino", "postgres", "mysql", "pyspark", "druid"] + [ + "datafusion", + "snowflake", + "trino", + "postgres", + "mysql", + "pyspark", + "druid", + "impala", + ] ) def test_asof_join(con, time_left, time_right, time_df1, time_df2, direction, op): on = op(time_left["time"], time_right["time"]) @@ -107,7 +116,16 @@ def test_asof_join(con, time_left, time_right, time_df1, time_df2, direction, op ["clickhouse"], raises=AssertionError, reason="`time` is truncated to seconds" ) @pytest.mark.notyet( - ["datafusion", "snowflake", "trino", "postgres", "mysql", "pyspark", "druid"] + [ + "datafusion", + "snowflake", + "trino", + "postgres", + "mysql", + "pyspark", + "druid", + "impala", + ] ) def test_keyed_asof_join_with_tolerance( con, diff --git a/ibis/backends/tests/test_dot_sql.py b/ibis/backends/tests/test_dot_sql.py index cb545345a2b0..5aec8be3d3b2 100644 --- a/ibis/backends/tests/test_dot_sql.py +++ b/ibis/backends/tests/test_dot_sql.py @@ -229,7 +229,10 @@ def test_dot_sql_reuse_alias_with_different_types(backend, alltypes, df): _NO_SQLGLOT_DIALECT = {"pandas", "dask", "druid", "flink"} no_sqlglot_dialect = sorted( - param(backend, marks=pytest.mark.xfail) for backend in _NO_SQLGLOT_DIALECT + # TODO(cpcloud): remove the strict=False hack once backends are ported to + # sqlglot + param(backend, marks=pytest.mark.xfail(strict=False)) + for backend in _NO_SQLGLOT_DIALECT ) @@ -287,7 +290,7 @@ def test_con_dot_sql_transpile(backend, con, dialect, df): @dot_sql_notimpl @dot_sql_never -@pytest.mark.notimpl(["druid", "flink", "impala", "polars"]) +@pytest.mark.notimpl(["druid", "flink", "polars"]) @pytest.mark.notyet(["snowflake"], reason="snowflake column names are case insensitive") def test_order_by_no_projection(backend): con = backend.connection @@ -307,5 +310,5 @@ def test_order_by_no_projection(backend): @dot_sql_never @pytest.mark.notyet(["polars"], raises=PolarsComputeError) def test_dot_sql_limit(con): - expr = con.sql("SELECT 'abc' ts").limit(1) + expr = con.sql("SELECT * FROM (SELECT 'abc' ts) _").limit(1) assert expr.execute().equals(pd.DataFrame({"ts": ["abc"]})) diff --git a/ibis/backends/tests/test_generic.py b/ibis/backends/tests/test_generic.py index aebf33c7c742..65e68d7b08be 100644 --- a/ibis/backends/tests/test_generic.py +++ b/ibis/backends/tests/test_generic.py @@ -1230,7 +1230,6 @@ def test_hash_consistent(backend, alltypes): "pandas", "dask", "bigquery", - "impala", "mssql", "oracle", "snowflake", @@ -1250,11 +1249,17 @@ def test_hash_consistent(backend, alltypes): "int", 1672531200, marks=[ - pytest.mark.notyet(["duckdb"], reason="casts to None"), - pytest.mark.notyet(["druid"], reason="returns milliseconds"), + pytest.mark.notyet(["duckdb", "impala"], reason="casts to NULL"), pytest.mark.notyet(["trino"], raises=TrinoUserError), - pytest.mark.broken(["polars"], reason="casts to 1672531200000000000"), - pytest.mark.broken(["datafusion"], reason="casts to 1672531200000000"), + pytest.mark.broken( + ["druid"], reason="casts to 1672531200000 (millisecond)" + ), + pytest.mark.broken( + ["polars"], reason="casts to 1672531200000000000 (nanoseconds)" + ), + pytest.mark.broken( + ["datafusion"], reason="casts to 1672531200000000 (microseconds)" + ), pytest.mark.broken(["mysql"], reason="returns 20230101000000"), ], ), @@ -1274,7 +1279,6 @@ def test_try_cast(con, from_val, to_type, expected): "datafusion", "druid", "exasol", - "impala", "mssql", "mysql", "oracle", @@ -1292,7 +1296,9 @@ def test_try_cast(con, from_val, to_type, expected): datetime.datetime(2023, 1, 1), "int", marks=[ - pytest.mark.never(["clickhouse"], reason="casts to 1672531200"), + pytest.mark.never( + ["clickhouse", "pyspark"], reason="casts to 1672531200" + ), pytest.mark.notyet(["trino"], raises=TrinoUserError), pytest.mark.broken(["polars"], reason="casts to 1672531200000000000"), ], @@ -1311,12 +1317,10 @@ def test_try_cast_null(con, from_val, to_type): "bigquery", "datafusion", "druid", - "impala", "mssql", "mysql", "oracle", "postgres", - "pyspark", "snowflake", "sqlite", "exasol", @@ -1340,7 +1344,6 @@ def test_try_cast_table(backend, con): "dask", "bigquery", "datafusion", - "impala", "mssql", "mysql", "oracle", @@ -1354,7 +1357,7 @@ def test_try_cast_table(backend, con): @pytest.mark.parametrize( ("from_val", "to_type", "func"), [ - param("a", "float", pd.isna), + param("a", "float", pd.isna, id="string-to-float"), param( datetime.datetime(2023, 1, 1), "float", @@ -1366,6 +1369,7 @@ def test_try_cast_table(backend, con): ), pytest.mark.notyet(["trino"], raises=TrinoUserError), ], + id="datetime-to-float", ), ], ) @@ -1415,7 +1419,18 @@ def test_try_cast_func(con, from_val, to_type, func): ################## ### POSITIVE start # no stop - param(slice(3, 0), lambda _: 0, id="[3:0]"), + param( + slice(3, 0), + lambda _: 0, + id="[3:0]", + marks=[ + pytest.mark.never( + ["impala"], + raises=ImpalaHiveServer2Error, + reason="impala doesn't support OFFSET without ORDER BY", + ) + ], + ), param( slice(3, None), lambda t: t.count().to_pandas() - 3, @@ -1443,7 +1458,18 @@ def test_try_cast_func(con, from_val, to_type, func): ], ), # positive stop - param(slice(3, 2), lambda _: 0, id="[3:2]"), + param( + slice(3, 2), + lambda _: 0, + id="[3:2]", + marks=[ + pytest.mark.never( + ["impala"], + raises=ImpalaHiveServer2Error, + reason="impala doesn't support OFFSET without ORDER BY", + ) + ], + ), param( slice(3, 4), lambda _: 1, diff --git a/ibis/backends/tests/test_numeric.py b/ibis/backends/tests/test_numeric.py index 39f4c07dfe4c..68ad3ebab40b 100644 --- a/ibis/backends/tests/test_numeric.py +++ b/ibis/backends/tests/test_numeric.py @@ -255,6 +255,7 @@ def test_numeric_literal(con, backend, expr, expected_types): "trino": decimal.Decimal("1.1"), "dask": decimal.Decimal("1.1"), "duckdb": decimal.Decimal("1.1"), + "impala": decimal.Decimal("1"), "postgres": decimal.Decimal("1.1"), "pandas": decimal.Decimal("1.1"), "pyspark": decimal.Decimal("1.1"), @@ -269,31 +270,19 @@ def test_numeric_literal(con, backend, expr, expected_types): "bigquery": "NUMERIC", "snowflake": "DECIMAL", "sqlite": "real", + "impala": "DECIMAL(9,0)", "trino": "decimal(18,3)", "duckdb": "DECIMAL(18,3)", "postgres": "numeric", "flink": "DECIMAL(38, 18) NOT NULL", }, marks=[ - pytest.mark.notimpl( - ["exasol"], - raises=ExaQueryError, - ), + pytest.mark.notimpl(["exasol"], raises=ExaQueryError), pytest.mark.notimpl( ["clickhouse"], "Unsupported precision. Supported values: [1 : 76]. Current value: None", raises=NotImplementedError, ), - pytest.mark.broken( - ["impala"], - "impala.error.HiveServer2Error: AnalysisException: Syntax error in line 1:" - "SELECT typeof(Decimal('1.1')) AS `TypeOf(Decimal('1.1'))" - "Encountered: DECIMAL" - "Expected: ALL, CASE, CAST, DEFAULT, DISTINCT, EXISTS, FALSE, IF, " - "INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER" - "CAUSED BY: Exception: Syntax error", - raises=ImpalaHiveServer2Error, - ), ], id="default", ), @@ -306,6 +295,7 @@ def test_numeric_literal(con, backend, expr, expected_types): "sqlite": 1.1, "trino": decimal.Decimal("1.1"), "duckdb": decimal.Decimal("1.100000000"), + "impala": decimal.Decimal("1.1"), "postgres": decimal.Decimal("1.1"), "pandas": decimal.Decimal("1.1"), "pyspark": decimal.Decimal("1.1"), @@ -322,28 +312,14 @@ def test_numeric_literal(con, backend, expr, expected_types): "bigquery": "NUMERIC", "clickhouse": "Decimal(38, 9)", "snowflake": "DECIMAL", + "impala": "DECIMAL(38,9)", "sqlite": "real", "trino": "decimal(38,9)", "duckdb": "DECIMAL(38,9)", "postgres": "numeric", "flink": "DECIMAL(38, 9) NOT NULL", }, - marks=[ - pytest.mark.notimpl( - ["exasol"], - raises=ExaQueryError, - ), - pytest.mark.broken( - ["impala"], - "impala.error.HiveServer2Error: AnalysisException: Syntax error in line 1:" - "SELECT typeof(Decimal('1.1')) AS `TypeOf(Decimal('1.1'))" - "Encountered: DECIMAL" - "Expected: ALL, CASE, CAST, DEFAULT, DISTINCT, EXISTS, FALSE, IF, " - "INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER" - "CAUSED BY: Exception: Syntax error", - raises=ImpalaHiveServer2Error, - ), - ], + marks=[pytest.mark.notimpl(["exasol"], raises=ExaQueryError)], id="decimal-small", ), param( @@ -375,16 +351,7 @@ def test_numeric_literal(con, backend, expr, expected_types): pytest.mark.notimpl(["exasol"], raises=ExaQueryError), pytest.mark.notimpl(["mysql"], raises=MySQLOperationalError), pytest.mark.notyet(["snowflake"], raises=SnowflakeProgrammingError), - pytest.mark.broken( - ["impala"], - "impala.error.HiveServer2Error: AnalysisException: Syntax error in line 1:" - "SELECT typeof(Decimal('1.2')) AS `TypeOf(Decimal('1.2'))" - "Encountered: DECIMAL" - "Expected: ALL, CASE, CAST, DEFAULT, DISTINCT, EXISTS, FALSE, IF, " - "INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER" - "CAUSED BY: Exception: Syntax error", - raises=ImpalaHiveServer2Error, - ), + pytest.mark.notyet(["impala"], raises=ImpalaHiveServer2Error), pytest.mark.broken( ["duckdb"], reason="Unsupported precision.", @@ -417,7 +384,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "pandas": decimal.Decimal("Infinity"), "dask": decimal.Decimal("Infinity"), "pyspark": decimal.Decimal("Infinity"), - "impala": float("inf"), "exasol": float("inf"), "duckdb": float("inf"), }, @@ -425,7 +391,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "bigquery": "FLOAT64", "sqlite": "real", "postgres": "numeric", - "impala": "DOUBLE", "duckdb": "FLOAT", }, marks=[ @@ -441,7 +406,9 @@ def test_numeric_literal(con, backend, expr, expected_types): "query_id=20230128_024107_01084_y8zm3)", raises=sa.exc.ProgrammingError, ), - pytest.mark.notyet(["mysql"], raises=com.UnsupportedOperationError), + pytest.mark.notyet( + ["mysql", "impala"], raises=com.UnsupportedOperationError + ), pytest.mark.broken( ["mssql"], "(pymssql._pymssql.ProgrammingError) (207, b\"Invalid column name 'Infinity'." @@ -492,7 +459,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "pandas": decimal.Decimal("-Infinity"), "dask": decimal.Decimal("-Infinity"), "pyspark": decimal.Decimal("-Infinity"), - "impala": float("-inf"), "exasol": float("-inf"), "duckdb": float("-inf"), }, @@ -500,7 +466,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "bigquery": "FLOAT64", "sqlite": "real", "postgres": "numeric", - "impala": "DOUBLE", "duckdb": "FLOAT", }, marks=[ @@ -516,7 +481,9 @@ def test_numeric_literal(con, backend, expr, expected_types): "query_id=20230128_024107_01084_y8zm3)", raises=sa.exc.ProgrammingError, ), - pytest.mark.notyet(["mysql"], raises=com.UnsupportedOperationError), + pytest.mark.notyet( + ["mysql", "impala"], raises=com.UnsupportedOperationError + ), pytest.mark.broken( ["mssql"], "(pymssql._pymssql.ProgrammingError) (207, b\"Invalid column name 'Infinity'." @@ -568,7 +535,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "pandas": decimal.Decimal("NaN"), "dask": decimal.Decimal("NaN"), "pyspark": decimal.Decimal("NaN"), - "impala": float("nan"), "exasol": float("nan"), "duckdb": float("nan"), }, @@ -577,7 +543,6 @@ def test_numeric_literal(con, backend, expr, expected_types): "snowflake": "DOUBLE", "sqlite": "null", "postgres": "numeric", - "impala": "DOUBLE", "duckdb": "FLOAT", }, marks=[ @@ -593,7 +558,9 @@ def test_numeric_literal(con, backend, expr, expected_types): "query_id=20230128_024107_01084_y8zm3)", raises=sa.exc.ProgrammingError, ), - pytest.mark.notyet(["mysql"], raises=com.UnsupportedOperationError), + pytest.mark.notyet( + ["mysql", "impala"], raises=com.UnsupportedOperationError + ), pytest.mark.broken( ["mssql"], "(pymssql._pymssql.ProgrammingError) (207, b\"Invalid column name 'NaN'." diff --git a/ibis/backends/tests/test_sql.py b/ibis/backends/tests/test_sql.py index ffe5f76fd820..1a85b73cc54a 100644 --- a/ibis/backends/tests/test_sql.py +++ b/ibis/backends/tests/test_sql.py @@ -28,7 +28,12 @@ reason="arrays not supported in the backend", ), pytest.mark.notyet( - ["impala", "sqlite"], + ["impala"], + raises=exc.UnsupportedBackendType, + reason="arrays not supported in the backend", + ), + pytest.mark.notyet( + ["sqlite"], raises=NotImplementedError, reason="backends hasn't implemented array literals", ), diff --git a/ibis/backends/tests/test_string.py b/ibis/backends/tests/test_string.py index dc74f018a3fe..c865108d897b 100644 --- a/ibis/backends/tests/test_string.py +++ b/ibis/backends/tests/test_string.py @@ -614,7 +614,7 @@ def uses_java_re(t): id="negative-index", marks=[ pytest.mark.broken(["druid"], raises=PyDruidProgrammingError), - pytest.mark.broken(["impala", "flink"], raises=AssertionError), + pytest.mark.broken(["flink"], raises=AssertionError), ], ), param( @@ -898,13 +898,16 @@ def test_capitalize(con): ["dask", "pandas", "polars", "oracle", "flink"], raises=com.OperationNotDefinedError ) @pytest.mark.notyet( - ["impala", "mssql", "sqlite", "exasol"], + ["mssql", "sqlite", "exasol"], reason="no arrays", raises=com.OperationNotDefinedError, ) @pytest.mark.never( ["mysql"], raises=com.UnsupportedBackendType, reason="no array support" ) +@pytest.mark.notimpl( + ["impala"], raises=com.UnsupportedBackendType, reason="no array support" +) def test_array_string_join(con): s = ibis.array(["a", "b", "c"]) expected = "a,b,c" diff --git a/ibis/backends/tests/test_temporal.py b/ibis/backends/tests/test_temporal.py index 3ae0aa153f57..0a90610171d1 100644 --- a/ibis/backends/tests/test_temporal.py +++ b/ibis/backends/tests/test_temporal.py @@ -348,7 +348,6 @@ def test_timestamp_extract_week_of_year(backend, alltypes, df): param( "W", marks=[ - pytest.mark.notimpl(["impala"], raises=AssertionError), pytest.mark.broken(["sqlite"], raises=AssertionError), pytest.mark.notimpl(["mysql"], raises=com.UnsupportedOperationError), pytest.mark.broken( @@ -407,9 +406,7 @@ def test_timestamp_extract_week_of_year(backend, alltypes, df): param( "s", marks=[ - pytest.mark.notimpl( - ["impala", "sqlite"], raises=com.UnsupportedOperationError - ), + pytest.mark.notimpl(["sqlite"], raises=com.UnsupportedOperationError), pytest.mark.broken( ["polars"], raises=AssertionError, @@ -426,13 +423,7 @@ def test_timestamp_extract_week_of_year(backend, alltypes, df): "ms", marks=[ pytest.mark.notimpl( - [ - "clickhouse", - "impala", - "mysql", - "sqlite", - "datafusion", - ], + ["clickhouse", "mysql", "sqlite", "datafusion"], raises=com.UnsupportedOperationError, ), pytest.mark.broken( @@ -451,14 +442,7 @@ def test_timestamp_extract_week_of_year(backend, alltypes, df): "us", marks=[ pytest.mark.notimpl( - [ - "clickhouse", - "impala", - "mysql", - "sqlite", - "trino", - "datafusion", - ], + ["clickhouse", "mysql", "sqlite", "trino", "datafusion"], raises=com.UnsupportedOperationError, ), pytest.mark.broken( @@ -575,7 +559,6 @@ def test_timestamp_truncate(backend, alltypes, df, unit): param( "W", marks=[ - pytest.mark.broken(["impala"], raises=AssertionError), pytest.mark.notyet(["mysql"], raises=com.UnsupportedOperationError), pytest.mark.never( ["flink"], @@ -887,9 +870,10 @@ def convert_to_offset(x): id="timestamp-add-interval-binop", marks=[ pytest.mark.notimpl( - ["dask", "impala", "snowflake", "sqlite", "bigquery"], + ["dask", "snowflake", "sqlite", "bigquery"], raises=com.OperationNotDefinedError, ), + pytest.mark.notimpl(["impala"], raises=com.UnsupportedOperationError), pytest.mark.notimpl(["mysql"], raises=sg.ParseError), pytest.mark.notimpl( ["druid"], @@ -906,9 +890,10 @@ def convert_to_offset(x): id="timestamp-add-interval-binop-different-units", marks=[ pytest.mark.notimpl( - ["sqlite", "polars", "impala", "snowflake", "bigquery"], + ["sqlite", "polars", "snowflake", "bigquery"], raises=com.OperationNotDefinedError, ), + pytest.mark.notimpl(["impala"], raises=com.UnsupportedOperationError), pytest.mark.notimpl(["mysql"], raises=sg.ParseError), pytest.mark.notimpl( ["druid"], @@ -1481,11 +1466,7 @@ def test_interval_add_cast_column(backend, alltypes, df): reason="Polars does not support columnar argument StringConcat()", ), pytest.mark.notyet(["dask"], raises=com.OperationNotDefinedError), - pytest.mark.broken( - ["impala"], - raises=AttributeError, - reason="'StringConcat' object has no attribute 'value'", - ), + pytest.mark.notyet(["impala"], raises=com.UnsupportedOperationError), pytest.mark.notimpl(["druid", "flink"], raises=AttributeError), ], id="column_format_str", @@ -1672,7 +1653,6 @@ def test_integer_to_timestamp(backend, con, unit): "pandas", "clickhouse", "sqlite", - "impala", "datafusion", "mssql", "druid", @@ -1835,12 +1815,13 @@ def test_now_from_projection(alltypes): DATE_BACKEND_TYPES = { "bigquery": "DATE", "clickhouse": "Date", + "duckdb": "DATE", + "flink": "DATE NOT NULL", + "impala": "DATE", + "postgres": "date", "snowflake": "DATE", "sqlite": "text", "trino": "date", - "duckdb": "DATE", - "postgres": "date", - "flink": "DATE NOT NULL", } @@ -1851,7 +1832,6 @@ def test_now_from_projection(alltypes): @pytest.mark.notimpl( ["oracle"], raises=sa.exc.DatabaseError, reason="ORA-00936 missing expression" ) -@pytest.mark.notyet(["impala"], raises=com.OperationNotDefinedError) @pytest.mark.notimpl(["exasol"], raises=ExaQueryError) def test_date_literal(con, backend): expr = ibis.date(2022, 2, 4) @@ -2113,7 +2093,6 @@ def test_interval_literal(con, backend): @pytest.mark.broken( ["oracle"], raises=sa.exc.DatabaseError, reason="ORA-00936: missing expression" ) -@pytest.mark.notyet(["impala"], raises=com.OperationNotDefinedError) @pytest.mark.notimpl(["exasol"], raises=sa.exc.DBAPIError) def test_date_column_from_ymd(backend, con, alltypes, df): c = alltypes.timestamp_col diff --git a/ibis/backends/tests/test_uuid.py b/ibis/backends/tests/test_uuid.py index 473726660f9d..a01a1c124ad7 100644 --- a/ibis/backends/tests/test_uuid.py +++ b/ibis/backends/tests/test_uuid.py @@ -4,8 +4,6 @@ import uuid import pytest -import sqlalchemy.exc -from packaging.version import parse as vparse import ibis import ibis.common.exceptions as com @@ -14,22 +12,21 @@ RAW_TEST_UUID = "08f48812-7948-4718-96c7-27fa6a398db6" TEST_UUID = uuid.UUID(RAW_TEST_UUID) -SQLALCHEMY2 = vparse(sqlalchemy.__version__) >= vparse("2") - UUID_BACKEND_TYPE = { "bigquery": "STRING", + "clickhouse": "Nullable(UUID)", "duckdb": "UUID", "exasol": "UUID", "flink": "CHAR(36) NOT NULL", - "sqlite": "text", - "snowflake": "VARCHAR", - "trino": "varchar(32)" if SQLALCHEMY2 else "uuid", + "impala": "STRING", "postgres": "uuid", - "clickhouse": "Nullable(UUID)", + "snowflake": "VARCHAR", + "sqlite": "text", + "trino": "uuid", } -@pytest.mark.notimpl(["impala", "polars"], raises=NotImplementedError) +@pytest.mark.notimpl(["polars"], raises=NotImplementedError) @pytest.mark.notimpl(["datafusion"], raises=Exception) def test_uuid_literal(con, backend): backend_name = backend.name() diff --git a/ibis/backends/tests/test_window.py b/ibis/backends/tests/test_window.py index 82731567bc60..0b7ac21a49fc 100644 --- a/ibis/backends/tests/test_window.py +++ b/ibis/backends/tests/test_window.py @@ -1061,11 +1061,6 @@ def test_mutate_window_filter(backend, alltypes): raises=Exception, reason="KeyError: Table with name win doesn't exist.", ) -@pytest.mark.broken( - ["impala"], - reason="the database returns incorrect results", - raises=AssertionError, -) @pytest.mark.notimpl(["dask"], raises=NotImplementedError) def test_first_last(backend): t = backend.win diff --git a/ibis/expr/operations/udf.py b/ibis/expr/operations/udf.py index 7d900df7c813..945f70f429d7 100644 --- a/ibis/expr/operations/udf.py +++ b/ibis/expr/operations/udf.py @@ -417,6 +417,7 @@ def pyarrow(cls, fn=None, *, name=None, schema=None, signature=None, **kwargs): ) +@public class agg(_UDF): __slots__ = () diff --git a/poetry.lock b/poetry.lock index 8a63eb609e8c..6d1b69a75386 100644 --- a/poetry.lock +++ b/poetry.lock @@ -7341,7 +7341,7 @@ examples = ["pins"] exasol = ["sqlalchemy", "sqlalchemy-exasol", "sqlalchemy-views"] flink = [] geospatial = ["geopandas", "shapely"] -impala = ["impyla", "sqlalchemy"] +impala = ["impyla"] mssql = ["pyodbc", "sqlalchemy", "sqlalchemy-views"] mysql = ["pymysql"] oracle = ["oracledb", "packaging", "sqlalchemy", "sqlalchemy-views"] @@ -7357,4 +7357,4 @@ visualization = ["graphviz"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "a2edd5b6e62e78267c3e2339efde3600b637e86ae05c0deec081798be5d1d34e" +content-hash = "1939863bb76e53c0c8a1575ffe8fd2e035e6768ac21682fe12a9e640ffe3ade1" diff --git a/pyproject.toml b/pyproject.toml index 49cdf5f0378f..55958423703e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -187,7 +187,7 @@ duckdb = ["duckdb"] exasol = ["sqlalchemy", "sqlalchemy-exasol", "sqlalchemy-views"] flink = [] geospatial = ["geopandas", "shapely"] -impala = ["impyla", "sqlalchemy"] +impala = ["impyla"] mssql = ["sqlalchemy", "pyodbc", "sqlalchemy-views"] mysql = ["pymysql"] oracle = ["sqlalchemy", "oracledb", "packaging", "sqlalchemy-views"]