@@ -742,7 +742,8 @@ TEST(Expression, BindWithDecimalDivision) {
742742TEST (Expression, BindWithImplicitCasts) {
743743 auto exciting_schema = schema (
744744 {field (" i64" , int64 ()), field (" dec128_3_2" , decimal128 (3 , 2 )),
745- field (" dec128_5_3" , decimal128 (5 , 3 )), field (" dec256_3_2" , decimal256 (3 , 2 )),
745+ field (" dec128_4_2" , decimal128 (4 , 2 )), field (" dec128_5_3" , decimal128 (5 , 3 )),
746+ field (" dec256_3_2" , decimal256 (3 , 2 )), field (" dec256_4_2" , decimal256 (4 , 2 )),
746747 field (" dec256_5_3" , decimal256 (5 , 3 ))});
747748 for (auto cmp : {equal, not_equal, less, less_equal, greater, greater_equal}) {
748749 // cast arguments to common numeric type
@@ -813,7 +814,25 @@ TEST(Expression, BindWithImplicitCasts) {
813814 cmp (cast (field_ref (" i64" ), decimal128 (21 , 2 )), field_ref (" dec128_3_2" )),
814815 /* bound_out=*/ nullptr , *exciting_schema);
815816
816- // decimal128 decimal256 with different scales
817+ // decimal decimal with different widths different precisions but same scale
818+ ExpectBindsTo (
819+ cmp (field_ref (" dec128_3_2" ), field_ref (" dec256_4_2" )),
820+ cmp (cast (field_ref (" dec128_3_2" ), decimal256 (3 , 2 )), field_ref (" dec256_4_2" )),
821+ /* bound_out=*/ nullptr , *exciting_schema);
822+ ExpectBindsTo (
823+ cmp (field_ref (" dec256_4_2" ), field_ref (" dec128_3_2" )),
824+ cmp (field_ref (" dec256_4_2" ), cast (field_ref (" dec128_3_2" ), decimal256 (3 , 2 ))),
825+ /* bound_out=*/ nullptr , *exciting_schema);
826+ ExpectBindsTo (
827+ cmp (field_ref (" dec128_4_2" ), field_ref (" dec256_3_2" )),
828+ cmp (cast (field_ref (" dec128_4_2" ), decimal256 (4 , 2 )), field_ref (" dec256_3_2" )),
829+ /* bound_out=*/ nullptr , *exciting_schema);
830+ ExpectBindsTo (
831+ cmp (field_ref (" dec256_3_2" ), field_ref (" dec128_4_2" )),
832+ cmp (field_ref (" dec256_3_2" ), cast (field_ref (" dec128_4_2" ), decimal256 (4 , 2 ))),
833+ /* bound_out=*/ nullptr , *exciting_schema);
834+
835+ // decimal decimal with different widths different scales
817836 ExpectBindsTo (
818837 cmp (field_ref (" dec128_3_2" ), field_ref (" dec256_5_3" )),
819838 cmp (cast (field_ref (" dec128_3_2" ), decimal256 (4 , 3 )), field_ref (" dec256_5_3" )),
@@ -831,6 +850,20 @@ TEST(Expression, BindWithImplicitCasts) {
831850 cast (field_ref (" dec128_5_3" ), decimal256 (5 , 3 ))),
832851 /* bound_out=*/ nullptr , *exciting_schema);
833852
853+ // decimal decimal with same width same precision but different scales (no cast)
854+ ExpectBindsTo (cmp (field_ref (" dec128_3_2" ), field_ref (" dec128_4_2" )),
855+ cmp (field_ref (" dec128_3_2" ), field_ref (" dec128_4_2" )),
856+ /* bound_out=*/ nullptr , *exciting_schema);
857+ ExpectBindsTo (cmp (field_ref (" dec128_4_2" ), field_ref (" dec128_3_2" )),
858+ cmp (field_ref (" dec128_4_2" ), field_ref (" dec128_3_2" )),
859+ /* bound_out=*/ nullptr , *exciting_schema);
860+ ExpectBindsTo (cmp (field_ref (" dec256_3_2" ), field_ref (" dec256_4_2" )),
861+ cmp (field_ref (" dec256_3_2" ), field_ref (" dec256_4_2" )),
862+ /* bound_out=*/ nullptr , *exciting_schema);
863+ ExpectBindsTo (cmp (field_ref (" dec256_4_2" ), field_ref (" dec256_3_2" )),
864+ cmp (field_ref (" dec256_4_2" ), field_ref (" dec256_3_2" )),
865+ /* bound_out=*/ nullptr , *exciting_schema);
866+
834867 // decimal decimal with same width but different scales
835868 ExpectBindsTo (
836869 cmp (field_ref (" dec128_3_2" ), field_ref (" dec128_5_3" )),
@@ -840,6 +873,14 @@ TEST(Expression, BindWithImplicitCasts) {
840873 cmp (field_ref (" dec128_5_3" ), field_ref (" dec128_3_2" )),
841874 cmp (field_ref (" dec128_5_3" ), cast (field_ref (" dec128_3_2" ), decimal128 (4 , 3 ))),
842875 /* bound_out=*/ nullptr , *exciting_schema);
876+ ExpectBindsTo (
877+ cmp (field_ref (" dec256_3_2" ), field_ref (" dec256_5_3" )),
878+ cmp (cast (field_ref (" dec256_3_2" ), decimal256 (4 , 3 )), field_ref (" dec256_5_3" )),
879+ /* bound_out=*/ nullptr , *exciting_schema);
880+ ExpectBindsTo (
881+ cmp (field_ref (" dec256_5_3" ), field_ref (" dec256_3_2" )),
882+ cmp (field_ref (" dec256_5_3" ), cast (field_ref (" dec256_3_2" ), decimal256 (4 , 3 ))),
883+ /* bound_out=*/ nullptr , *exciting_schema);
843884 }
844885
845886 compute::SetLookupOptions in_a{ArrayFromJSON (utf8 (), R"( ["a"])" )};
0 commit comments