|
2 | 2 |
|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
4 | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
5 | 6 | import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
6 | 7 | import static org.junit.jupiter.api.Assertions.assertTrue; |
7 | 8 |
|
@@ -51,14 +52,23 @@ void currentDate() throws Exception { |
51 | 52 |
|
52 | 53 | @Test |
53 | 54 | void currentTimezone() throws Exception { |
54 | | - // CURRENT_TIMEZONE is a Substrait-specific niladic operator with no standard Calcite |
55 | | - // equivalent; it is registered in SubstraitOperatorTable so it parses without parentheses. |
56 | 55 | assertFullRoundTrip("select current_timezone from part"); |
| 56 | + } |
57 | 57 |
|
58 | | - // ...and it is emitted back as the bare niladic keyword (no dialect changes required). |
| 58 | + @Test |
| 59 | + void currentTimezoneEmittedAsBareKeyword() throws Exception { |
| 60 | + // CURRENT_TIMEZONE is a Substrait-specific niladic operator with no standard Calcite |
| 61 | + // equivalent; it is registered in SubstraitOperatorTable so it parses without parentheses and |
| 62 | + // is emitted back as the bare keyword rather than as a function call CURRENT_TIMEZONE(). |
59 | 63 | Plan plan = toSubstraitPlan("select current_timezone from part", TPCH_CATALOG); |
| 64 | + String sql = toSql(plan); |
60 | 65 | assertTrue( |
61 | | - toSql(plan).contains("CURRENT_TIMEZONE"), "expected CURRENT_TIMEZONE in emitted SQL"); |
| 66 | + sql.contains("CURRENT_TIMEZONE"), () -> "expected CURRENT_TIMEZONE in emitted SQL: " + sql); |
| 67 | + assertFalse( |
| 68 | + sql.contains("CURRENT_TIMEZONE("), |
| 69 | + () -> |
| 70 | + "expected CURRENT_TIMEZONE as a bare keyword, not a function call, in emitted SQL: " |
| 71 | + + sql); |
62 | 72 | } |
63 | 73 |
|
64 | 74 | @Test |
|
0 commit comments