1+ use crate :: common:: util;
12use crate :: common:: { InclusionConfig , Result , fuzzer_err} ;
3+ use crate :: oracle:: oracle_common;
24use crate :: oracle:: { Oracle , QueryContext , QueryExecutionResult } ;
35use crate :: query_generator:: stmt_select_def:: SelectStatementBuilder ;
46use std:: sync:: Arc ;
@@ -92,7 +94,7 @@ impl Oracle for TlpHavingOracle {
9294 return Ok ( ( ) ) ;
9395 }
9496
95- crate :: oracle :: tlp_shared :: validate_value_equivalence ( results, "TLP-HAVING" )
97+ oracle_common :: validate_value_equivalence ( results, 0 , 1 , "TLP-HAVING" )
9698 }
9799
98100 fn create_error_report ( & self , results : & [ QueryExecutionResult ] ) -> Result < String > {
@@ -113,13 +115,42 @@ impl Oracle for TlpHavingOracle {
113115 match & result. result {
114116 Ok ( batches) => report. push_str ( & format ! (
115117 " status: ok, rows={}\n \n " ,
116- crate :: oracle :: tlp_shared :: count_total_rows( batches)
118+ util :: count_total_rows( batches)
117119 ) ) ,
118120 Err ( e) => report. push_str ( & format ! ( " status: error, details={}\n \n " , e) ) ,
119121 }
120122 }
121123
122- crate :: oracle:: tlp_shared:: append_value_equivalence_report ( & mut report, results) ?;
124+ if results. len ( ) == 2 && results. iter ( ) . all ( |r| r. result . is_ok ( ) ) {
125+ let q_all_batches = results[ 0 ]
126+ . result
127+ . as_ref ( )
128+ . map_err ( |e| fuzzer_err ( & e. to_string ( ) ) ) ?;
129+ let q_union_batches = results[ 1 ]
130+ . result
131+ . as_ref ( )
132+ . map_err ( |e| fuzzer_err ( & e. to_string ( ) ) ) ?;
133+
134+ report. push_str ( & format ! (
135+ "Row counts: all={}, partition_union={}\n " ,
136+ util:: count_total_rows( q_all_batches) ,
137+ util:: count_total_rows( q_union_batches)
138+ ) ) ;
139+
140+ let all_multiset = util:: batches_to_row_multiset ( q_all_batches) ?;
141+ let partition_multiset = util:: batches_to_row_multiset ( q_union_batches) ?;
142+
143+ if all_multiset != partition_multiset {
144+ report. push_str ( "\n Top multiset differences:\n " ) ;
145+ report. push_str ( & util:: format_row_multiset_diff (
146+ & all_multiset,
147+ & partition_multiset,
148+ ) ) ;
149+ report. push ( '\n' ) ;
150+ } else {
151+ report. push_str ( "Multiset equivalence: true\n " ) ;
152+ }
153+ }
123154
124155 Ok ( report)
125156 }
0 commit comments