uros-b commented on code in PR #56550:
URL: https://github.com/apache/spark/pull/56550#discussion_r3431822382


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtilsSuite.scala:
##########
@@ -69,4 +72,18 @@ class JdbcUtilsSuite extends SparkFunSuite {
       condition = "PARSE_SYNTAX_ERROR",
       parameters = Map("error" -> "'.'", "hint" -> ""))
   }
+
+  test("SPARK-57471: estimateInternalRowSize estimates ArrayType by element 
count") {
+    val schema = StructType(Seq(StructField("a", ArrayType(IntegerType))))
+    val row = new GenericInternalRow(Array[Any](new GenericArrayData(Array(1, 
2, 3))))
+    // 3 elements * 4 bytes (IntegerType.defaultSize) = 12
+    assert(JdbcUtils.estimateInternalRowSize(row, schema) === 12L)
+  }
+
+  test("SPARK-57471: estimateRowSize estimates ArrayType by element count") {
+    val schema = StructType(Seq(StructField("a", ArrayType(IntegerType))))
+    val row = Row(Seq(1, 2, 3))
+    // 3 elements * 4 bytes (IntegerType.defaultSize) = 12
+    assert(JdbcUtils.estimateRowSize(row, schema) === 12L)
+  }
 }

Review Comment:
   JdbcUtilsSuite only adds ArrayType tests. Consider one or two direct unit 
tests for: String (numBytes vs defaultSize); Null fields contributing 0; Binary 
length; etc.



-- 
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