rednaxelafx opened a new pull request #24392: [SPARK-27423][SQL][FOLLOWUP] 
Minor polishes to Cast codegen templates for Date <-> Timestamp 
URL: https://github.com/apache/spark/pull/24392
 
 
   ## What changes were proposed in this pull request?
   
   https://github.com/apache/spark/pull/24332 introduced an unnecessary 
`import` statement and two slight issues in the codegen templates in `Cast` for 
`Date` <-> `Timestamp`.
   This PR removes the unused import statement and fixes the slight codegen 
issue.
   
   The issue in those two codegen templates is this pattern:
   ```scala
   val zid = JavaCode.global(
     ctx.addReferenceObj("zoneId", zoneId, "java.time.ZoneId"),
     zoneId.getClass)
   ```
   `zoneId` can refer to an instance of a non-public class, e.g. 
`java.time.ZoneRegion`, and while this code correctly puts in the 3rd argument 
to `ctx.addReferenceObj()`, it's still passing `zoneId.getClass` to 
`JavaCode.global()` which is not desirable, but doesn't cause any immediate 
bugs in this particular case, because `zid` is used in an expression 
immediately afterwards.
   If this `zid` ever needs to spill to any explicitly typed variables, e.g. a 
local variable, and if the spill handling uses the `javaType` on this 
`GlobalVariable`, it'd generate code that looks like:
   ```java
   java.time.ZoneRegion value1 = ((java.time.ZoneId) references[2] /* literal 
*/);
   ```
   which would then be a real bug:
   - a non-accessible type `java.time.ZoneRegion` is referenced in the 
generated code, and
   - `ZoneId` -> `ZoneRegion` requires an explicit downcast.
   
   ## How was this patch tested?
   
   Existing tests. This PR does not change behavior, and the original PR won't 
cause any real behavior bug to begin with.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to