uros-db commented on code in PR #56550:
URL: https://github.com/apache/spark/pull/56550#discussion_r3430224948
##########
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:
Please confirm this, but I think that CharType/VarcharType branches are
effectively dead in the real paths. Char/Varchar are normalized to StringType
before reaching JdbcUtils.
--
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]