yadavay-amzn commented on code in PR #56550:
URL: https://github.com/apache/spark/pull/56550#discussion_r3432155791
##########
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:
Added direct `JdbcUtilsSuite `unit tests for String (actual `numBytes` vs
defaultSize), null fields
contributing 0, Binary length, and array-of-String accuracy, for both
helpers.
--
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]