50bdc9befa
## 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. Closes #24392 from rednaxelafx/spark-27423-followup. Authored-by: Kris Mok <kris.mok@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> |
||
---|---|---|
.. | ||
benchmarks | ||
src | ||
pom.xml |