david-mollitor-db opened a new pull request, #58803:
URL: https://github.com/apache/spark/pull/58803

   ### What changes were proposed in this pull request?
   
   `SparkDateTimeUtils.parseTimestampString` normalizes the parsed time zone 
with:
   
   ```scala
   val zoneId = tz.map(zoneName => getZoneId(zoneName.trim))
   ```
   
   Because `getZoneId` is an instance method of the trait, the mapping function 
`zoneName =>
   getZoneId(zoneName.trim)` captures `this`. This PR replaces the `map` with a 
direct pattern
   match on the `Option`, which is behavior-preserving:
   
   ```scala
   val zoneId = tz match {
     case Some(zoneName) => Some(getZoneId(zoneName.trim))
     case None => None
   }
   ```
   
   ### Why are the changes needed?
   
   A *capturing* lambda is not compiled to a cached singleton: the JVM 
allocates a fresh closure
   instance every time the lambda expression is evaluated (only non-capturing 
lambdas get a
   constant `CallSite`). `parseTimestampString` runs once per parsed timestamp 
value — e.g. CSV
   and JSON ingestion, casts to timestamp, and the date/time functions — so the 
current code
   allocates one closure per parsed timestamp on a hot path.
   
   The pattern match produces the identical result with no closure: the `None` 
case allocates
   nothing, and the `Some` case allocates only the `Some` wrapper that `map` 
already produced.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing tests, which cover the time-zone parsing paths:
   
   ```
   build/sbt 'catalyst/testOnly *DateTimeUtilsSuite *TimestampFormatterSuite'
   ```
   
   All 124 tests pass.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Isaac
   
   This pull request and its description were written by Isaac.
   


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