File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
fuzz-testing/src/main/scala/org/apache/comet/fuzz Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,9 @@ object ComparisonTool {
115115 val cometRows = cometDf.orderBy(cometDf.columns.map(functions.col): _* ).collect()
116116
117117 // Compare the results
118- QueryComparison .assertSameRows(sparkRows, cometRows, output)
119-
120- output.write(s " Subfolder $subfolderName: ${sparkRows.length} rows matched \n\n " )
121-
118+ if (QueryComparison .assertSameRows(sparkRows, cometRows, output)) {
119+ output.write(s " Subfolder $subfolderName: ${sparkRows.length} rows matched \n\n " )
120+ }
122121 } catch {
123122 case e : Exception =>
124123 output.write(
Original file line number Diff line number Diff line change @@ -149,37 +149,42 @@ object QueryComparison {
149149 sparkRows : Array [Row ],
150150 cometRows : Array [Row ],
151151 output : BufferedWriter ): Boolean = {
152- var success = true
153152 if (sparkRows.length == cometRows.length) {
154153 var i = 0
155154 while (i < sparkRows.length) {
156155 val l = sparkRows(i)
157156 val r = cometRows(i)
158157 // Check the schema is equal for first row only
159- if (i == 0 ) {
160- assert(l.schema == r.schema)
158+ if (i == 0 && l.schema != r.schema) {
159+ output.write(
160+ s " [ERROR] Spark produced schema ${l.schema} and " +
161+ s " Comet produced schema ${r.schema} rows. \n " )
162+
163+ return false
161164 }
162165
163166 assert(l.length == r.length)
164167 for (j <- 0 until l.length) {
165168 if (! same(l(j), r(j))) {
166- success = false
167169 output.write(s " First difference at row $i: \n " )
168170 output.write(" Spark: `" + formatRow(l) + " `\n " )
169171 output.write(" Comet: `" + formatRow(r) + " `\n " )
170172 i = sparkRows.length
173+
174+ return false
171175 }
172176 }
173177 i += 1
174178 }
175179 } else {
176- success = false
177180 output.write(
178181 s " [ERROR] Spark produced ${sparkRows.length} rows and " +
179182 s " Comet produced ${cometRows.length} rows. \n " )
183+
184+ return false
180185 }
181186
182- success
187+ true
183188 }
184189
185190 private def same (l : Any , r : Any ): Boolean = {
You can’t perform that action at this time.
0 commit comments