|
24 | 24 | import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral; |
25 | 25 | import org.apache.doris.nereids.trees.expressions.literal.StringLiteral; |
26 | 26 | import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; |
| 27 | +import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral; |
27 | 28 | import org.apache.doris.nereids.types.DateTimeV2Type; |
28 | 29 |
|
29 | 30 | import org.junit.jupiter.api.Assertions; |
@@ -166,4 +167,46 @@ public void testFromUnixTimeOutOfRangeThrows() { |
166 | 167 | Assertions.assertThrows(AnalysisException.class, |
167 | 168 | () -> DateTimeExtractAndTransform.fromUnixTime(dec)); |
168 | 169 | } |
| 170 | + |
| 171 | + @Test |
| 172 | + void testConvertTzDstTransition() { |
| 173 | + // Spring gap maps skipped local times to the transition instant. |
| 174 | + Assertions.assertEquals( |
| 175 | + new DateTimeV2Literal("2021-03-28 01:00:00"), |
| 176 | + DateTimeExtractAndTransform.convertTz( |
| 177 | + new DateTimeV2Literal("2021-03-28 02:15:00"), |
| 178 | + new VarcharLiteral("Europe/Paris"), |
| 179 | + new VarcharLiteral("UTC"))); |
| 180 | + Assertions.assertEquals( |
| 181 | + new DateTimeV2Literal("2021-03-28 01:00:00"), |
| 182 | + DateTimeExtractAndTransform.convertTz( |
| 183 | + new DateTimeV2Literal("2021-03-28 02:00:00"), |
| 184 | + new VarcharLiteral("Europe/Paris"), |
| 185 | + new VarcharLiteral("UTC"))); |
| 186 | + Assertions.assertEquals( |
| 187 | + new DateTimeV2Literal("2021-03-28 01:00:00"), |
| 188 | + DateTimeExtractAndTransform.convertTz( |
| 189 | + new DateTimeV2Literal("2021-03-28 03:00:00"), |
| 190 | + new VarcharLiteral("Europe/Paris"), |
| 191 | + new VarcharLiteral("UTC"))); |
| 192 | + // Fall overlap uses the pre-transition offset. |
| 193 | + Assertions.assertEquals( |
| 194 | + new DateTimeV2Literal("2021-10-31 00:15:00"), |
| 195 | + DateTimeExtractAndTransform.convertTz( |
| 196 | + new DateTimeV2Literal("2021-10-31 02:15:00"), |
| 197 | + new VarcharLiteral("Europe/Paris"), |
| 198 | + new VarcharLiteral("UTC"))); |
| 199 | + Assertions.assertEquals( |
| 200 | + new DateTimeV2Literal("2021-10-31 00:00:00"), |
| 201 | + DateTimeExtractAndTransform.convertTz( |
| 202 | + new DateTimeV2Literal("2021-10-31 02:00:00"), |
| 203 | + new VarcharLiteral("Europe/Paris"), |
| 204 | + new VarcharLiteral("UTC"))); |
| 205 | + Assertions.assertEquals( |
| 206 | + new DateTimeV2Literal("2021-10-31 02:00:00"), |
| 207 | + DateTimeExtractAndTransform.convertTz( |
| 208 | + new DateTimeV2Literal("2021-10-31 03:00:00"), |
| 209 | + new VarcharLiteral("Europe/Paris"), |
| 210 | + new VarcharLiteral("UTC"))); |
| 211 | + } |
169 | 212 | } |
0 commit comments