yadavay-amzn commented on code in PR #56550:
URL: https://github.com/apache/spark/pull/56550#discussion_r3431899313


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -354,6 +354,60 @@ object JdbcUtils extends Logging with SQLConfHelper {
     internalRows.map(fromRow)
   }
 
+  /**
+   * Estimates the size in bytes of a row given its schema. For 
variable-length types
+   * (String, Binary), uses actual value size; for fixed-width types, uses 
defaultSize.
+   * Null fields contribute 0 bytes.
+   */
+  private[jdbc] def estimateInternalRowSize(row: InternalRow, schema: 
StructType): Long = {
+    var size = 0L
+    var i = 0
+    while (i < schema.length) {
+      if (!row.isNullAt(i)) {
+        schema.fields(i).dataType match {
+          case _: StringType | _: CharType | _: VarcharType =>

Review Comment:
   Confirmed: JdbcUtils runs 
CharVarcharUtils.replaceCharVarcharWithStringInSchema on the
     read schema before the estimator, and the write rddSchema is already 
post-analysis, so raw
     CharType/VarcharType never reach these helpers. Removed those branches 
(and their unit tests);
     StringType/BinaryType/ArrayType/defaultSize remain.



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