Skip to content

Commit ce5a441

Browse files
committed
chore: display schema for datasets being compared
1 parent 2c299d5 commit ce5a441

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

fuzz-testing/src/main/scala/org/apache/comet/fuzz/QueryRunner.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,16 @@ object QueryComparison {
154154
while (i < sparkRows.length) {
155155
val l = sparkRows(i)
156156
val r = cometRows(i)
157+
157158
// Check the schema is equal for first row only
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")
159+
if (i == 0) {
160+
showSchema(output, l.schema.treeString, r.schema.treeString)
161+
162+
if (l.schema != r.schema) {
163+
output.write("[ERROR] Spark produced different schema than Comet.\n")
162164

163-
return false
165+
return false
166+
}
164167
}
165168

166169
assert(l.length == r.length)
@@ -254,4 +257,11 @@ object QueryComparison {
254257
w.write("### Comet Plan\n")
255258
w.write(s"```\n$cometPlan\n```\n")
256259
}
260+
261+
def showSchema(w: BufferedWriter, sparkSchema: String, cometSchema: String): Unit = {
262+
w.write("### Spark Schema\n")
263+
w.write(s"```\n$sparkSchema\n```\n")
264+
w.write("### Comet Schema\n")
265+
w.write(s"```\n$cometSchema\n```\n")
266+
}
257267
}

0 commit comments

Comments
 (0)