From e4ff1bd71088b0f49d5d2d40d7bc040710d705ef Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:38:09 -0400 Subject: [PATCH] fix(duckdb): avoid literals casts that might defeat optimization --- .../test_geospatial_dwithin/out.sql | 2 +- ibis/backends/sql/compilers/duckdb.py | 29 ++++++++----- .../test_many_subqueries/duckdb/out.sql | 4 +- .../test_sql/test_isin_bug/duckdb/out.sql | 2 +- .../test_union_aliasing/duckdb/out.sql | 42 +++++++++---------- .../test_agg_and_non_agg_filter/out.sql | 4 +- .../test_compiler/test_agg_filter/out.sql | 8 ++-- .../test_agg_filter_with_alias/out.sql | 8 ++-- .../test_column_expr_default_name/out.sql | 2 +- .../test_column_expr_retains_name/out.sql | 2 +- .../test_compiler/test_count_distinct/out.sql | 2 +- .../test_difference_project_column/out.sql | 4 +- .../test_having_from_filter/out.sql | 2 +- .../test_compiler/test_having_size/out.sql | 2 +- .../test_intersect_project_column/out.sql | 4 +- .../test_pushdown_with_or/out.sql | 11 +++-- .../test_simple_agg_filter/out.sql | 4 +- .../test_table_difference/out.sql | 4 +- .../test_table_drop_with_filter/out.sql | 2 +- .../test_table_intersect/out.sql | 4 +- .../test_compiler/test_union/out.sql | 4 +- .../test_union_project_column/out.sql | 4 +- .../test_aggregate_having/explicit.sql | 2 +- .../test_aggregate_having/inline.sql | 2 +- .../agg_filtered.sql | 2 +- .../agg_filtered2.sql | 4 +- .../filtered.sql | 2 +- .../proj.sql | 2 +- .../test_select_sql/test_bool_bool/out.sql | 2 +- .../result.sql | 2 +- .../test_complex_union/result.sql | 4 +- .../expr4.sql | 2 +- .../test_fuse_projections/project.sql | 2 +- .../test_fuse_projections/project_filter.sql | 4 +- .../result.sql | 6 +-- .../result.sql | 4 +- .../out.sql | 8 +--- .../test_loj_subquery_filter_handling/out.sql | 4 +- .../test_projection_filter_fuse/out.sql | 2 +- .../test_select_sql/filter_then_limit/out.sql | 2 +- .../test_select_sql/limit_then_filter/out.sql | 2 +- .../test_tpch_self_join_failure/out.sql | 2 +- .../test_where_no_pushdown_possible/out.sql | 2 +- .../test_where_with_between/out.sql | 3 +- .../test_where_with_join/out.sql | 2 +- .../test_aggregate/having_count/out.sql | 2 +- .../test_aggregate/having_sum/out.sql | 2 +- .../snapshots/test_sql/test_between/out.sql | 2 +- .../test_boolean_conjunction/and/out.sql | 7 ++-- .../test_boolean_conjunction/or/out.sql | 7 ++-- .../snapshots/test_sql/test_coalesce/out.sql | 6 +-- .../test_sql/test_comparisons/eq/out.sql | 2 +- .../test_sql/test_comparisons/ge/out.sql | 2 +- .../test_sql/test_comparisons/gt/out.sql | 2 +- .../test_sql/test_comparisons/le/out.sql | 2 +- .../test_sql/test_comparisons/lt/out.sql | 2 +- .../test_sql/test_comparisons/ne/out.sql | 2 +- .../out.sql | 2 +- .../out.sql | 2 +- .../test_sql/test_limit_filter/out.sql | 2 +- .../test_sql/test_limit_subquery/out.sql | 2 +- .../test_lower_projection_sort_key/out.sql | 2 +- .../out.sql | 2 +- .../test_sql/test_named_expr/out.sql | 2 +- .../snapshots/test_sql/test_negate/out.sql | 2 +- .../test_sql/test_no_cart_join/out.sql | 12 ++---- .../test_sql/test_order_by_expr/out.sql | 2 +- .../test_sql/test_searched_case/out.sql | 8 ++-- .../test_where_simple_comparisons/out.sql | 4 +- ibis/backends/tests/sql/test_sql.py | 14 ------- ibis/backends/tests/test_numeric.py | 20 ++++----- ibis/expr/types/generic.py | 2 +- 72 files changed, 156 insertions(+), 177 deletions(-) diff --git a/ibis/backends/duckdb/tests/snapshots/test_geospatial/test_geospatial_dwithin/out.sql b/ibis/backends/duckdb/tests/snapshots/test_geospatial/test_geospatial_dwithin/out.sql index a7503ad3c708..cc2c861b57cd 100644 --- a/ibis/backends/duckdb/tests/snapshots/test_geospatial/test_geospatial_dwithin/out.sql +++ b/ibis/backends/duckdb/tests/snapshots/test_geospatial/test_geospatial_dwithin/out.sql @@ -1,3 +1,3 @@ SELECT - ST_DWITHIN("t0"."geom", "t0"."geom", CAST(3.0 AS DOUBLE)) AS "tmp" + ST_DWITHIN("t0"."geom", "t0"."geom", 3.0) AS "tmp" FROM "t" AS "t0" \ No newline at end of file diff --git a/ibis/backends/sql/compilers/duckdb.py b/ibis/backends/sql/compilers/duckdb.py index 7adcf362e3b9..fe8f53e2d3a1 100644 --- a/ibis/backends/sql/compilers/duckdb.py +++ b/ibis/backends/sql/compilers/duckdb.py @@ -201,10 +201,17 @@ def visit_ArrayZip(self, op, *, arg): any_arg_null = sg.or_(*(arr.is_(NULL) for arr in arg)) return self.if_(any_arg_null, NULL, zipped_arrays) + def visit_Array(self, op, *, exprs): + return self.cast(self.f.array(*exprs), op.dtype) + def visit_Map(self, op, *, keys, values): # workaround for https://github.com/ibis-project/ibis/issues/8632 return self.if_( - sg.or_(keys.is_(NULL), values.is_(NULL)), NULL, self.f.map(keys, values) + sg.or_(keys.is_(NULL), values.is_(NULL)), + NULL, + self.f.map( + self.cast(keys, op.keys.dtype), self.cast(values, op.values.dtype) + ), ) def visit_MapGet(self, op, *, arg, key, default): @@ -378,6 +385,8 @@ def visit_NonNullLiteral(self, op, *, value, dtype): return self.cast( str(value), to=dt.float32 if dtype.is_decimal() else dtype ) + if dtype.is_floating() or dtype.is_integer(): + return sge.convert(value) return self.cast(value, dtype) elif dtype.is_time(): return self.f.make_time( @@ -401,16 +410,16 @@ def visit_NonNullLiteral(self, op, *, value, dtype): return self.f[funcname](*args) elif dtype.is_struct(): - return sge.Struct.from_arg_list( - [ - sge.PropertyEQ( - this=sg.to_identifier(k, quoted=self.quoted), - expression=self.visit_Literal( + return self.cast( + sge.Struct.from_arg_list( + [ + self.visit_Literal( ops.Literal(v, field_dtype), value=v, dtype=field_dtype - ), - ) - for field_dtype, (k, v) in zip(dtype.types, value.items()) - ] + ) + for field_dtype, v in zip(dtype.types, value.values()) + ] + ), + op.dtype, ) else: return None diff --git a/ibis/backends/tests/snapshots/test_generic/test_many_subqueries/duckdb/out.sql b/ibis/backends/tests/snapshots/test_generic/test_many_subqueries/duckdb/out.sql index e0040fe91644..9c85ae747f64 100644 --- a/ibis/backends/tests/snapshots/test_generic/test_many_subqueries/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_generic/test_many_subqueries/duckdb/out.sql @@ -1,12 +1,12 @@ WITH "t1" AS ( SELECT "t0"."street", - ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - CAST(1 AS TINYINT) AS "key" + ROW_NUMBER() OVER (ORDER BY "t0"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key" FROM "data" AS "t0" ), "t7" AS ( SELECT "t6"."street", - ROW_NUMBER() OVER (ORDER BY "t6"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - CAST(1 AS TINYINT) AS "key" + ROW_NUMBER() OVER (ORDER BY "t6"."street" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) - 1 AS "key" FROM ( SELECT "t3"."street", diff --git a/ibis/backends/tests/snapshots/test_sql/test_isin_bug/duckdb/out.sql b/ibis/backends/tests/snapshots/test_sql/test_isin_bug/duckdb/out.sql index c7c92a8b6abe..fb1657e229db 100644 --- a/ibis/backends/tests/snapshots/test_sql/test_isin_bug/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_sql/test_isin_bug/duckdb/out.sql @@ -4,6 +4,6 @@ SELECT * FROM "t" AS "t0" WHERE - "t0"."x" > CAST(2 AS TINYINT) + "t0"."x" > 2 ) AS "InSubquery(x)" FROM "t" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/snapshots/test_sql/test_union_aliasing/duckdb/out.sql b/ibis/backends/tests/snapshots/test_sql/test_union_aliasing/duckdb/out.sql index 90c27a09e25e..f20e2b58b33e 100644 --- a/ibis/backends/tests/snapshots/test_sql/test_union_aliasing/duckdb/out.sql +++ b/ibis/backends/tests/snapshots/test_sql/test_union_aliasing/duckdb/out.sql @@ -26,26 +26,26 @@ WITH "t5" AS ( SELECT "t0"."field_of_study", UNNEST( - [ - {'years': '1970-71', 'degrees': "t0"."1970-71"}, - {'years': '1975-76', 'degrees': "t0"."1975-76"}, - {'years': '1980-81', 'degrees': "t0"."1980-81"}, - {'years': '1985-86', 'degrees': "t0"."1985-86"}, - {'years': '1990-91', 'degrees': "t0"."1990-91"}, - {'years': '1995-96', 'degrees': "t0"."1995-96"}, - {'years': '2000-01', 'degrees': "t0"."2000-01"}, - {'years': '2005-06', 'degrees': "t0"."2005-06"}, - {'years': '2010-11', 'degrees': "t0"."2010-11"}, - {'years': '2011-12', 'degrees': "t0"."2011-12"}, - {'years': '2012-13', 'degrees': "t0"."2012-13"}, - {'years': '2013-14', 'degrees': "t0"."2013-14"}, - {'years': '2014-15', 'degrees': "t0"."2014-15"}, - {'years': '2015-16', 'degrees': "t0"."2015-16"}, - {'years': '2016-17', 'degrees': "t0"."2016-17"}, - {'years': '2017-18', 'degrees': "t0"."2017-18"}, - {'years': '2018-19', 'degrees': "t0"."2018-19"}, - {'years': '2019-20', 'degrees': "t0"."2019-20"} - ] + CAST([ + ROW('1970-71', "t0"."1970-71"), + ROW('1975-76', "t0"."1975-76"), + ROW('1980-81', "t0"."1980-81"), + ROW('1985-86', "t0"."1985-86"), + ROW('1990-91', "t0"."1990-91"), + ROW('1995-96', "t0"."1995-96"), + ROW('2000-01', "t0"."2000-01"), + ROW('2005-06', "t0"."2005-06"), + ROW('2010-11', "t0"."2010-11"), + ROW('2011-12', "t0"."2011-12"), + ROW('2012-13', "t0"."2012-13"), + ROW('2013-14', "t0"."2013-14"), + ROW('2014-15', "t0"."2014-15"), + ROW('2015-16', "t0"."2015-16"), + ROW('2016-17', "t0"."2016-17"), + ROW('2017-18', "t0"."2017-18"), + ROW('2018-19', "t0"."2018-19"), + ROW('2019-20', "t0"."2019-20") + ] AS STRUCT("years" TEXT, "degrees" BIGINT)[]) ) AS "__pivoted__" FROM "humanities" AS "t0" ) AS "t1" @@ -73,7 +73,7 @@ FROM ( * FROM "t5" AS "t6" WHERE - "t6"."diff" < CAST(0 AS TINYINT) + "t6"."diff" < 0 ORDER BY "t6"."diff" ASC LIMIT 10 diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_and_non_agg_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_and_non_agg_filter/out.sql index c7e15fae0c04..3acb7c032328 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_and_non_agg_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_and_non_agg_filter/out.sql @@ -2,7 +2,7 @@ SELECT * FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 AND "t0"."a" = ( SELECT MAX("t1"."a") AS "Max(a)" @@ -11,7 +11,7 @@ WHERE * FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 ) AS "t1" ) AND "t0"."b" = 'a' \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter/out.sql index 6ccba780d897..51e1c5727ef4 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter/out.sql @@ -1,18 +1,18 @@ SELECT "t0"."a", - "t0"."b" * CAST(2 AS TINYINT) AS "b2" + "t0"."b" * 2 AS "b2" FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 AND "t0"."a" = ( SELECT MAX("t1"."a") AS "Max(a)" FROM ( SELECT "t0"."a", - "t0"."b" * CAST(2 AS TINYINT) AS "b2" + "t0"."b" * 2 AS "b2" FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 ) AS "t1" ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter_with_alias/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter_with_alias/out.sql index 6ccba780d897..51e1c5727ef4 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter_with_alias/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_agg_filter_with_alias/out.sql @@ -1,18 +1,18 @@ SELECT "t0"."a", - "t0"."b" * CAST(2 AS TINYINT) AS "b2" + "t0"."b" * 2 AS "b2" FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 AND "t0"."a" = ( SELECT MAX("t1"."a") AS "Max(a)" FROM ( SELECT "t0"."a", - "t0"."b" * CAST(2 AS TINYINT) AS "b2" + "t0"."b" * 2 AS "b2" FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 ) AS "t1" ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_default_name/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_default_name/out.sql index 2e86d41c48ea..0dbd10aa6d0d 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_default_name/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_default_name/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."int_col" + CAST(4 AS TINYINT) AS "Add(int_col, 4)" + "t0"."int_col" + 4 AS "Add(int_col, 4)" FROM "int_col_table" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_retains_name/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_retains_name/out.sql index 26c4292ded48..9e66a962a135 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_retains_name/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_column_expr_retains_name/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."int_col" + CAST(4 AS TINYINT) AS "foo" + "t0"."int_col" + 4 AS "foo" FROM "int_col_table" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_count_distinct/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_count_distinct/out.sql index 13c843a38296..bf86b6125d34 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_count_distinct/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_count_distinct/out.sql @@ -6,7 +6,7 @@ FROM ( * FROM "functional_alltypes" AS "t0" WHERE - "t0"."bigint_col" > CAST(0 AS TINYINT) + "t0"."bigint_col" > 0 ) AS "t1" GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_difference_project_column/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_difference_project_column/out.sql index 3ac830ba92b3..f1172d9a1854 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_difference_project_column/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_difference_project_column/out.sql @@ -9,7 +9,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" EXCEPT SELECT @@ -20,6 +20,6 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" ) AS "t3" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_having_from_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_having_from_filter/out.sql index 1b919c1dd31b..7ad9dd706613 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_having_from_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_having_from_filter/out.sql @@ -17,4 +17,4 @@ FROM ( 1 ) AS "t2" WHERE - "t2"."Max(a)" = CAST(2 AS TINYINT) \ No newline at end of file + "t2"."Max(a)" = 2 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_having_size/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_having_size/out.sql index 3d6ac367d06e..cb0f2cfed817 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_having_size/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_having_size/out.sql @@ -11,4 +11,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."Max(double_col)" = CAST(1 AS TINYINT) \ No newline at end of file + "t1"."Max(double_col)" = 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_intersect_project_column/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_intersect_project_column/out.sql index 07c91b224cd0..419dc415b6d7 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_intersect_project_column/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_intersect_project_column/out.sql @@ -9,7 +9,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" INTERSECT SELECT @@ -20,6 +20,6 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" ) AS "t3" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_pushdown_with_or/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_pushdown_with_or/out.sql index 584107031b07..a09ea9f3019d 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_pushdown_with_or/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_pushdown_with_or/out.sql @@ -2,15 +2,14 @@ SELECT * FROM "functional_alltypes" AS "t0" WHERE - "t0"."double_col" > CAST(3.14 AS DOUBLE) + "t0"."double_col" > 3.14 AND CONTAINS("t0"."string_col", 'foo') AND ( ( ( - "t0"."int_col" - CAST(1 AS TINYINT) - ) = CAST(0 AS TINYINT) - ) - OR ( - "t0"."float_col" <= CAST(1.34 AS DOUBLE) + "t0"."int_col" - 1 + ) = 0 + ) OR ( + "t0"."float_col" <= 1.34 ) ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_simple_agg_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_simple_agg_filter/out.sql index 82648fc1e594..76740abc6150 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_simple_agg_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_simple_agg_filter/out.sql @@ -2,7 +2,7 @@ SELECT * FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 AND "t0"."a" = ( SELECT MAX("t1"."a") AS "Max(a)" @@ -11,6 +11,6 @@ WHERE * FROM "my_table" AS "t0" WHERE - "t0"."a" < CAST(100 AS TINYINT) + "t0"."a" < 100 ) AS "t1" ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_difference/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_difference/out.sql index b5bc844f70a8..dd7dee12555a 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_difference/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_difference/out.sql @@ -6,7 +6,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" EXCEPT SELECT @@ -17,5 +17,5 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql index f632f0f30059..5ba2964ed643 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql @@ -16,4 +16,4 @@ FROM ( ON "t4"."b" = "t2"."b" ) AS "t5" WHERE - "t5"."a" < CAST(1.0 AS DOUBLE) \ No newline at end of file + "t5"."a" < 1.0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_intersect/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_intersect/out.sql index 8ffb71b3b102..ee1839925340 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_intersect/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_intersect/out.sql @@ -6,7 +6,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" INTERSECT SELECT @@ -17,5 +17,5 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_union/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_union/out.sql index fbda8f8cffb8..2d956232cd45 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_union/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_union/out.sql @@ -6,7 +6,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" UNION SELECT @@ -17,5 +17,5 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_union_project_column/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_union_project_column/out.sql index 4efd94517079..82a047ee7582 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_union_project_column/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_union_project_column/out.sql @@ -9,7 +9,7 @@ FROM ( CAST("t0"."float_col" AS DOUBLE) AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" > CAST(0 AS TINYINT) + "t0"."int_col" > 0 ) AS "t1" UNION ALL SELECT @@ -20,6 +20,6 @@ FROM ( "t0"."double_col" AS "value" FROM "functional_alltypes" AS "t0" WHERE - "t0"."int_col" <= CAST(0 AS TINYINT) + "t0"."int_col" <= 0 ) AS "t2" ) AS "t3" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/explicit.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/explicit.sql index ffdf2ce8e3d1..863f04b99f8e 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/explicit.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/explicit.sql @@ -9,4 +9,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."total" > CAST(10 AS TINYINT) \ No newline at end of file + "t1"."total" > 10 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/inline.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/inline.sql index 1ae3730bd70f..9a693f5bcc6c 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/inline.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_having/inline.sql @@ -11,4 +11,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."CountStar(star1)" > CAST(100 AS TINYINT) \ No newline at end of file + "t1"."CountStar(star1)" > 100 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered.sql index 808c9de5c6fc..28b406daae35 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered.sql @@ -17,7 +17,7 @@ FROM ( "t0"."a" + "t0"."b" AS "foo" FROM "alltypes" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) AND "t0"."g" = 'bar' + "t0"."f" > 0 AND "t0"."g" = 'bar' ) AS "t1" GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered2.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered2.sql index 84b289f68fc3..899b77b38784 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered2.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/agg_filtered2.sql @@ -17,9 +17,9 @@ FROM ( "t0"."a" + "t0"."b" AS "foo" FROM "alltypes" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) AND ( + "t0"."f" > 0 AND ( "t0"."a" + "t0"."b" - ) < CAST(10 AS TINYINT) + ) < 10 ) AS "t1" GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/filtered.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/filtered.sql index 802747adcc8c..b7296f6b019d 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/filtered.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/filtered.sql @@ -13,4 +13,4 @@ SELECT "t0"."a" + "t0"."b" AS "foo" FROM "alltypes" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) AND "t0"."g" = 'bar' \ No newline at end of file + "t0"."f" > 0 AND "t0"."g" = 'bar' \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/proj.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/proj.sql index f41268dc8f89..cfd111ac5f76 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/proj.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_subquery/proj.sql @@ -13,4 +13,4 @@ SELECT "t0"."a" + "t0"."b" AS "foo" FROM "alltypes" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) \ No newline at end of file + "t0"."f" > 0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_bool_bool/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_bool_bool/out.sql index 714bb6c5b6c0..454d1a111c70 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_bool_bool/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_bool_bool/out.sql @@ -3,5 +3,5 @@ SELECT FROM "airlines" AS "t0" WHERE ( - CAST("t0"."dest" AS BIGINT) = CAST(0 AS TINYINT) + CAST("t0"."dest" AS BIGINT) = 0 ) = TRUE \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_chain_limit_doesnt_collapse/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_chain_limit_doesnt_collapse/result.sql index 976b5da5d1c8..7cf9d2dc9409 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_chain_limit_doesnt_collapse/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_chain_limit_doesnt_collapse/result.sql @@ -18,7 +18,7 @@ FROM ( LIMIT 5 OFFSET ( SELECT - COUNT(*) + CAST(-5 AS TINYINT) + COUNT(*) + -5 FROM ( SELECT * diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_complex_union/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_complex_union/result.sql index ba179f3abdfa..e081900f900b 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_complex_union/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_complex_union/result.sql @@ -2,7 +2,7 @@ SELECT * FROM ( SELECT - CAST("t0"."diag" + CAST(1 AS TINYINT) AS INT) AS "diag", + CAST("t0"."diag" + 1 AS INT) AS "diag", "t0"."status" FROM "aids2_one" AS "t0" ) AS "t2" @@ -11,7 +11,7 @@ SELECT * FROM ( SELECT - CAST("t1"."diag" + CAST(1 AS TINYINT) AS INT) AS "diag", + CAST("t1"."diag" + 1 AS INT) AS "diag", "t1"."status" FROM "aids2_two" AS "t1" ) AS "t3" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_subquery_derived_reduction/expr4.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_subquery_derived_reduction/expr4.sql index bbfa6b1b8503..6622ef4c9843 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_subquery_derived_reduction/expr4.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_subquery_derived_reduction/expr4.sql @@ -15,5 +15,5 @@ WHERE "t0"."foo_id" = 'foo' ) AS "t1" ) - ) + CAST(1 AS TINYINT) + ) + 1 ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project.sql index 79d8cee79e9d..64e25182142b 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project.sql @@ -3,5 +3,5 @@ SELECT "t0"."bar", "t0"."value", "t0"."foo" + "t0"."bar" AS "baz", - "t0"."foo" * CAST(2 AS TINYINT) AS "qux" + "t0"."foo" * 2 AS "qux" FROM "tbl" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project_filter.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project_filter.sql index d91e991fa6d7..d685e6b325a5 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project_filter.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_fuse_projections/project_filter.sql @@ -3,7 +3,7 @@ SELECT "t0"."bar", "t0"."value", "t0"."foo" + "t0"."bar" AS "baz", - "t0"."foo" * CAST(2 AS TINYINT) AS "qux" + "t0"."foo" * 2 AS "qux" FROM "tbl" AS "t0" WHERE - "t0"."value" > CAST(0 AS TINYINT) \ No newline at end of file + "t0"."value" > 0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown/result.sql index 4d92015cc1bd..759b6c284826 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown/result.sql @@ -1,7 +1,7 @@ SELECT - "t0"."x" + CAST(1 AS TINYINT) AS "x" + "t0"."x" + 1 AS "x" FROM "t" AS "t0" WHERE ( - "t0"."x" + CAST(1 AS TINYINT) - ) > CAST(1 AS TINYINT) \ No newline at end of file + "t0"."x" + 1 + ) > 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown_with_literal/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown_with_literal/result.sql index 11159dee0f92..69bca29bf719 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown_with_literal/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_incorrect_predicate_pushdown_with_literal/result.sql @@ -1,5 +1,5 @@ SELECT - CAST(1 AS TINYINT) AS "a" + 1 AS "a" FROM "t" AS "t0" WHERE - CAST(1 AS TINYINT) > CAST(1 AS TINYINT) \ No newline at end of file + 1 > 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_filtered_tables_no_pushdown/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_filtered_tables_no_pushdown/out.sql index 3e327c3d541c..5d05f5ce6859 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_filtered_tables_no_pushdown/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_filtered_tables_no_pushdown/out.sql @@ -6,18 +6,14 @@ FROM ( * FROM "a" AS "t0" WHERE - "t0"."year" = CAST(2016 AS SMALLINT) - AND "t0"."month" = CAST(2 AS TINYINT) - AND "t0"."day" = CAST(29 AS TINYINT) + "t0"."year" = 2016 AND "t0"."month" = 2 AND "t0"."day" = 29 ) AS "t4" LEFT OUTER JOIN ( SELECT * FROM "b" AS "t1" WHERE - "t1"."year" = CAST(2016 AS SMALLINT) - AND "t1"."month" = CAST(2 AS TINYINT) - AND "t1"."day" = CAST(29 AS TINYINT) + "t1"."year" = 2016 AND "t1"."month" = 2 AND "t1"."day" = 29 ) AS "t5" ON "t4"."year" = "t5"."year" AND "t4"."month" = "t5"."month" diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql index 169e1d3250ad..c16180e55b6f 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql @@ -8,13 +8,13 @@ FROM ( * FROM "foo" AS "t0" WHERE - "t0"."id" < CAST(2 AS TINYINT) + "t0"."id" < 2 ) AS "t4" LEFT OUTER JOIN ( SELECT * FROM "bar" AS "t1" WHERE - "t1"."id" < CAST(3 AS TINYINT) + "t1"."id" < 3 ) AS "t5" ON "t4"."id" = "t5"."id" AND "t4"."desc" = "t5"."desc" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_projection_filter_fuse/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_projection_filter_fuse/out.sql index 4c7c35d3c442..f6ebd6fa084e 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_projection_filter_fuse/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_projection_filter_fuse/out.sql @@ -4,4 +4,4 @@ SELECT "t0"."c" FROM "foo" AS "t0" WHERE - "t0"."a" > CAST(0 AS TINYINT) \ No newline at end of file + "t0"."a" > 0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/filter_then_limit/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/filter_then_limit/out.sql index d41cd77ec97a..3280ba7e90ea 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/filter_then_limit/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/filter_then_limit/out.sql @@ -2,5 +2,5 @@ SELECT * FROM "star1" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) + "t0"."f" > 0 LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/limit_then_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/limit_then_filter/out.sql index f3d300bc1052..1e4eb526f47c 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/limit_then_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_select_sql/limit_then_filter/out.sql @@ -7,4 +7,4 @@ FROM ( LIMIT 10 ) AS "t1" WHERE - "t1"."f" > CAST(0 AS TINYINT) \ No newline at end of file + "t1"."f" > 0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql index 18f3ee847814..264452b978ba 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql @@ -28,5 +28,5 @@ SELECT FROM "t9" AS "t11" INNER JOIN "t9" AS "t12" ON "t11"."year" = ( - "t12"."year" - CAST(1 AS TINYINT) + "t12"."year" - 1 ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql index 07a7d0197889..7517bb3173bb 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql @@ -12,4 +12,4 @@ FROM ( ON "t2"."foo_id" = "t3"."foo_id" ) AS "t4" WHERE - "t4"."diff" > CAST(1 AS TINYINT) \ No newline at end of file + "t4"."diff" > 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_between/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_between/out.sql index 4a879e93d25c..987e13760590 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_between/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_between/out.sql @@ -2,5 +2,4 @@ SELECT * FROM "alltypes" AS "t0" WHERE - "t0"."a" > CAST(0 AS TINYINT) - AND "t0"."f" BETWEEN CAST(0 AS TINYINT) AND CAST(1 AS TINYINT) \ No newline at end of file + "t0"."a" > 0 AND "t0"."f" BETWEEN 0 AND 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql index bcceb927d496..c8f61dcdb75e 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql @@ -13,4 +13,4 @@ FROM ( ON "t2"."foo_id" = "t3"."foo_id" ) AS "t4" WHERE - "t4"."f" > CAST(0 AS TINYINT) AND "t4"."value3" < CAST(1000 AS SMALLINT) \ No newline at end of file + "t4"."f" > 0 AND "t4"."value3" < 1000 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_count/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_count/out.sql index 1ae3730bd70f..9a693f5bcc6c 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_count/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_count/out.sql @@ -11,4 +11,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."CountStar(star1)" > CAST(100 AS TINYINT) \ No newline at end of file + "t1"."CountStar(star1)" > 100 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_sum/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_sum/out.sql index ffdf2ce8e3d1..863f04b99f8e 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_sum/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_aggregate/having_sum/out.sql @@ -9,4 +9,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."total" > CAST(10 AS TINYINT) \ No newline at end of file + "t1"."total" > 10 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_between/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_between/out.sql index af7f94c32409..f70c8bb7dab1 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_between/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_between/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" BETWEEN CAST(5 AS TINYINT) AND CAST(10 AS TINYINT) AS "tmp" + "t0"."double_col" BETWEEN 5 AND 10 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/and/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/and/out.sql index a288a6c325f4..771802d940ba 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/and/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/and/out.sql @@ -1,8 +1,7 @@ SELECT ( - "t0"."double_col" > CAST(0 AS TINYINT) - ) - AND ( - "t0"."double_col" < CAST(5 AS TINYINT) + "t0"."double_col" > 0 + ) AND ( + "t0"."double_col" < 5 ) AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/or/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/or/out.sql index 8e7e85a06eef..03bd1d37ac08 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/or/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_boolean_conjunction/or/out.sql @@ -1,8 +1,7 @@ SELECT ( - "t0"."double_col" < CAST(0 AS TINYINT) - ) - OR ( - "t0"."double_col" > CAST(5 AS TINYINT) + "t0"."double_col" < 0 + ) OR ( + "t0"."double_col" > 5 ) AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_coalesce/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_coalesce/out.sql index 978ba8ae9e67..e48a52e1fb5d 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_coalesce/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_coalesce/out.sql @@ -1,10 +1,6 @@ SELECT COALESCE( - CASE - WHEN "t0"."double_col" > CAST(30 AS TINYINT) - THEN "t0"."double_col" - ELSE NULL - END, + CASE WHEN "t0"."double_col" > 30 THEN "t0"."double_col" ELSE NULL END, NULL, "t0"."float_col" ) AS "tmp" diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/eq/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/eq/out.sql index a21e83164c3e..1274e613c4dc 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/eq/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/eq/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" = CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" = 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ge/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ge/out.sql index 3dd5fffe7afe..4d830d4d16fe 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ge/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ge/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" >= CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" >= 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/gt/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/gt/out.sql index d1b071460150..73eaadebf08b 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/gt/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/gt/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" > CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" > 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/le/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/le/out.sql index b09e7d427b7a..d84e082478bb 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/le/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/le/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" <= CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" <= 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/lt/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/lt/out.sql index 44e538076f9d..4e85237c6838 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/lt/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/lt/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" < CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" < 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ne/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ne/out.sql index e9b9c60dcac8..ab3c6c8a0649 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ne/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_comparisons/ne/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" <> CAST(5 AS TINYINT) AS "tmp" + "t0"."double_col" <> 5 AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_double_order_by_different_expression/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_double_order_by_different_expression/out.sql index 6e617305ef68..8294697e748b 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_double_order_by_different_expression/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_double_order_by_different_expression/out.sql @@ -3,6 +3,6 @@ SELECT FROM "t" AS "t0" ORDER BY "t0"."b" ASC, - "t0"."a" + CAST(1 AS TINYINT) DESC, + "t0"."a" + 1 DESC, "t0"."a" ASC, "t0"."c" ASC \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_filter_group_by_agg_with_same_name/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_filter_group_by_agg_with_same_name/out.sql index 9ece266e46da..1abac914f882 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_filter_group_by_agg_with_same_name/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_filter_group_by_agg_with_same_name/out.sql @@ -9,4 +9,4 @@ FROM ( 1 ) AS "t1" WHERE - "t1"."bigint_col" = CAST(60 AS TINYINT) \ No newline at end of file + "t1"."bigint_col" = 60 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_limit_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_limit_filter/out.sql index d41cd77ec97a..3280ba7e90ea 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_limit_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_limit_filter/out.sql @@ -2,5 +2,5 @@ SELECT * FROM "star1" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) + "t0"."f" > 0 LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_limit_subquery/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_limit_subquery/out.sql index f3d300bc1052..1e4eb526f47c 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_limit_subquery/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_limit_subquery/out.sql @@ -7,4 +7,4 @@ FROM ( LIMIT 10 ) AS "t1" WHERE - "t1"."f" > CAST(0 AS TINYINT) \ No newline at end of file + "t1"."f" > 0 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql index 570d4d1eeca6..943e9674fe9c 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql @@ -17,6 +17,6 @@ FROM ( ON "t4"."foo_id" = "t2"."foo_id" ) AS "t5" WHERE - "t5"."total" > CAST(100 AS TINYINT) + "t5"."total" > 100 ORDER BY "t5"."total" DESC \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_mutate_filter_join_no_cross_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_mutate_filter_join_no_cross_join/out.sql index 293c1b4efd77..bb97654b9b14 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_mutate_filter_join_no_cross_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_mutate_filter_join_no_cross_join/out.sql @@ -2,4 +2,4 @@ SELECT "t0"."person_id" FROM "person" AS "t0" WHERE - CAST(400 AS SMALLINT) <= CAST(40 AS TINYINT) \ No newline at end of file + 400 <= 40 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_named_expr/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_named_expr/out.sql index 90abf9858067..6fa92068d826 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_named_expr/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_named_expr/out.sql @@ -1,3 +1,3 @@ SELECT - "t0"."double_col" * CAST(2 AS TINYINT) AS "foo" + "t0"."double_col" * 2 AS "foo" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_negate/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_negate/out.sql index e248e7ce636e..96c5eb8ab355 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_negate/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_negate/out.sql @@ -1,5 +1,5 @@ SELECT NOT ( - "t0"."double_col" > CAST(0 AS TINYINT) + "t0"."double_col" > 0 ) AS "tmp" FROM "functional_alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql index abef0d37077e..9139f2ed68a5 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql @@ -3,7 +3,7 @@ SELECT FROM ( SELECT "t5"."ancestor_node_sort_order", - CAST(1 AS TINYINT) AS "n" + 1 AS "n" FROM ( SELECT "t2"."product_id", @@ -19,13 +19,9 @@ FROM ( "t1"."ancestor_level_number", "t1"."ancestor_node_sort_order", "t1"."descendant_node_natural_key", - LPAD( - '-', - ( - "t1"."ancestor_level_number" - CAST(1 AS TINYINT) - ) * CAST(7 AS TINYINT), - '-' - ) || "t1"."ancestor_level_name" AS "product_level_name" + LPAD('-', ( + "t1"."ancestor_level_number" - 1 + ) * 7, '-') || "t1"."ancestor_level_name" AS "product_level_name" FROM "products" AS "t1" ) AS "t4" ON "t2"."product_id" = "t4"."descendant_node_natural_key" diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_order_by_expr/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_order_by_expr/out.sql index a91bb75063b0..a2cc75df86ac 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_order_by_expr/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_order_by_expr/out.sql @@ -2,6 +2,6 @@ SELECT * FROM "t" AS "t0" WHERE - "t0"."a" = CAST(1 AS TINYINT) + "t0"."a" = 1 ORDER BY "t0"."b" || 'a' ASC \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_searched_case/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_searched_case/out.sql index 1bbe6d29ebd7..49029740c04f 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_searched_case/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_searched_case/out.sql @@ -1,9 +1,9 @@ SELECT CASE - WHEN "t0"."f" > CAST(0 AS TINYINT) - THEN "t0"."d" * CAST(2 AS TINYINT) - WHEN "t0"."c" < CAST(0 AS TINYINT) - THEN "t0"."a" * CAST(2 AS TINYINT) + WHEN "t0"."f" > 0 + THEN "t0"."d" * 2 + WHEN "t0"."c" < 0 + THEN "t0"."a" * 2 ELSE CAST(NULL AS BIGINT) END AS "tmp" FROM "alltypes" AS "t0" \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_where_simple_comparisons/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_where_simple_comparisons/out.sql index df9a35f24711..f1e634a51452 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_where_simple_comparisons/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_where_simple_comparisons/out.sql @@ -2,6 +2,6 @@ SELECT * FROM "star1" AS "t0" WHERE - "t0"."f" > CAST(0 AS TINYINT) AND "t0"."c" < ( - "t0"."f" * CAST(2 AS TINYINT) + "t0"."f" > 0 AND "t0"."c" < ( + "t0"."f" * 2 ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/test_sql.py b/ibis/backends/tests/sql/test_sql.py index 6f1d116374e9..991cd02b7f3e 100644 --- a/ibis/backends/tests/sql/test_sql.py +++ b/ibis/backends/tests/sql/test_sql.py @@ -523,9 +523,6 @@ def test_double_order_by(snapshot): t = ibis.table(dict(a="int", b="string"), name="t") # t.b DESC, t.a ASC expr = t.order_by(t.a).order_by(t.b.desc()) - sql = to_sql(expr, pretty=False) - expected = '"t0"."b" DESC, "t0"."a" ASC' - assert expected in sql snapshot.assert_match(to_sql(expr), "out.sql") @@ -533,29 +530,18 @@ def test_double_order_by_same_column(snapshot): t = ibis.table(dict(a="int", b="string", c="float"), name="t") # t.b ASC, t.a DESC, t.c ASC expr = t.order_by(t.a, t.c).order_by(t.b.asc(), t.a.desc()) - sql = to_sql(expr, pretty=False) - expected = '"t0"."b" ASC, "t0"."a" DESC, "t0"."c" ASC' - assert expected in sql snapshot.assert_match(to_sql(expr), "out.sql") def test_double_order_by_deferred(snapshot): t = ibis.table(dict(a="int", b="string", c="float"), name="t") expr = t.order_by(t.a, t.c).order_by(t.b.asc(), _.a.desc()) - sql = to_sql(expr, pretty=False) - expected = '"t0"."b" ASC, "t0"."a" DESC, "t0"."c" ASC' - assert expected in sql snapshot.assert_match(to_sql(expr), "out.sql") def test_double_order_by_different_expression(snapshot): t = ibis.table(dict(a="int", b="string", c="float"), name="t") expr = t.order_by(t.a, t.c).order_by(t.b.asc(), (t.a + 1).desc()) - sql = to_sql(expr, pretty=False) - expected = ( - '"t0"."b" ASC, "t0"."a" + CAST(1 AS TINYINT) DESC, "t0"."a" ASC, "t0"."c" ASC' - ) - assert expected in sql snapshot.assert_match(to_sql(expr), "out.sql") diff --git a/ibis/backends/tests/test_numeric.py b/ibis/backends/tests/test_numeric.py index 2019b08c406d..89f33217b31d 100644 --- a/ibis/backends/tests/test_numeric.py +++ b/ibis/backends/tests/test_numeric.py @@ -49,7 +49,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "TINYINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -65,7 +65,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "SMALLINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -97,7 +97,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "BIGINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -113,7 +113,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "UTINYINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -129,7 +129,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "USMALLINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -145,7 +145,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "UINTEGER", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -161,7 +161,7 @@ "snowflake": "INTEGER", "sqlite": "integer", "trino": "integer", - "duckdb": "UBIGINT", + "duckdb": "INTEGER", "postgres": "integer", "risingwave": "integer", "flink": "INT NOT NULL", @@ -177,7 +177,7 @@ "snowflake": "INTEGER", "sqlite": "real", "trino": "real", - "duckdb": "FLOAT", + "duckdb": "DECIMAL(2,1)", "postgres": "numeric", "risingwave": "numeric", "flink": "DECIMAL(2, 1) NOT NULL", @@ -200,7 +200,7 @@ "snowflake": "INTEGER", "sqlite": "real", "trino": "real", - "duckdb": "FLOAT", + "duckdb": "DECIMAL(2,1)", "postgres": "numeric", "risingwave": "numeric", "flink": "DECIMAL(2, 1) NOT NULL", @@ -216,7 +216,7 @@ "snowflake": "INTEGER", "sqlite": "real", "trino": "double", - "duckdb": "DOUBLE", + "duckdb": "DECIMAL(2,1)", "postgres": "numeric", "risingwave": "numeric", "flink": "DECIMAL(2, 1) NOT NULL", diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py index 0aade5f88686..d9b087fbd4f1 100644 --- a/ibis/expr/types/generic.py +++ b/ibis/expr/types/generic.py @@ -353,7 +353,7 @@ def typeof(self) -> ir.StringValue: Different backends have different names for their native types >>> ibis.duckdb.connect().execute(ibis.literal(5.4).typeof()) - 'DOUBLE' + 'DECIMAL(2,1)' >>> ibis.sqlite.connect().execute(ibis.literal(5.4).typeof()) 'real' """