@@ -76,17 +76,38 @@ fn calculate_union_binary(
7676 } )
7777 . collect :: < Vec < _ > > ( ) ;
7878
79+ // TEMP HACK WORKAROUND
80+ // Revert code from https://github.com/apache/datafusion/pull/12562
81+ // Context: https://github.com/apache/datafusion/issues/13748
82+ // Context: https://github.com/influxdata/influxdb_iox/issues/13038
83+
7984 // Next, calculate valid orderings for the union by searching for prefixes
8085 // in both sides.
81- let mut orderings = UnionEquivalentOrderingBuilder :: new ( ) ;
82- orderings. add_satisfied_orderings ( lhs. normalized_oeq_class ( ) , lhs. constants ( ) , & rhs) ;
83- orderings. add_satisfied_orderings ( rhs. normalized_oeq_class ( ) , rhs. constants ( ) , & lhs) ;
84- let orderings = orderings. build ( ) ;
85-
86- let mut eq_properties =
87- EquivalenceProperties :: new ( lhs. schema ) . with_constants ( constants) ;
88-
86+ let mut orderings = vec ! [ ] ;
87+ for mut ordering in lhs. normalized_oeq_class ( ) . into_iter ( ) {
88+ // Progressively shorten the ordering to search for a satisfied prefix:
89+ while !rhs. ordering_satisfy ( & ordering) {
90+ ordering. pop ( ) ;
91+ }
92+ // There is a non-trivial satisfied prefix, add it as a valid ordering:
93+ if !ordering. is_empty ( ) {
94+ orderings. push ( ordering) ;
95+ }
96+ }
97+ for mut ordering in rhs. normalized_oeq_class ( ) . into_iter ( ) {
98+ // Progressively shorten the ordering to search for a satisfied prefix:
99+ while !lhs. ordering_satisfy ( & ordering) {
100+ ordering. pop ( ) ;
101+ }
102+ // There is a non-trivial satisfied prefix, add it as a valid ordering:
103+ if !ordering. is_empty ( ) {
104+ orderings. push ( ordering) ;
105+ }
106+ }
107+ let mut eq_properties = EquivalenceProperties :: new ( lhs. schema ) ;
108+ eq_properties. constants = constants;
89109 eq_properties. add_new_orderings ( orderings) ;
110+
90111 Ok ( eq_properties)
91112}
92113
@@ -132,6 +153,7 @@ struct UnionEquivalentOrderingBuilder {
132153 orderings : Vec < LexOrdering > ,
133154}
134155
156+ #[ expect( unused) ]
135157impl UnionEquivalentOrderingBuilder {
136158 fn new ( ) -> Self {
137159 Self { orderings : vec ! [ ] }
@@ -509,6 +531,7 @@ mod tests {
509531 }
510532
511533 #[ test]
534+ #[ ignore = "InfluxData patch: chore: skip order calculation / exponential planning" ]
512535 fn test_union_equivalence_properties_constants_fill_gaps ( ) {
513536 let schema = create_test_schema ( ) . unwrap ( ) ;
514537 UnionEquivalenceTest :: new ( & schema)
@@ -584,6 +607,7 @@ mod tests {
584607 }
585608
586609 #[ test]
610+ #[ ignore = "InfluxData patch: chore: skip order calculation / exponential planning" ]
587611 fn test_union_equivalence_properties_constants_fill_gaps_non_symmetric ( ) {
588612 let schema = create_test_schema ( ) . unwrap ( ) ;
589613 UnionEquivalenceTest :: new ( & schema)
@@ -611,6 +635,7 @@ mod tests {
611635 }
612636
613637 #[ test]
638+ #[ ignore = "InfluxData patch: chore: skip order calculation / exponential planning" ]
614639 fn test_union_equivalence_properties_constants_gap_fill_symmetric ( ) {
615640 let schema = create_test_schema ( ) . unwrap ( ) ;
616641 UnionEquivalenceTest :: new ( & schema)
@@ -662,6 +687,7 @@ mod tests {
662687 }
663688
664689 #[ test]
690+ #[ ignore = "InfluxData patch: chore: skip order calculation / exponential planning" ]
665691 fn test_union_equivalence_properties_constants_middle_desc ( ) {
666692 let schema = create_test_schema ( ) . unwrap ( ) ;
667693 UnionEquivalenceTest :: new ( & schema)
0 commit comments