diff --git a/ibis/backends/clickhouse/tests/test_aggregations.py b/ibis/backends/clickhouse/tests/test_aggregations.py index 3806bae4baa5..e7c2ce1dfe1b 100644 --- a/ibis/backends/clickhouse/tests/test_aggregations.py +++ b/ibis/backends/clickhouse/tests/test_aggregations.py @@ -15,20 +15,20 @@ @pytest.mark.parametrize( "reduction", ["sum", "count", "mean", "max", "min", "std", "var"] ) -def test_reduction_where(alltypes, reduction, snapshot): +def test_reduction_where(alltypes, reduction, assert_sql): method = getattr(alltypes.double_col, reduction) cond = alltypes.bigint_col < 70 expr = method(where=cond) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) @pytest.mark.parametrize("method", ["var", "std"]) -def test_std_var_pop(con, alltypes, method, snapshot): +def test_std_var_pop(con, alltypes, method, assert_sql): cond = alltypes.bigint_col < 70 col = alltypes.double_col expr = getattr(col, method)(where=cond, how="pop") - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert isinstance(con.execute(expr), float) diff --git a/ibis/backends/clickhouse/tests/test_client.py b/ibis/backends/clickhouse/tests/test_client.py index fecae9ae9e19..38ff49b8863d 100644 --- a/ibis/backends/clickhouse/tests/test_client.py +++ b/ibis/backends/clickhouse/tests/test_client.py @@ -15,6 +15,11 @@ cc = pytest.importorskip("clickhouse_connect") +def test_connection(con): + assert con is not None + assert isinstance(con, ibis.backends.clickhouse.Backend) + + def test_run_sql(con): query = "SELECT * FROM ibis_testing.functional_alltypes" table = con.sql(query) diff --git a/ibis/backends/clickhouse/tests/test_functions.py b/ibis/backends/clickhouse/tests/test_functions.py index 5952bb8b6f6e..04b53f4d840d 100644 --- a/ibis/backends/clickhouse/tests/test_functions.py +++ b/ibis/backends/clickhouse/tests/test_functions.py @@ -19,10 +19,9 @@ @pytest.mark.parametrize("to_type", ["int8", "int16", "float32", "float", "!float64"]) -def test_cast_double_col(alltypes, to_type, snapshot): +def test_cast_double_col(alltypes, to_type, assert_sql): expr = alltypes.double_col.cast(to_type) - result = expr.compile() - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -37,9 +36,9 @@ def test_cast_double_col(alltypes, to_type, snapshot): "!struct", ], ) -def test_cast_string_col(alltypes, to_type, snapshot): +def test_cast_string_col(alltypes, to_type, assert_sql): expr = alltypes.string_col.cast(to_type) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -60,14 +59,14 @@ def test_cast_string_col(alltypes, to_type, snapshot): "month", ], ) -def test_noop_cast(alltypes, column, snapshot): +def test_noop_cast(alltypes, column, assert_sql): col = alltypes[column] result = col.cast(col.type()) assert result.equals(col) - snapshot.assert_match(result.compile(), "out.sql") + assert_sql(result) -def test_timestamp_cast(alltypes, snapshot): +def test_timestamp_cast(alltypes, assert_sql): target = dt.Timestamp(nullable=False) result1 = alltypes.timestamp_col.cast(target) result2 = alltypes.int_col.cast(target) @@ -75,20 +74,20 @@ def test_timestamp_cast(alltypes, snapshot): assert isinstance(result1, ir.TimestampColumn) assert isinstance(result2, ir.TimestampColumn) - snapshot.assert_match(result1.compile(), "out1.sql") - snapshot.assert_match(result2.compile(), "out2.sql") + assert_sql(result1, "out1.sql") + assert_sql(result2, "out2.sql") -def test_timestamp_now(con, snapshot): +def test_timestamp_now(con, assert_sql): expr = ibis.now() - snapshot.assert_match(con.compile(expr), "out.sql") + assert_sql(expr) @pytest.mark.parametrize("unit", ["y", "m", "d", "w", "h", "minute"]) -def test_timestamp_truncate(con, unit, snapshot): +def test_timestamp_truncate(con, unit, assert_sql): stamp = ibis.timestamp("2009-05-17 12:34:56") expr = stamp.truncate(unit) - snapshot.assert_match(con.compile(expr), "out.sql") + assert_sql(expr) @pytest.mark.parametrize(("value", "expected"), [(0, None), (5.5, 5.5)]) @@ -185,13 +184,13 @@ def test_string_substring(con, op, expected): assert con.execute(op(value)) == expected -def test_string_column_substring(con, alltypes, snapshot): +def test_string_column_substring(con, alltypes, assert_sql): expr = alltypes.string_col.substr(2) - snapshot.assert_match(expr.compile(), "out1.sql") + assert_sql(expr, "out1.sql") assert len(con.execute(expr)) expr = alltypes.string_col.substr(0, 3) - snapshot.assert_match(expr.compile(), "out2.sql") + assert_sql(expr, "out2.sql") assert len(con.execute(expr)) @@ -243,12 +242,12 @@ def test_find_in_set(con, value, expected): assert con.execute(expr) == expected -def test_string_column_find_in_set(con, alltypes, snapshot): +def test_string_column_find_in_set(con, alltypes, assert_sql): s = alltypes.string_col vals = list("abc") expr = s.find_in_set(vals) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) @@ -271,25 +270,25 @@ def test_string_find_like(con, expr, expected): assert con.execute(expr) == expected -def test_string_column_like(con, alltypes, snapshot): +def test_string_column_like(con, alltypes, assert_sql): expr = alltypes.string_col.like("foo%") - snapshot.assert_match(expr.compile(), "out1.sql") + assert_sql(expr, "out1.sql") assert len(con.execute(expr)) expr = alltypes.string_col.like(["foo%", "%bar"]) - snapshot.assert_match(expr.compile(), "out2.sql") + assert_sql(expr, "out2.sql") assert len(con.execute(expr)) -def test_string_column_find(con, alltypes, snapshot): +def test_string_column_find(con, alltypes, assert_sql): s = alltypes.string_col expr = s.find("a") - snapshot.assert_match(expr.compile(), "out1.sql") + assert_sql(expr, "out1.sql") assert len(con.execute(expr)) expr = s.find(s) - snapshot.assert_match(expr.compile(), "out2.sql") + assert_sql(expr, "out2.sql") assert len(con.execute(expr)) @@ -309,9 +308,9 @@ def test_string_column_find(con, alltypes, snapshot): param(methodcaller("sign"), id="sign"), ], ) -def test_translate_math_functions(con, alltypes, call, snapshot): +def test_translate_math_functions(con, alltypes, call, assert_sql): expr = call(alltypes.double_col) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr, "out.sql") assert len(con.execute(expr)) @@ -352,21 +351,21 @@ def test_math_functions(con, expr, expected): assert con.execute(expr) == expected -def test_greatest_least(con, alltypes, snapshot): +def test_greatest_least(con, alltypes, assert_sql): expr = ibis.greatest(alltypes.int_col, 10) - snapshot.assert_match(expr.compile(), "out1.sql") + assert_sql(expr, "out1.sql") assert len(con.execute(expr)) expr = ibis.greatest(alltypes.int_col, alltypes.bigint_col) - snapshot.assert_match(expr.compile(), "out2.sql") + assert_sql(expr, "out2.sql") assert len(con.execute(expr)) expr = ibis.least(alltypes.int_col, 10) - snapshot.assert_match(expr.compile(), "out3.sql") + assert_sql(expr, "out3.sql") assert len(con.execute(expr)) expr = ibis.least(alltypes.int_col, alltypes.bigint_col) - snapshot.assert_match(expr.compile(), "out4.sql") + assert_sql(expr, "out4.sql") assert len(con.execute(expr)) @@ -397,15 +396,15 @@ def test_regexp_extract(con, expr, expected): assert con.execute(expr) == expected -def test_column_regexp_extract(con, alltypes, snapshot): +def test_column_regexp_extract(con, alltypes, assert_sql): expr = alltypes.string_col.re_extract(r"[\d]+", 3) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr, "out.sql") assert len(con.execute(expr)) -def test_column_regexp_replace(con, alltypes, snapshot): +def test_column_regexp_replace(con, alltypes, assert_sql): expr = alltypes.string_col.re_replace(r"[\d]+", "aaa") - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr, "out.sql") assert len(con.execute(expr)) @@ -437,10 +436,10 @@ def test_literal_none_to_nullable_column(alltypes): tm.assert_series_equal(result, expected) -def test_timestamp_from_integer(con, alltypes, snapshot): +def test_timestamp_from_integer(con, alltypes, assert_sql): # timestamp_col has datetime type expr = alltypes.int_col.to_timestamp() - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr, "out.sql") assert len(con.execute(expr)) @@ -460,15 +459,15 @@ def test_count_distinct_with_filter(alltypes): param(",", 0, id="comma_zero"), ], ) -def test_group_concat(alltypes, sep, where_case, snapshot): +def test_group_concat(alltypes, sep, where_case, assert_sql): where = None if where_case is None else alltypes.bool_col == where_case expr = alltypes.string_col.group_concat(sep, where) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr, "out.sql") -def test_hash(alltypes, snapshot): +def test_hash(alltypes, assert_sql): expr = alltypes.string_col.hash() - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) def test_udf_in_array_map(alltypes): diff --git a/ibis/backends/clickhouse/tests/test_literals.py b/ibis/backends/clickhouse/tests/test_literals.py index 1d1aa3020958..33f5970bb4fd 100644 --- a/ibis/backends/clickhouse/tests/test_literals.py +++ b/ibis/backends/clickhouse/tests/test_literals.py @@ -18,8 +18,8 @@ ibis.timestamp("2015-01-01 12:34:56"), ], ) -def test_timestamp_literals(con, expr, snapshot): - snapshot.assert_match(con.compile(expr), "out.sql") +def test_timestamp_literals(con, expr, assert_sql): + assert_sql(expr) assert con.execute(expr) == Timestamp("2015-01-01 12:34:56") @@ -32,8 +32,8 @@ def test_timestamp_literals(con, expr, snapshot): param(ibis.timestamp("2015-01-01 12:34:56.789321 UTC"), id="micros_tz"), ], ) -def test_fine_grained_timestamp_literals(con, expr, snapshot): - snapshot.assert_match(con.compile(expr), "out.sql") +def test_fine_grained_timestamp_literals(con, expr, assert_sql): + assert_sql(expr) assert con.execute(expr) == expr.op().value @@ -49,10 +49,9 @@ def test_fine_grained_timestamp_literals(con, expr, snapshot): param(False, id="false"), ], ) -def test_string_numeric_boolean_literals(con, value, snapshot): +def test_string_numeric_boolean_literals(con, value, assert_sql): expr = ibis.literal(value) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) assert con.execute(expr) == value diff --git a/ibis/backends/clickhouse/tests/test_operators.py b/ibis/backends/clickhouse/tests/test_operators.py index 4db313f76a93..4ca53a3d2b9f 100644 --- a/ibis/backends/clickhouse/tests/test_operators.py +++ b/ibis/backends/clickhouse/tests/test_operators.py @@ -56,11 +56,11 @@ def test_string_temporal_compare(con, op, left, right, type): "op", ["add", "sub", "mul", "truediv", "pow", "lt", "le", "gt", "ge", "eq", "ne"], ) -def test_binary_infix_operators(con, alltypes, op, snapshot): +def test_binary_infix_operators(con, alltypes, op, assert_sql): func = getattr(operator, op) a, b = alltypes.int_col, alltypes.tinyint_col expr = func(a, b) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) @@ -78,19 +78,19 @@ def test_binary_infix_operators(con, alltypes, op, snapshot): lambda a, b, c: (b + (-(a + c))), ], ) -def test_binary_infix_parenthesization(con, alltypes, op, snapshot): +def test_binary_infix_parenthesization(con, alltypes, op, assert_sql): a = alltypes.int_col b = alltypes.tinyint_col c = alltypes.double_col expr = op(a, b, c) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) -def test_between(con, alltypes, snapshot): +def test_between(con, alltypes, assert_sql): expr = alltypes.int_col.between(0, 10) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) @@ -143,9 +143,9 @@ def test_field_in_literals(con, alltypes, df, container): @pytest.mark.parametrize("column", ["int_col", "float_col", "bool_col"]) -def test_negate(con, alltypes, column, snapshot): +def test_negate(con, alltypes, column, assert_sql): expr = -alltypes[column] - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) @@ -199,17 +199,17 @@ def test_ifelse(alltypes, df, op, pandas_op): tm.assert_series_equal(result, expected) -def test_simple_case(con, alltypes, snapshot): +def test_simple_case(con, alltypes, assert_sql): t = alltypes expr = ( t.string_col.case().when("foo", "bar").when("baz", "qux").else_("default").end() ) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) -def test_search_case(con, alltypes, snapshot): +def test_search_case(con, alltypes, assert_sql): t = alltypes expr = ( ibis.case() @@ -219,7 +219,7 @@ def test_search_case(con, alltypes, snapshot): .end() ) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) assert len(con.execute(expr)) diff --git a/ibis/backends/clickhouse/tests/test_select.py b/ibis/backends/clickhouse/tests/test_select.py index ffb4aeb4c355..609e44782238 100644 --- a/ibis/backends/clickhouse/tests/test_select.py +++ b/ibis/backends/clickhouse/tests/test_select.py @@ -35,7 +35,7 @@ def time_right(con): return con.table("time_df2") -def test_timestamp_extract_field(alltypes, snapshot): +def test_timestamp_extract_field(alltypes, assert_sql): t = alltypes.timestamp_col expr = alltypes[ t.year().name("year"), @@ -45,21 +45,16 @@ def test_timestamp_extract_field(alltypes, snapshot): t.minute().name("minute"), t.second().name("second"), ] + assert_sql(expr) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") - - -def test_isin_notin_in_select(alltypes, snapshot): +def test_isin_notin_in_select(alltypes, assert_sql): values = ["foo", "bar"] filtered = alltypes[alltypes.string_col.isin(values)] - result = ibis.clickhouse.compile(filtered) - snapshot.assert_match(result, "out1.sql") + assert_sql(filtered, "out1.sql") filtered = alltypes[alltypes.string_col.notin(values)] - result = ibis.clickhouse.compile(filtered) - snapshot.assert_match(result, "out2.sql") + assert_sql(filtered, "out2.sql") def test_head(alltypes): @@ -100,14 +95,12 @@ def test_subquery(alltypes, df): tm.assert_frame_equal(result, expected) -def test_simple_scalar_aggregates(alltypes, snapshot): +def test_simple_scalar_aggregates(alltypes, assert_sql): # Things like table.column.{sum, mean, ...}() table = alltypes expr = table[table.int_col > 0].float_col.sum() - - sql_query = ibis.clickhouse.compile(expr) - snapshot.assert_match(sql_query, "out.sql") + assert_sql(expr) # def test_scalar_aggregates_multiple_tables(alltypes): @@ -156,50 +149,42 @@ def test_simple_scalar_aggregates(alltypes, snapshot): # assert result == expected -def test_table_column_unbox(alltypes, snapshot): +def test_table_column_unbox(alltypes, assert_sql): m = alltypes.float_col.sum().name("total") agged = alltypes[alltypes.int_col > 0].group_by("string_col").aggregate([m]) expr = agged.string_col + assert_sql(expr) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") - -def test_complex_array_expr_projection(alltypes, snapshot): +def test_complex_array_expr_projection(alltypes, assert_sql): # May require finding the base table and forming a projection. expr = ( alltypes.group_by("string_col") .aggregate([alltypes.count().name("count")]) .string_col.cast("double") ) - - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( "expr", [param(ibis.now(), id="now"), param(ibis.literal(1) + ibis.literal(2), id="add")], ) -def test_scalar_exprs_no_table_refs(expr, snapshot): - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") +def test_scalar_exprs_no_table_refs(expr, assert_sql): + assert_sql(expr) -def test_isnull_case_expr_rewrite_failure(alltypes, snapshot): +def test_isnull_case_expr_rewrite_failure(alltypes, assert_sql): # #172, case expression that was not being properly converted into an # aggregation reduction = alltypes.string_col.isnull().ifelse(1, 0).sum() - - result = ibis.clickhouse.compile(reduction) - snapshot.assert_match(result, "out.sql") + assert_sql(reduction) -def test_physical_table_reference_translate(alltypes, snapshot): +def test_physical_table_reference_translate(alltypes, assert_sql): # If an expression's table leaves all reference database tables, verify # we translate correctlys - result = ibis.clickhouse.compile(alltypes) - snapshot.assert_match(result, "out.sql") + assert_sql(alltypes) def test_non_equijoin(alltypes): @@ -223,56 +208,46 @@ def test_non_equijoin(alltypes): ("left_key", "right_key"), [("playerID", "playerID"), ("playerID", "awardID")] ) def test_simple_joins( - batting, awards_players, join_type, left_key, right_key, snapshot + batting, awards_players, join_type, left_key, right_key, assert_sql ): t1, t2 = batting, awards_players pred = [t1[left_key] == t2[right_key]] expr = getattr(t1, join_type)(t2, pred)[[t1]] + assert_sql(expr) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") - -def test_self_reference_simple(con, alltypes, snapshot): +def test_self_reference_simple(con, alltypes, assert_sql): expr = alltypes.view() - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) assert len(con.execute(expr)) -def test_join_self_reference(con, alltypes, snapshot): +def test_join_self_reference(con, alltypes, assert_sql): t1 = alltypes t2 = t1.view() expr = t1.inner_join(t2, ["id"])[[t1]] - - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) assert len(con.execute(expr)) -def test_where_simple_comparisons(con, alltypes, snapshot): +def test_where_simple_comparisons(con, alltypes, assert_sql): t1 = alltypes expr = t1.filter([t1.float_col > 0, t1.int_col < t1.float_col * 2]) - - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) assert len(con.execute(expr)) -def test_where_with_between(con, alltypes, snapshot): +def test_where_with_between(con, alltypes, assert_sql): t = alltypes expr = t.filter([t.int_col > 0, t.float_col.between(0, 1)]) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) con.execute(expr) -def test_ifelse_use_if(con, alltypes, snapshot): +def test_ifelse_use_if(con, alltypes, assert_sql): expr = ibis.ifelse(alltypes.float_col > 0, alltypes.int_col, alltypes.bigint_col) - - result = expr.compile() - snapshot.assert_match(result, "out.sql") + assert_sql(expr) con.execute(expr) @@ -290,14 +265,13 @@ def test_filter_predicates(diamonds): expr.execute() -def test_where_with_timestamp(snapshot): +def test_where_with_timestamp(assert_sql): t = ibis.table( [("uuid", "string"), ("ts", "timestamp"), ("search_level", "int64")], name="t", ) expr = t.group_by(t.uuid).aggregate(min_date=t.ts.min(where=t.search_level == 1)) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) def test_timestamp_scalar_in_filter(alltypes): @@ -313,17 +287,15 @@ def test_timestamp_scalar_in_filter(alltypes): expr.execute() -def test_named_from_filter_groupby(snapshot): +def test_named_from_filter_groupby(assert_sql): t = ibis.table([("key", "string"), ("value", "double")], name="t0") gb = t.filter(t.value == 42).group_by(t.key) sum_expr = lambda t: (t.value + 1 + 2 + 3).sum() expr = gb.aggregate(abc=sum_expr) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out1.sql") + assert_sql(expr, "out1.sql") expr = gb.aggregate(foo=sum_expr) - result = ibis.clickhouse.compile(expr) - snapshot.assert_match(result, "out2.sql") + assert_sql(expr, "out2.sql") def test_join_with_external_table_errors(alltypes): @@ -385,30 +357,26 @@ def test_asof_join(time_left, time_right): ) -def test_count_name(snapshot): +def test_count_name(assert_sql): t = ibis.table(dict(a="string", b="bool"), name="t") expr = t.group_by(t.a).agg( A=t.count(where=~t.b).fillna(0), B=t.count(where=t.b).fillna(0) ) - - snapshot.assert_match(str(ibis.to_sql(expr, dialect="clickhouse")), "out.sql") + assert_sql(expr) -def test_array_join_in_subquery(snapshot): +def test_array_join_in_subquery(assert_sql): node_view = ibis.table(dict(id="int64"), name="node_view") way_view = ibis.table(dict(ids="array"), name="way_view") expr = node_view.id.isin(way_view.ids.unnest()) - - out = ibis.clickhouse.compile(expr) - snapshot.assert_match(out, "out.sql") + assert_sql(expr) -def test_complex_join(snapshot): +def test_complex_join(assert_sql): t1 = ibis.table({"a": "int", "b": "int"}, name="s") t2 = ibis.table({"c": "int", "d": "int"}, name="t") t3 = t1.join(t2, t1.a == t2.c) q = t3.mutate(e=t3.c / (t3.a - t3.b)) - out = ibis.clickhouse.compile(q) - snapshot.assert_match(out, "out.sql") + assert_sql(q) diff --git a/ibis/backends/conftest.py b/ibis/backends/conftest.py index 652c51c79010..7c7eaf9101af 100644 --- a/ibis/backends/conftest.py +++ b/ibis/backends/conftest.py @@ -712,3 +712,12 @@ def test_employee_data_2(): ) return df2 + + +@pytest.fixture +def assert_sql(con, snapshot): + def checker(expr, file_name="out.sql"): + sql = con.compile(expr, pretty=True) + snapshot.assert_match(sql, file_name) + + return checker diff --git a/ibis/backends/dask/__init__.py b/ibis/backends/dask/__init__.py index 7bc28079d935..90fa80bb6d4b 100644 --- a/ibis/backends/dask/__init__.py +++ b/ibis/backends/dask/__init__.py @@ -89,6 +89,7 @@ def compile( params: dict | None = None, limit: int | None = None, timecontext=None, + **kwargs, ): from ibis.backends.dask.executor import DaskExecutor diff --git a/ibis/backends/duckdb/tests/test_geospatial.py b/ibis/backends/duckdb/tests/test_geospatial.py index 3cca6f59e7d5..a6855743902f 100644 --- a/ibis/backends/duckdb/tests/test_geospatial.py +++ b/ibis/backends/duckdb/tests/test_geospatial.py @@ -32,17 +32,16 @@ def test_geospatial_point(zones, zones_gdf): param("n_points", {}, id="n_points"), ], ) -def test_geospatial_unary_snapshot(operation, keywords, snapshot): +def test_geospatial_unary_snapshot(operation, keywords, assert_sql): t = ibis.table([("geom", "geometry")], name="t") expr = getattr(t.geom, operation)(**keywords).name("tmp") - snapshot.assert_match(ibis.to_sql(expr), "out.sql") + assert_sql(expr) -def test_geospatial_dwithin(snapshot): +def test_geospatial_dwithin(assert_sql): t = ibis.table([("geom", "geometry")], name="t") expr = t.geom.d_within(t.geom, 3.0).name("tmp") - - snapshot.assert_match(ibis.to_sql(expr), "out.sql") + assert_sql(expr) # geospatial unary functions that return a non-geometry series @@ -252,9 +251,8 @@ def test_create_table_geospatial_types(geotable, con): @pytest.mark.parametrize("expr", [point, point_geom]) -def test_literal_geospatial_explicit(con, expr, snapshot): - result = str(con.compile(expr)) - snapshot.assert_match(result, "out.sql") +def test_literal_geospatial_explicit(con, expr, assert_sql): + assert_sql(expr) # test input data with shapely geometries @@ -291,12 +289,13 @@ def test_literal_geospatial_explicit(con, expr, snapshot): ), ], ) -def test_literal_geospatial_inferred(con, shp, expected, snapshot): - result = str(con.compile(ibis.literal(shp).name("result"))) +def test_literal_geospatial_inferred(con, shp, expected, assert_sql): + expr = ibis.literal(shp).name("result") + result = con.compile(expr) name = type(shp).__name__.upper() pair = f"{name} {expected}" assert pair in result - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.skipif( diff --git a/ibis/backends/flink/__init__.py b/ibis/backends/flink/__init__.py index 8cf9cd744814..64c43ad21d52 100644 --- a/ibis/backends/flink/__init__.py +++ b/ibis/backends/flink/__init__.py @@ -328,10 +328,16 @@ def _register_udf(self, udf_node: ops.ScalarUDF): _compile_python_udf = _register_udf def compile( - self, expr: ir.Expr, params: Mapping[ir.Expr, Any] | None = None, **_: Any + self, + expr: ir.Expr, + params: Mapping[ir.Expr, Any] | None = None, + pretty: bool = False, + **_: Any, ) -> Any: """Compile an Ibis expression to Flink.""" - return super().compile(expr, params=params) # Discard `limit` and other kwargs. + return super().compile( + expr, params=params, pretty=pretty + ) # Discard `limit` and other kwargs. def _to_sqlglot( self, expr: ir.Expr, params: Mapping[ir.Expr, Any] | None = None, **_: Any diff --git a/ibis/backends/flink/tests/test_compiler.py b/ibis/backends/flink/tests/test_compiler.py index 0c404c32e378..210ba6f9941e 100644 --- a/ibis/backends/flink/tests/test_compiler.py +++ b/ibis/backends/flink/tests/test_compiler.py @@ -7,16 +7,14 @@ from ibis.common.deferred import _ -def test_sum(con, snapshot, simple_table): +def test_sum(con, simple_table, assert_sql): expr = simple_table.a.sum() - result = con.compile(expr) - snapshot.assert_match(str(result), "out.sql") + assert_sql(expr) -def test_count_star(con, snapshot, simple_table): +def test_count_star(con, simple_table, assert_sql): expr = simple_table.group_by(simple_table.i).size() - result = con.compile(expr) - snapshot.assert_match(str(result), "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -26,29 +24,26 @@ def test_count_star(con, snapshot, simple_table): param("s", id="timestamp_s"), ], ) -def test_timestamp_from_unix(con, snapshot, simple_table, unit): +def test_timestamp_from_unix(con, simple_table, unit, assert_sql): expr = simple_table.d.to_timestamp(unit=unit) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_complex_projections(con, snapshot, simple_table): +def test_complex_projections(con, simple_table, assert_sql): expr = ( simple_table.group_by(["a", "c"]) .aggregate(the_sum=simple_table.b.sum()) .group_by("a") .aggregate(mad=lambda x: x.the_sum.abs().mean()) ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_filter(con, snapshot, simple_table): +def test_filter(con, simple_table, assert_sql): expr = simple_table[ ((simple_table.c > 0) | (simple_table.c < 0)) & simple_table.g.isin(["A", "B"]) ] - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -65,53 +60,47 @@ def test_filter(con, snapshot, simple_table): "second", ], ) -def test_extract_fields(con, snapshot, simple_table, kind): +def test_extract_fields(con, simple_table, kind, assert_sql): expr = getattr(simple_table.i, kind)().name("tmp") - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_complex_groupby_aggregation(con, snapshot, simple_table): +def test_complex_groupby_aggregation(con, simple_table, assert_sql): keys = [simple_table.i.year().name("year"), simple_table.i.month().name("month")] b_unique = simple_table.b.nunique() expr = simple_table.group_by(keys).aggregate( total=simple_table.count(), b_unique=b_unique ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_simple_filtered_agg(con, snapshot, simple_table): +def test_simple_filtered_agg(con, simple_table, assert_sql): expr = simple_table.b.nunique(where=simple_table.g == "A") - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_complex_filtered_agg(con, snapshot, simple_table): +def test_complex_filtered_agg(con, snapshot, simple_table, assert_sql): expr = simple_table.group_by("b").aggregate( total=simple_table.count(), avg_a=simple_table.a.mean(), avg_a_A=simple_table.a.mean(where=simple_table.g == "A"), avg_a_B=simple_table.a.mean(where=simple_table.g == "B"), ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_value_counts(con, snapshot, simple_table): +def test_value_counts(con, simple_table, assert_sql): expr = simple_table.i.year().value_counts() - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_having(con, snapshot, simple_table): +def test_having(con, simple_table, assert_sql): expr = ( simple_table.group_by("g") .having(simple_table.count() >= 1000) .aggregate(simple_table.b.sum().name("b_sum")) ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -138,26 +127,24 @@ def test_having(con, snapshot, simple_table): ), ], ) -def test_windowing_tvf(con, snapshot, simple_table, function_type, params): +def test_windowing_tvf(con, simple_table, function_type, params, assert_sql): expr = getattr(simple_table.window_by(time_col=simple_table.i), function_type)( **params ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_window_aggregation(con, snapshot, simple_table): +def test_window_aggregation(con, simple_table, assert_sql): expr = ( simple_table.window_by(time_col=simple_table.i) .tumble(window_size=ibis.interval(minutes=15)) .group_by(["window_start", "window_end", "g"]) .aggregate(mean=_.d.mean()) ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_window_topn(con, snapshot, simple_table): +def test_window_topn(con, simple_table, assert_sql): expr = simple_table.window_by(time_col="i").tumble( window_size=ibis.interval(seconds=600), )["a", "b", "c", "d", "g", "window_start", "window_end"] @@ -167,5 +154,4 @@ def test_window_topn(con, snapshot, simple_table): ) ) expr = expr[expr.rownum <= 3] - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) diff --git a/ibis/backends/flink/tests/test_window.py b/ibis/backends/flink/tests/test_window.py index 9104cc558b30..9e0e480a603f 100644 --- a/ibis/backends/flink/tests/test_window.py +++ b/ibis/backends/flink/tests/test_window.py @@ -53,15 +53,13 @@ def test_window_invalid_start_end(con, window): con.execute(expr) -def test_range_window(con, snapshot, simple_table): +def test_range_window(con, simple_table, assert_sql): expr = simple_table.f.sum().over( range=(-ibis.interval(minutes=500), 0), order_by=simple_table.f ) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) -def test_rows_window(con, snapshot, simple_table): +def test_rows_window(con, simple_table, assert_sql): expr = simple_table.f.sum().over(rows=(-1000, 0), order_by=simple_table.f) - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) diff --git a/ibis/backends/impala/tests/conftest.py b/ibis/backends/impala/tests/conftest.py index c92c8782d52c..e748e39aad5d 100644 --- a/ibis/backends/impala/tests/conftest.py +++ b/ibis/backends/impala/tests/conftest.py @@ -113,6 +113,7 @@ def _load_data(self, **_: Any) -> None: ('a', 4, 1) """ ) + con.drop_table("topk", database="ibis_testing", force=True) con.create_table( "topk", schema=ibis.schema({"x": "int64"}), database="ibis_testing" 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 3174e14dfa1e..a1bbbf5cae31 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,16 +1 @@ -SELECT - `t2`.`col`, - `t2`.`analytic` -FROM ( - 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 +SELECT `t2`.`col`, `t2`.`analytic` FROM (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 084d6ae3fcc9..84540f2ab1a2 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,17 +1 @@ -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 +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 e49a2c885636..c0973fd06539 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,17 +1 @@ -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 +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 b9962ec6e33c..2d7d349a39d8 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,3 +1 @@ -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 +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 9265a674c3c3..0499d3a1d41c 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,6 +1 @@ -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 +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_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 28c6528bec63..b76e784fe68e 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,6 +1 @@ -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 +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_join_key_name/out.sql b/ibis/backends/impala/tests/snapshots/test_sql/test_join_key_name/out.sql index 58a634e12636..032e4e331c24 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,79 +1 @@ -WITH `t8` AS ( - 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` -) -SELECT - `t12`.`year`, - `t12`.`CountStar()` AS `pre_count`, - `t17`.`CountStar()` AS `post_count`, - `t17`.`CountStar()` / CAST(`t12`.`CountStar()` AS DOUBLE) AS `fraction` -FROM ( - SELECT - EXTRACT(year FROM `t9`.`odate`) AS `year`, - COUNT(*) AS `CountStar()` - FROM `t8` AS `t9` - GROUP BY - 1 -) AS `t12` -INNER JOIN ( - SELECT - EXTRACT(year FROM `t15`.`odate`) AS `year`, - COUNT(*) AS `CountStar()` - FROM ( - SELECT - `t9`.`c_custkey`, - `t9`.`c_name`, - `t9`.`c_address`, - `t9`.`c_nationkey`, - `t9`.`c_phone`, - `t9`.`c_acctbal`, - `t9`.`c_mktsegment`, - `t9`.`c_comment`, - `t9`.`region`, - `t9`.`o_totalprice`, - `t9`.`odate` - FROM `t8` AS `t9` - WHERE - `t9`.`o_totalprice` > ( - SELECT - AVG(`t13`.`o_totalprice`) AS `Mean(o_totalprice)` - FROM ( - SELECT - `t10`.`c_custkey`, - `t10`.`c_name`, - `t10`.`c_address`, - `t10`.`c_nationkey`, - `t10`.`c_phone`, - `t10`.`c_acctbal`, - `t10`.`c_mktsegment`, - `t10`.`c_comment`, - `t10`.`region`, - `t10`.`o_totalprice`, - `t10`.`odate` - FROM `t8` AS `t10` - WHERE - `t10`.`region` = `t9`.`region` - ) AS `t13` - ) - ) AS `t15` - GROUP BY - 1 -) AS `t17` - ON `t12`.`year` = `t17`.`year` \ No newline at end of file +WITH `t8` AS (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`) SELECT `t12`.`year`, `t12`.`CountStar()` AS `pre_count`, `t17`.`CountStar()` AS `post_count`, `t17`.`CountStar()` / CAST(`t12`.`CountStar()` AS DOUBLE) AS `fraction` FROM (SELECT EXTRACT(year FROM `t9`.`odate`) AS `year`, COUNT(*) AS `CountStar()` FROM `t8` AS `t9` GROUP BY 1) AS `t12` INNER JOIN (SELECT EXTRACT(year FROM `t15`.`odate`) AS `year`, COUNT(*) AS `CountStar()` FROM (SELECT `t9`.`c_custkey`, `t9`.`c_name`, `t9`.`c_address`, `t9`.`c_nationkey`, `t9`.`c_phone`, `t9`.`c_acctbal`, `t9`.`c_mktsegment`, `t9`.`c_comment`, `t9`.`region`, `t9`.`o_totalprice`, `t9`.`odate` FROM `t8` AS `t9` WHERE `t9`.`o_totalprice` > (SELECT AVG(`t13`.`o_totalprice`) AS `Mean(o_totalprice)` FROM (SELECT `t10`.`c_custkey`, `t10`.`c_name`, `t10`.`c_address`, `t10`.`c_nationkey`, `t10`.`c_phone`, `t10`.`c_acctbal`, `t10`.`c_mktsegment`, `t10`.`c_comment`, `t10`.`region`, `t10`.`o_totalprice`, `t10`.`odate` FROM `t8` AS `t10` WHERE `t10`.`region` = `t9`.`region`) AS `t13`)) AS `t15` GROUP BY 1) AS `t17` ON `t12`.`year` = `t17`.`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 d1e5ad2187ee..bff7789e00ed 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,35 +1 @@ -WITH `t9` AS ( - SELECT - EXTRACT(year FROM `t8`.`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 `t8` - GROUP BY - 1 -) -SELECT - `t11`.`year`, - `t11`.`CountStar()` AS `pre_count`, - `t13`.`CountStar()` AS `post_count` -FROM `t9` AS `t11` -INNER JOIN `t9` AS `t13` - ON `t11`.`year` = `t13`.`year` \ No newline at end of file +WITH `t9` AS (SELECT EXTRACT(year FROM `t8`.`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 `t8` GROUP BY 1) SELECT `t11`.`year`, `t11`.`CountStar()` AS `pre_count`, `t13`.`CountStar()` AS `post_count` FROM `t9` AS `t11` INNER JOIN `t9` AS `t13` ON `t11`.`year` = `t13`.`year` \ 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 1aa828dc1fc5..4cf8d1e8bcb7 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,2 +1 @@ -SELECT - UDF_TESTING.IDENTITY('hello world') AS `identity_0('hello world')` \ No newline at end of file +SELECT UDF_TESTING.IDENTITY('hello world') AS `identity_0('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 7331927594aa..c26be6f5db59 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,2 +1 @@ -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/postgres/tests/snapshots/test_functions/test_union_cte/False/out.sql b/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/False/out.sql index 0f8848f4142e..3cad2c4cc391 100644 --- a/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/False/out.sql +++ b/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/False/out.sql @@ -1 +1,33 @@ -WITH "t1" AS ( SELECT "t0"."string_col", SUM("t0"."double_col") AS "metric" FROM "functional_alltypes" AS "t0" GROUP BY 1 ) SELECT "t7"."string_col", "t7"."metric" FROM ( SELECT * FROM ( SELECT "t5"."string_col", "t5"."metric" FROM ( SELECT * FROM "t1" AS "t2" UNION ALL SELECT * FROM "t1" AS "t4" ) AS "t5" ) AS "t6" UNION ALL SELECT * FROM "t1" AS "t3" ) AS "t7" \ No newline at end of file +WITH "t1" AS ( + SELECT + "t0"."string_col", + SUM("t0"."double_col") AS "metric" + FROM "functional_alltypes" AS "t0" + GROUP BY + 1 +) +SELECT + "t7"."string_col", + "t7"."metric" +FROM ( + SELECT + * + FROM ( + SELECT + "t5"."string_col", + "t5"."metric" + FROM ( + SELECT + * + FROM "t1" AS "t2" + UNION ALL + SELECT + * + FROM "t1" AS "t4" + ) AS "t5" + ) AS "t6" + UNION ALL + SELECT + * + FROM "t1" AS "t3" +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/True/out.sql b/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/True/out.sql index 59496e7819dc..3d8fd25596a5 100644 --- a/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/True/out.sql +++ b/ibis/backends/postgres/tests/snapshots/test_functions/test_union_cte/True/out.sql @@ -1 +1,33 @@ -WITH "t1" AS ( SELECT "t0"."string_col", SUM("t0"."double_col") AS "metric" FROM "functional_alltypes" AS "t0" GROUP BY 1 ) SELECT "t7"."string_col", "t7"."metric" FROM ( SELECT * FROM ( SELECT "t5"."string_col", "t5"."metric" FROM ( SELECT * FROM "t1" AS "t2" UNION SELECT * FROM "t1" AS "t4" ) AS "t5" ) AS "t6" UNION SELECT * FROM "t1" AS "t3" ) AS "t7" \ No newline at end of file +WITH "t1" AS ( + SELECT + "t0"."string_col", + SUM("t0"."double_col") AS "metric" + FROM "functional_alltypes" AS "t0" + GROUP BY + 1 +) +SELECT + "t7"."string_col", + "t7"."metric" +FROM ( + SELECT + * + FROM ( + SELECT + "t5"."string_col", + "t5"."metric" + FROM ( + SELECT + * + FROM "t1" AS "t2" + UNION + SELECT + * + FROM "t1" AS "t4" + ) AS "t5" + ) AS "t6" + UNION + SELECT + * + FROM "t1" AS "t3" +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/postgres/tests/test_client.py b/ibis/backends/postgres/tests/test_client.py index dcfa269c370d..ecf230322273 100644 --- a/ibis/backends/postgres/tests/test_client.py +++ b/ibis/backends/postgres/tests/test_client.py @@ -64,13 +64,12 @@ def test_list_tables(con): assert len(con.list_tables(like="functional")) == 1 -def test_compile_toplevel(snapshot): +def test_compile_toplevel(assert_sql): t = ibis.table([("foo", "double")], name="t0") # it works! expr = t.foo.sum() - result = ibis.postgres.compile(expr) - snapshot.assert_match(str(result), "out.sql") + assert_sql(expr) def test_list_databases(con): diff --git a/ibis/backends/postgres/tests/test_functions.py b/ibis/backends/postgres/tests/test_functions.py index f12d72f61673..4d403fbdc137 100644 --- a/ibis/backends/postgres/tests/test_functions.py +++ b/ibis/backends/postgres/tests/test_functions.py @@ -33,14 +33,14 @@ ), ], ) -def test_cast(alltypes, expr_fn, snapshot): +def test_cast(alltypes, expr_fn, assert_sql): expr = expr_fn(alltypes) - snapshot.assert_match(expr.compile(), "out.sql") + assert_sql(expr) -def test_date_cast(alltypes, snapshot): +def test_date_cast(alltypes, assert_sql): result = alltypes.date_string_col.cast("date") - snapshot.assert_match(result.compile(), "out.sql") + assert_sql(result) @pytest.mark.parametrize( @@ -66,7 +66,7 @@ def test_noop_cast(alltypes, column): assert col.cast(col.type()).equals(col) -def test_timestamp_cast_noop(alltypes, snapshot): +def test_timestamp_cast_noop(alltypes, assert_sql): # See GH #592 timestamp_col_type = alltypes.timestamp_col.type() result1 = alltypes.timestamp_col.cast(timestamp_col_type) @@ -77,8 +77,8 @@ def test_timestamp_cast_noop(alltypes, snapshot): assert result1.type() == timestamp_col_type - snapshot.assert_match(result1.compile(), "out1.sql") - snapshot.assert_match(result2.compile(), "out2.sql") + assert_sql(result1, "out1.sql") + assert_sql(result2, "out2.sql") @pytest.mark.parametrize( @@ -486,14 +486,13 @@ def test_category_label(alltypes, df): @pytest.mark.parametrize("distinct", [True, False]) -def test_union_cte(alltypes, distinct, snapshot): +def test_union_cte(alltypes, distinct, assert_sql): t = alltypes expr1 = t.group_by(t.string_col).aggregate(metric=t.double_col.sum()) expr2 = expr1.view() expr3 = expr1.view() expr = expr1.union(expr2, distinct=distinct).union(expr3, distinct=distinct) - result = " ".join(line.strip() for line in expr.compile().splitlines()) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -1025,7 +1024,7 @@ def test_identical_to(con, df): tm.assert_series_equal(result, expected) -def test_analytic_functions(alltypes, snapshot): +def test_analytic_functions(alltypes, assert_sql): expr = alltypes.select( rank=alltypes.double_col.rank(), dense_rank=alltypes.double_col.dense_rank(), @@ -1033,7 +1032,7 @@ def test_analytic_functions(alltypes, snapshot): ntile=alltypes.double_col.ntile(7), percent_rank=alltypes.double_col.percent_rank(), ) - snapshot.assert_match(str(ibis.to_sql(expr)), "out.sql") + assert_sql(expr) @pytest.mark.parametrize("opname", ["invert", "neg"]) diff --git a/ibis/backends/postgres/tests/test_geospatial.py b/ibis/backends/postgres/tests/test_geospatial.py index cef5b04478b7..9821f9d3ec26 100644 --- a/ibis/backends/postgres/tests/test_geospatial.py +++ b/ibis/backends/postgres/tests/test_geospatial.py @@ -66,9 +66,8 @@ point_geog_2, ], ) -def test_literal_geospatial_explicit(con, expr, snapshot): - result = con.compile(expr) - snapshot.assert_match(result, "out.sql") +def test_literal_geospatial_explicit(expr, assert_sql): + assert_sql(expr) @pytest.mark.parametrize( @@ -85,8 +84,9 @@ def test_literal_geospatial_explicit(con, expr, snapshot): shp_multipoint_0, ], ) -def test_literal_geospatial_inferred(con, shp, snapshot): - snapshot.assert_match(con.compile(ibis.literal(shp)), "out.sql") +def test_literal_geospatial_inferred(shp, assert_sql): + expr = ibis.literal(shp) + assert_sql(expr) @pytest.mark.parametrize( @@ -407,10 +407,10 @@ def test_geo_dataframe(geotable): ), ], ) -def test_geo_literals_smoke(con, shape, value, modifier, snapshot): +def test_geo_literals_smoke(con, shape, value, modifier, assert_sql): """Smoke tests for geo spatial literals.""" expr = ibis.literal(value, type=getattr(dt, shape).copy(**modifier)) - snapshot.assert_match(con.compile(expr), "out.sql") + assert_sql(expr) @pytest.mark.parametrize( @@ -472,29 +472,30 @@ def test_geo_literals_smoke(con, shape, value, modifier, snapshot): ), ], ) -def test_geo_ops_smoke(geotable, fn_expr, snapshot): +def test_geo_ops_smoke(geotable, fn_expr, assert_sql): """Smoke tests for geo spatial operations.""" - snapshot.assert_match(fn_expr(geotable).compile(), "out.sql") + expr = fn_expr(geotable) + assert_sql(expr) -def test_geo_equals(geotable, snapshot): +def test_geo_equals(geotable, assert_sql): # Fix https://github.com/ibis-project/ibis/pull/2956 expr = geotable.mutate( Location_Latitude=geotable.geo_point.y(), Latitude=geotable.geo_point.y() ) - snapshot.assert_match(expr.compile(), "out1.sql") + assert_sql(expr, "out1.sql") # simple test using == expr = geotable.geo_point == geotable.geo_point - snapshot.assert_match(expr.compile(), "out2.sql") + assert_sql(expr, "out2.sql") result = expr.execute() assert not result.empty assert result.all() # using geo_equals expr = geotable.geo_point.geo_equals(geotable.geo_point).name("tmp") - snapshot.assert_match(expr.compile(), "out3.sql") + assert_sql(expr, "out3.sql") result = expr.execute() assert not result.empty assert result.all() diff --git a/ibis/backends/postgres/tests/test_postgis.py b/ibis/backends/postgres/tests/test_postgis.py index 34d4972a80f8..c1c1b6484715 100644 --- a/ibis/backends/postgres/tests/test_postgis.py +++ b/ibis/backends/postgres/tests/test_postgis.py @@ -26,38 +26,30 @@ def test_empty_select(geotable): assert len(result) == 0 -def test_select_point_geodata(geotable, snapshot): +def test_select_point_geodata(geotable, assert_sql): expr = geotable["geo_point"] - sqla_expr = expr.compile() - compiled = str(sqla_expr) - snapshot.assert_match(compiled, "out.sql") + assert_sql(expr) data = expr.execute() assert data.geom_type.iloc[0] == "Point" -def test_select_linestring_geodata(geotable, snapshot): +def test_select_linestring_geodata(geotable, assert_sql): expr = geotable["geo_linestring"] - sqla_expr = expr.compile() - compiled = str(sqla_expr) - snapshot.assert_match(compiled, "out.sql") + assert_sql(expr) data = expr.execute() assert data.geom_type.iloc[0] == "LineString" -def test_select_polygon_geodata(geotable, snapshot): +def test_select_polygon_geodata(geotable, assert_sql): expr = geotable["geo_polygon"] - sqla_expr = expr.compile() - compiled = str(sqla_expr) - snapshot.assert_match(compiled, "out.sql") + assert_sql(expr) data = expr.execute() assert data.geom_type.iloc[0] == "Polygon" -def test_select_multipolygon_geodata(geotable, snapshot): +def test_select_multipolygon_geodata(geotable, assert_sql): expr = geotable["geo_multipolygon"] - sqla_expr = expr.compile() - compiled = str(sqla_expr) - snapshot.assert_match(compiled, "out.sql") + assert_sql(expr) data = expr.execute() assert data.geom_type.iloc[0] == "MultiPolygon" diff --git a/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/False/out.sql b/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/False/out.sql index 0f8848f4142e..3cad2c4cc391 100644 --- a/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/False/out.sql +++ b/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/False/out.sql @@ -1 +1,33 @@ -WITH "t1" AS ( SELECT "t0"."string_col", SUM("t0"."double_col") AS "metric" FROM "functional_alltypes" AS "t0" GROUP BY 1 ) SELECT "t7"."string_col", "t7"."metric" FROM ( SELECT * FROM ( SELECT "t5"."string_col", "t5"."metric" FROM ( SELECT * FROM "t1" AS "t2" UNION ALL SELECT * FROM "t1" AS "t4" ) AS "t5" ) AS "t6" UNION ALL SELECT * FROM "t1" AS "t3" ) AS "t7" \ No newline at end of file +WITH "t1" AS ( + SELECT + "t0"."string_col", + SUM("t0"."double_col") AS "metric" + FROM "functional_alltypes" AS "t0" + GROUP BY + 1 +) +SELECT + "t7"."string_col", + "t7"."metric" +FROM ( + SELECT + * + FROM ( + SELECT + "t5"."string_col", + "t5"."metric" + FROM ( + SELECT + * + FROM "t1" AS "t2" + UNION ALL + SELECT + * + FROM "t1" AS "t4" + ) AS "t5" + ) AS "t6" + UNION ALL + SELECT + * + FROM "t1" AS "t3" +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/True/out.sql b/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/True/out.sql index 59496e7819dc..3d8fd25596a5 100644 --- a/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/True/out.sql +++ b/ibis/backends/risingwave/tests/snapshots/test_functions/test_union_cte/True/out.sql @@ -1 +1,33 @@ -WITH "t1" AS ( SELECT "t0"."string_col", SUM("t0"."double_col") AS "metric" FROM "functional_alltypes" AS "t0" GROUP BY 1 ) SELECT "t7"."string_col", "t7"."metric" FROM ( SELECT * FROM ( SELECT "t5"."string_col", "t5"."metric" FROM ( SELECT * FROM "t1" AS "t2" UNION SELECT * FROM "t1" AS "t4" ) AS "t5" ) AS "t6" UNION SELECT * FROM "t1" AS "t3" ) AS "t7" \ No newline at end of file +WITH "t1" AS ( + SELECT + "t0"."string_col", + SUM("t0"."double_col") AS "metric" + FROM "functional_alltypes" AS "t0" + GROUP BY + 1 +) +SELECT + "t7"."string_col", + "t7"."metric" +FROM ( + SELECT + * + FROM ( + SELECT + "t5"."string_col", + "t5"."metric" + FROM ( + SELECT + * + FROM "t1" AS "t2" + UNION + SELECT + * + FROM "t1" AS "t4" + ) AS "t5" + ) AS "t6" + UNION + SELECT + * + FROM "t1" AS "t3" +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/risingwave/tests/test_client.py b/ibis/backends/risingwave/tests/test_client.py index 918b648b7bc8..b48f2af95b53 100644 --- a/ibis/backends/risingwave/tests/test_client.py +++ b/ibis/backends/risingwave/tests/test_client.py @@ -49,12 +49,11 @@ def test_list_tables(con): assert len(con.list_tables(like="functional")) == 1 -def test_compile_toplevel(snapshot): +def test_compile_toplevel(assert_sql): t = ibis.table([("foo", "double")], name="t0") expr = t.foo.sum() - result = ibis.postgres.compile(expr) - snapshot.assert_match(str(result), "out.sql") + assert_sql(expr) def test_list_databases(con): diff --git a/ibis/backends/risingwave/tests/test_functions.py b/ibis/backends/risingwave/tests/test_functions.py index dd95a81a260e..285a8672d48a 100644 --- a/ibis/backends/risingwave/tests/test_functions.py +++ b/ibis/backends/risingwave/tests/test_functions.py @@ -317,14 +317,13 @@ def test_category_label(alltypes, df): @pytest.mark.parametrize("distinct", [True, False]) -def test_union_cte(alltypes, distinct, snapshot): +def test_union_cte(alltypes, distinct, assert_sql): t = alltypes expr1 = t.group_by(t.string_col).aggregate(metric=t.double_col.sum()) expr2 = expr1.view() expr3 = expr1.view() expr = expr1.union(expr2, distinct=distinct).union(expr3, distinct=distinct) - result = " ".join(line.strip() for line in expr.compile().splitlines()) - snapshot.assert_match(result, "out.sql") + assert_sql(expr) @pytest.mark.parametrize( diff --git a/ibis/backends/sql/__init__.py b/ibis/backends/sql/__init__.py index 8d100f33e93a..67b256afec72 100644 --- a/ibis/backends/sql/__init__.py +++ b/ibis/backends/sql/__init__.py @@ -112,11 +112,16 @@ def _to_sqlglot( return sql def compile( - self, expr: ir.Expr, limit: str | None = None, params=None, **kwargs: Any + self, + expr: ir.Expr, + limit: str | None = None, + params=None, + pretty: bool = False, + **kwargs: Any, ): """Compile an Ibis expression to a SQL string.""" query = self._to_sqlglot(expr, limit=limit, params=params, **kwargs) - sql = query.sql(dialect=self.dialect, pretty=True, copy=False) + sql = query.sql(dialect=self.dialect, pretty=pretty, copy=False) self._log(sql) return sql diff --git a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/clickhouse/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/clickhouse/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/clickhouse/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/clickhouse/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/datafusion/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/datafusion/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/datafusion/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/datafusion/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/druid/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/druid/out.sql index e69e89fc3d4b..1b6d96c17565 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/druid/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/druid/out.sql @@ -1,7 +1 @@ -SELECT - "t0"."id", - 1 - ( - MOD("t0"."id", 2) - ) AS "bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +SELECT "t0"."id", 1 - (MOD("t0"."id", 2)) AS "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_default_limit/duckdb/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/duckdb/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/duckdb/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/exasol/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/exasol/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/exasol/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/exasol/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/flink/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/flink/out.sql index f63de03c314a..4b2e65281a44 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/flink/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/flink/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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_default_limit/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/impala/out.sql index f63de03c314a..4b2e65281a44 100644 --- 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 @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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_default_limit/mssql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mssql/out.sql index c3c69f741a10..7772bf8b2d43 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mssql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mssql/out.sql @@ -1,10 +1 @@ -SELECT - [t2].[id], - IIF([t2].[bool_col] <> 0, 1, 0) AS [bool_col] -FROM ( - SELECT - TOP 11 - [t0].[id], - [t0].[bool_col] - FROM [functional_alltypes] AS [t0] -) AS [t2] \ No newline at end of file +SELECT [t2].[id], IIF([t2].[bool_col] <> 0, 1, 0) AS [bool_col] FROM (SELECT TOP 11 [t0].[id], [t0].[bool_col] FROM [functional_alltypes] AS [t0]) AS [t2] \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mysql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mysql/out.sql index b4d624684bfc..730401f05d86 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mysql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/mysql/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` = 1 AS `bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +SELECT `t0`.`id`, `t0`.`bool_col` = 1 AS `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_default_limit/oracle/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/oracle/out.sql index 2124da09f645..56a7f2ff6fe8 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/oracle/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/oracle/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" = 1 AS "bool_col" -FROM "functional_alltypes" "t0" -FETCH FIRST 11 ROWS ONLY \ No newline at end of file +SELECT "t0"."id", "t0"."bool_col" = 1 AS "bool_col" FROM "functional_alltypes" "t0" FETCH FIRST 11 ROWS ONLY \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/postgres/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/postgres/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/postgres/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/postgres/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/pyspark/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/pyspark/out.sql index f63de03c314a..4b2e65281a44 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/pyspark/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/pyspark/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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_default_limit/risingwave/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/risingwave/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/risingwave/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/risingwave/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/snowflake/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/snowflake/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/snowflake/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/snowflake/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/sqlite/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/sqlite/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/sqlite/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/sqlite/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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_default_limit/trino/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/trino/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_default_limit/trino/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_default_limit/trino/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/clickhouse/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/clickhouse/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/clickhouse/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/clickhouse/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/datafusion/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/datafusion/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/datafusion/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/datafusion/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/druid/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/druid/out.sql index e69e89fc3d4b..1b6d96c17565 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/druid/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/druid/out.sql @@ -1,7 +1 @@ -SELECT - "t0"."id", - 1 - ( - MOD("t0"."id", 2) - ) AS "bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +SELECT "t0"."id", 1 - (MOD("t0"."id", 2)) AS "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/duckdb/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/duckdb/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/duckdb/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/exasol/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/exasol/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/exasol/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/exasol/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/flink/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/flink/out.sql index f63de03c314a..4b2e65281a44 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/flink/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/flink/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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 index f63de03c314a..4b2e65281a44 100644 --- 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 @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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/mssql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mssql/out.sql index c3c69f741a10..7772bf8b2d43 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mssql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mssql/out.sql @@ -1,10 +1 @@ -SELECT - [t2].[id], - IIF([t2].[bool_col] <> 0, 1, 0) AS [bool_col] -FROM ( - SELECT - TOP 11 - [t0].[id], - [t0].[bool_col] - FROM [functional_alltypes] AS [t0] -) AS [t2] \ No newline at end of file +SELECT [t2].[id], IIF([t2].[bool_col] <> 0, 1, 0) AS [bool_col] FROM (SELECT TOP 11 [t0].[id], [t0].[bool_col] FROM [functional_alltypes] AS [t0]) AS [t2] \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mysql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mysql/out.sql index b4d624684bfc..730401f05d86 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mysql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/mysql/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` = 1 AS `bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +SELECT `t0`.`id`, `t0`.`bool_col` = 1 AS `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/oracle/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/oracle/out.sql index 2124da09f645..56a7f2ff6fe8 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/oracle/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/oracle/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" = 1 AS "bool_col" -FROM "functional_alltypes" "t0" -FETCH FIRST 11 ROWS ONLY \ No newline at end of file +SELECT "t0"."id", "t0"."bool_col" = 1 AS "bool_col" FROM "functional_alltypes" "t0" FETCH FIRST 11 ROWS ONLY \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/postgres/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/postgres/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/postgres/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/postgres/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/pyspark/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/pyspark/out.sql index f63de03c314a..4b2e65281a44 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/pyspark/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/pyspark/out.sql @@ -1,5 +1 @@ -SELECT - `t0`.`id`, - `t0`.`bool_col` -FROM `functional_alltypes` AS `t0` -LIMIT 11 \ No newline at end of file +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/risingwave/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/risingwave/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/risingwave/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/risingwave/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/snowflake/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/snowflake/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/snowflake/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/snowflake/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/sqlite/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/sqlite/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/sqlite/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/sqlite/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/trino/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/trino/out.sql index b309cd65374d..4c86fd9a336f 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/trino/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_disable_query_limit/trino/out.sql @@ -1,5 +1 @@ -SELECT - "t0"."id", - "t0"."bool_col" -FROM "functional_alltypes" AS "t0" -LIMIT 11 \ No newline at end of file +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/clickhouse/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/clickhouse/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/clickhouse/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/clickhouse/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/datafusion/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/datafusion/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/datafusion/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/datafusion/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/druid/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/druid/out.sql index 6195869f606c..a559e69749bb 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/druid/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/druid/out.sql @@ -1,22 +1 @@ -SELECT - SUM("t1"."bigint_col") AS "Sum(bigint_col)" -FROM ( - SELECT - "t0"."__time", - "t0"."id", - 1 - ( - MOD("t0"."id", 2) - ) AS "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" -) AS "t1" \ No newline at end of file +SELECT SUM("t1"."bigint_col") AS "Sum(bigint_col)" FROM (SELECT "t0"."__time", "t0"."id", 1 - (MOD("t0"."id", 2)) AS "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") AS "t1" \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/duckdb/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/duckdb/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/duckdb/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/exasol/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/exasol/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/exasol/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/exasol/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/flink/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/flink/out.sql index d8a9c4090dc1..89dcdcf038f2 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/flink/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/flink/out.sql @@ -1,3 +1 @@ -SELECT - SUM(`t0`.`bigint_col`) AS `Sum(bigint_col)` -FROM `functional_alltypes` AS `t0` \ No newline at end of file +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_interactive_execute_on_repr/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/impala/out.sql index d8a9c4090dc1..89dcdcf038f2 100644 --- 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 @@ -1,3 +1 @@ -SELECT - SUM(`t0`.`bigint_col`) AS `Sum(bigint_col)` -FROM `functional_alltypes` AS `t0` \ No newline at end of file +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_interactive_execute_on_repr/mssql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mssql/out.sql index a4c958333e78..c80b3be1ecd4 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mssql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mssql/out.sql @@ -1,3 +1 @@ -SELECT - SUM([t0].[bigint_col]) AS [Sum(bigint_col)] -FROM [functional_alltypes] AS [t0] \ No newline at end of file +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_interactive_execute_on_repr/mysql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mysql/out.sql index d93091fd3aba..1757df1def95 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mysql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/mysql/out.sql @@ -1,19 +1 @@ -SELECT - SUM(`t1`.`bigint_col`) AS `Sum(bigint_col)` -FROM ( - SELECT - `t0`.`id`, - `t0`.`bool_col` = 1 AS `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` -) AS `t1` \ No newline at end of file +SELECT SUM(`t1`.`bigint_col`) AS `Sum(bigint_col)` FROM (SELECT `t0`.`id`, `t0`.`bool_col` = 1 AS `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`) AS `t1` \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/oracle/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/oracle/out.sql index 7b50874f2771..4eadb6631cc7 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/oracle/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/oracle/out.sql @@ -1,19 +1 @@ -SELECT - SUM("t1"."bigint_col") AS "Sum(bigint_col)" -FROM ( - SELECT - "t0"."id", - "t0"."bool_col" = 1 AS "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" "t0" -) "t1" \ No newline at end of file +SELECT SUM("t1"."bigint_col") AS "Sum(bigint_col)" FROM (SELECT "t0"."id", "t0"."bool_col" = 1 AS "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" "t0") "t1" \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/postgres/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/postgres/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/postgres/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/postgres/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/pyspark/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/pyspark/out.sql index d8a9c4090dc1..89dcdcf038f2 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/pyspark/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/pyspark/out.sql @@ -1,3 +1 @@ -SELECT - SUM(`t0`.`bigint_col`) AS `Sum(bigint_col)` -FROM `functional_alltypes` AS `t0` \ No newline at end of file +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_interactive_execute_on_repr/risingwave/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/risingwave/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/risingwave/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/risingwave/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/snowflake/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/snowflake/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/snowflake/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/snowflake/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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_interactive_execute_on_repr/sqlite/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/sqlite/out.sql index 3cadfca6be22..4ec1b08dba7c 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/sqlite/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/sqlite/out.sql @@ -1,19 +1 @@ -SELECT - SUM("t1"."bigint_col") AS "Sum(bigint_col)" -FROM ( - 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" -) AS "t1" \ No newline at end of file +SELECT SUM("t1"."bigint_col") AS "Sum(bigint_col)" FROM (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") AS "t1" \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/trino/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/trino/out.sql index 6bd0ba8c995d..8f15b0aa87a0 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/trino/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_interactive_execute_on_repr/trino/out.sql @@ -1,3 +1 @@ -SELECT - SUM("t0"."bigint_col") AS "Sum(bigint_col)" -FROM "functional_alltypes" AS "t0" \ No newline at end of file +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/clickhouse/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/clickhouse/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/clickhouse/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/clickhouse/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/datafusion/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/datafusion/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/datafusion/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/datafusion/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/druid/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/druid/out.sql index 38962733a72a..b03c04cb3291 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/druid/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/druid/out.sql @@ -1,12 +1 @@ -SELECT - * -FROM ( - SELECT - "t0"."id", - 1 - ( - MOD("t0"."id", 2) - ) AS "bool_col" - FROM "functional_alltypes" AS "t0" - LIMIT 10 -) AS "t2" -LIMIT 11 \ No newline at end of file +SELECT * FROM (SELECT "t0"."id", 1 - (MOD("t0"."id", 2)) AS "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_interactive/test_respect_set_limit/duckdb/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/duckdb/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/duckdb/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/exasol/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/exasol/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/exasol/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/exasol/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/flink/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/flink/out.sql index d4b1b19815b0..2975e9a271b2 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/flink/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/flink/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/impala/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/impala/out.sql index d4b1b19815b0..2975e9a271b2 100644 --- 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 @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/mssql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mssql/out.sql index 06e59f87c727..d7ddb038d751 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mssql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mssql/out.sql @@ -1,15 +1 @@ -SELECT - [t3].[id], - IIF([t3].[bool_col] <> 0, 1, 0) AS [bool_col] -FROM ( - SELECT - TOP 11 - * - FROM ( - SELECT - TOP 10 - [t0].[id], - [t0].[bool_col] - FROM [functional_alltypes] AS [t0] - ) AS [t2] -) AS [t3] \ No newline at end of file +SELECT [t3].[id], IIF([t3].[bool_col] <> 0, 1, 0) AS [bool_col] FROM (SELECT TOP 11 * FROM (SELECT TOP 10 [t0].[id], [t0].[bool_col] FROM [functional_alltypes] AS [t0]) AS [t2]) AS [t3] \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mysql/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mysql/out.sql index 1c3fb645041c..344585eb2f06 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mysql/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/mysql/out.sql @@ -1,10 +1 @@ -SELECT - * -FROM ( - SELECT - `t0`.`id`, - `t0`.`bool_col` = 1 AS `bool_col` - FROM `functional_alltypes` AS `t0` - LIMIT 10 -) AS `t2` -LIMIT 11 \ No newline at end of file +SELECT * FROM (SELECT `t0`.`id`, `t0`.`bool_col` = 1 AS `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_interactive/test_respect_set_limit/oracle/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/oracle/out.sql index 96217eecd9a1..3a1fb9c311c4 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/oracle/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/oracle/out.sql @@ -1,10 +1 @@ -SELECT - * -FROM ( - SELECT - "t0"."id", - "t0"."bool_col" = 1 AS "bool_col" - FROM "functional_alltypes" "t0" - FETCH FIRST 10 ROWS ONLY -) "t2" -FETCH FIRST 11 ROWS ONLY \ No newline at end of file +SELECT * FROM (SELECT "t0"."id", "t0"."bool_col" = 1 AS "bool_col" FROM "functional_alltypes" "t0" FETCH FIRST 10 ROWS ONLY) "t2" FETCH FIRST 11 ROWS ONLY \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/postgres/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/postgres/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/postgres/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/postgres/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/pyspark/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/pyspark/out.sql index d4b1b19815b0..2975e9a271b2 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/pyspark/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/pyspark/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/risingwave/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/risingwave/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/risingwave/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/risingwave/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/snowflake/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/snowflake/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/snowflake/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/snowflake/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/sqlite/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/sqlite/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/sqlite/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/sqlite/out.sql @@ -1,10 +1 @@ -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 +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_interactive/test_respect_set_limit/trino/out.sql b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/trino/out.sql index 97338646649f..10ccd5d00050 100644 --- a/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/trino/out.sql +++ b/ibis/backends/tests/snapshots/test_interactive/test_respect_set_limit/trino/out.sql @@ -1,10 +1 @@ -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 +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/expr/types/core.py b/ibis/expr/types/core.py index 04e4aa07ec4f..6adf1d19aa36 100644 --- a/ibis/expr/types/core.py +++ b/ibis/expr/types/core.py @@ -376,6 +376,7 @@ def compile( limit: int | None = None, timecontext: TimeContext | None = None, params: Mapping[ir.Value, Any] | None = None, + pretty: bool = False, ): """Compile to an execution target. @@ -394,9 +395,11 @@ def compile( execute will result in an error. params Mapping of scalar parameter expressions to value + pretty + In case of SQL backends, return a pretty formatted SQL query. """ return self._find_backend().compile( - self, limit=limit, timecontext=timecontext, params=params + self, limit=limit, timecontext=timecontext, params=params, pretty=pretty ) @experimental