Commit eb5af73
Support DST timezones conversion for ORC [databricks] (#14544)
Fixes #13437.
#### Depends on:
* part 1: NVIDIA/cudf-spark-jni#4539
* part 2: NVIDIA/cudf-spark-jni#4635
* part 3: NVIDIA/cudf-spark-jni#4733
* ORC 2015 base-offset borrow fix:
NVIDIA/cudf-spark-jni#4809
* part 4: NVIDIA/cudf-spark-jni#4812
* part 5: NVIDIA/cudf-spark-jni#4813
### Description
#### Context
ORC OSS uses java.util.TimeZone to do rebase, it does not use
java.time.ZoneId API.
The java.util.TimeZone and java.time.ZoneId have inconsistent behavior.
cuDF have `java.time` compatible impl, but does not have `java.util`
compatible impl
`java.util.TimeZone.getOffset` and `java.time.ZoneId.getOffset` are not
always consistent.
<details>
<summary>For more details, click to expand</summary>
```java
static void testDiffBehaviorBetweenTwoAPIs() {
// diff in `Africa/Casablanca` timezone at 6424721300000: 0 vs 3600000
String tzId = "Africa/Casablanca";
long epochMillis = 6424721300000L;
int offsetMillis_1 = java.util.TimeZone.getTimeZone(tzId).getOffset(epochMillis);
int offsetMillis_2 = java.time.ZoneId.of(tzId, ZoneId.SHORT_IDS).getRules().getOffset(Instant.ofEpochMilli(epochMillis)).getTotalSeconds() * 1000;
if (offsetMillis_1 != offsetMillis_2) {
// print: get diff!! 0 vs 3600000
System.out.println("get diff!! " + offsetMillis_1 + " vs " + offsetMillis_2);
}
}
```
</details>
#### Solution 1 [not feasible], use cuDF with
ignoreTimezoneInStripeFooter=False.
cuDF manages the ORC writer timezone decode.
Problem: for far-future timestamps projected into the synthetic 400-year
cycle, dates before the first synthetic DST transition were incorrectly
using the first cycle entry, which is the DST offset. That causes
exactly the +1 hour winter drift you saw for America/Los_Angeles with
years like 8770.
cuDF has `java.time` compatible impl instead of `java.util`. We can not
get correct result.
So this solution is not feasible.
#### Solution 2, develope kernel, use cuDF with
ignoreTimezoneInStripeFooter=True
cuDF does not manage the ORC writer timezone decode. Decode as UTC in
cuDF.
All time rebasing logic is handled by customized JNI kernel which is
compatible to `java.util`.
#### changes
- Remove the orc_timezone_info.data file, get the timezone info
dynamically.
Why: A pre-built timezone info file can not handle for all Java
versions, in future the timezone info may change.
- Implements `java.util.Timezone` logic
- Add OrcTimezoneSuite to test reader/writer timezone combinations.
#### Related cuDF issue
* rapidsai/cudf#21993
### perf number
| Test | CPU avg (ms) | GPU avg (ms) | Speedup |
|------|-------------:|-------------:|--------:|
| **cross-tz** (LA→UTC) | 23,662 | 13,815 | 1.71x |
| **same-tz-baseline** (LA→LA) | 79,699 | 13,766 | 5.79x |
<details>
<summary>How to run, refer to `OrcTimezonePerfSuite.scala`, click to
expand</summary>
```bash
argLine="-DenableOrcTimeZonePerf=true \
-DorcPerfWriterTZ=America/Los_Angeles \
-DorcPerfReaderTZ=UTC \
-DorcPerfRows=1073741824" \
mvn test -Dbuildver=350 \
-DwildcardSuites=com.nvidia.spark.rapids.timezone.OrcTimezonePerfSuite
```
</details>
### Checklists
Documentation
- [x] Updated for new or modified user-facing features or behaviors
- [ ] No user-facing change
Testing
- [x] Added or modified tests to cover new code paths
- [ ] Covered by existing tests
(Please provide the names of the existing tests in the PR description.)
- [ ] Not required
Performance
- [x] Tests ran and results are added in the PR description
- [ ] Issue filed with a link in the PR description
- [ ] Not required
Signed-off-by: Chong Gao <chongg@nvidia.com>
---------
Signed-off-by: Chong Gao <res_life@163.com>
Signed-off-by: Chong Gao <chongg@nvidia.com>
Co-authored-by: Chong Gao <res_life@163.com>1 parent c406ee0 commit eb5af73
8 files changed
Lines changed: 908 additions & 201 deletions
File tree
- integration_tests/src/main/python
- sql-plugin/src/main/scala
- com/nvidia/spark/rapids
- shims
- org/apache/spark/sql/rapids
- tests/src/test/scala/com/nvidia/spark/rapids/timezone
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
| |||
195 | 193 | | |
196 | 194 | | |
197 | 195 | | |
198 | | - | |
199 | 196 | | |
200 | 197 | | |
201 | 198 | | |
| |||
224 | 221 | | |
225 | 222 | | |
226 | 223 | | |
227 | | - | |
228 | 224 | | |
229 | 225 | | |
230 | 226 | | |
| |||
281 | 277 | | |
282 | 278 | | |
283 | 279 | | |
284 | | - | |
285 | 280 | | |
286 | 281 | | |
287 | 282 | | |
| |||
351 | 346 | | |
352 | 347 | | |
353 | 348 | | |
354 | | - | |
355 | 349 | | |
356 | 350 | | |
357 | 351 | | |
| |||
693 | 687 | | |
694 | 688 | | |
695 | 689 | | |
696 | | - | |
697 | 690 | | |
698 | 691 | | |
699 | 692 | | |
| |||
878 | 871 | | |
879 | 872 | | |
880 | 873 | | |
881 | | - | |
882 | 874 | | |
883 | 875 | | |
884 | 876 | | |
| |||
893 | 885 | | |
894 | 886 | | |
895 | 887 | | |
896 | | - | |
897 | 888 | | |
898 | 889 | | |
899 | 890 | | |
| |||
1129 | 1120 | | |
1130 | 1121 | | |
1131 | 1122 | | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1132 | 1147 | | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | 1148 | | |
1137 | 1149 | | |
1138 | 1150 | | |
1139 | | - | |
| 1151 | + | |
1140 | 1152 | | |
1141 | 1153 | | |
1142 | | - | |
| 1154 | + | |
| 1155 | + | |
1143 | 1156 | | |
1144 | 1157 | | |
1145 | 1158 | | |
| |||
1154 | 1167 | | |
1155 | 1168 | | |
1156 | 1169 | | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
1160 | 1170 | | |
1161 | 1171 | | |
1162 | 1172 | | |
1163 | 1173 | | |
1164 | 1174 | | |
| 1175 | + | |
| 1176 | + | |
1165 | 1177 | | |
1166 | 1178 | | |
1167 | 1179 | | |
| |||
0 commit comments