dongjoon-hyun commented on a change in pull request #34199:
URL: https://github.com/apache/spark/pull/34199#discussion_r740758703



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaSuite.scala
##########
@@ -114,7 +130,66 @@ abstract class ParquetSchemaTest extends ParquetTest with 
SharedSparkSession {
       sqlSchema,
       parquetSchema,
       binaryAsString,
-      int96AsTimestamp)
+      int96AsTimestamp,
+      expectedParquetColumn = expectedParquetColumn)
+  }
+
+  protected def compareParquetColumn(actual: ParquetColumn, expected: 
ParquetColumn): Unit = {
+    assert(actual.sparkType == expected.sparkType, "sparkType mismatch: " +
+        s"actual = ${actual.sparkType}, expected = ${expected.sparkType}")
+    assert(actual.descriptor === expected.descriptor, "column descriptor 
mismatch: " +
+        s"actual = ${actual.descriptor}, expected = ${expected.descriptor})")
+    // Parquet ColumnDescriptor equals only compare path so we'll need to 
compare other fields
+    // explicitly here
+    if (actual.descriptor.isDefined && expected.descriptor.isDefined) {
+      val actualDesc = actual.descriptor.get
+      val expectedDesc = expected.descriptor.get
+      assert(actualDesc.getMaxRepetitionLevel == 
expectedDesc.getMaxRepetitionLevel)
+      assert(actualDesc.getMaxRepetitionLevel == 
expectedDesc.getMaxRepetitionLevel)
+      assert(actualDesc.getPrimitiveType === expectedDesc.getPrimitiveType)
+    }
+
+    assert(actual.repetitionLevel == expected.repetitionLevel, "repetition 
level mismatch: " +
+        s"actual = ${actual.repetitionLevel}, expected = 
${expected.repetitionLevel}")
+    assert(actual.definitionLevel == expected.definitionLevel, "definition 
level mismatch: " +
+        s"actual = ${actual.definitionLevel}, expected = 
${expected.definitionLevel}")
+    assert(actual.required == expected.required, "required mismatch: " +
+        s"actual = ${actual.required}, expected = ${expected.required}")
+    assert(actual.path == expected.path, "path mismatch: " +
+        s"actual = $actual.path, expected = ${expected.path}")
+
+    assert(actual.children.size == expected.children.size, "number of children 
mismatch: " +
+        s"actual = ${actual.children.size}, expected = 
${expected.children.size}")
+    actual.children.zip(expected.children).foreach { case (actualChild, 
expectedChild) =>
+      compareParquetColumn(actualChild, expectedChild)
+    }
+  }
+
+  protected def primitiveParquetColumn(
+      sparkType: DataType,
+      parquetTypeName: PrimitiveTypeName,
+      repetition: Repetition,
+      repLevel: Int,
+      defLevel: Int,

Review comment:
       `defLevel` -> `definitionLevel`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to