@@ -136,19 +136,19 @@ class ExpressionsSchemaSuite extends QueryTest with SharedSparkSession {
136
136
}
137
137
}
138
138
139
+ val header = Seq (
140
+ s " <!-- Automatically generated by ${getClass.getSimpleName} --> " ,
141
+ " ## Summary" ,
142
+ s " - Number of queries: ${outputs.size}" ,
143
+ s " - Number of expressions that missing example: ${missingExamples.size}" ,
144
+ s " - Expressions missing examples: ${missingExamples.mkString(" ," )}" ,
145
+ " ## Schema of Built-in Functions" ,
146
+ " | Class name | Function name or alias | Query example | Output schema |" ,
147
+ " | ---------- | ---------------------- | ------------- | ------------- |"
148
+ )
149
+
139
150
if (regenerateGoldenFiles) {
140
- val missingExampleStr = missingExamples.mkString(" ," )
141
- val goldenOutput = {
142
- s " <!-- Automatically generated by ${getClass.getSimpleName} --> \n " +
143
- " ## Summary\n " +
144
- s " - Number of queries: ${outputs.size}\n " +
145
- s " - Number of expressions that missing example: ${missingExamples.size}\n " +
146
- s " - Expressions missing examples: $missingExampleStr\n " +
147
- " ## Schema of Built-in Functions\n " +
148
- " | Class name | Function name or alias | Query example | Output schema |\n " +
149
- " | ---------- | ---------------------- | ------------- | ------------- |\n " +
150
- outputBuffer.mkString(" \n " )
151
- }
151
+ val goldenOutput = (header ++ outputBuffer).mkString(" \n " )
152
152
val parent = resultFile.getParentFile
153
153
if (! parent.exists()) {
154
154
assert(parent.mkdirs(), " Could not create directory: " + parent)
@@ -157,19 +157,18 @@ class ExpressionsSchemaSuite extends QueryTest with SharedSparkSession {
157
157
}
158
158
159
159
val outputSize = outputs.size
160
+ val headerSize = header.size
160
161
val expectedOutputs : Seq [QueryOutput ] = {
161
162
val expectedGoldenOutput = fileToString(resultFile)
162
163
val lines = expectedGoldenOutput.split(" \n " )
163
164
val expectedSize = lines.size
164
165
165
- // The header of golden file has one line, plus four lines of the summary and three
166
- // lines of the header of schema table.
167
- assert(expectedSize == outputSize + 8 ,
168
- s " Expected $expectedSize blocks in result file but got $outputSize. " +
169
- s " Try regenerate the result files. " )
166
+ assert(expectedSize == outputSize + headerSize,
167
+ s " Expected $expectedSize blocks in result file but got " +
168
+ s " ${outputSize + headerSize}. Try regenerate the result files. " )
170
169
171
- Seq .tabulate(outputs.size ) { i =>
172
- val segments = lines(i + 8 ).split('|' )
170
+ Seq .tabulate(outputSize ) { i =>
171
+ val segments = lines(i + headerSize ).split('|' )
173
172
QueryOutput (
174
173
className = segments(1 ).trim,
175
174
funcName = segments(2 ).trim,
0 commit comments