Skip to content

Commit c503b05

Browse files
committed
test(isthmus): assert current_timezone emits as bare keyword
Split the emitted-SQL check out of the current_timezone round-trip test into its own currentTimezoneEmittedAsBareKeyword test that explicitly asserts CURRENT_TIMEZONE is rendered as a bare niladic keyword and not as a function call CURRENT_TIMEZONE(). Both assertions now include the actual emitted SQL in their failure messages.
1 parent 36e5012 commit c503b05

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

isthmus/src/test/java/io/substrait/isthmus/Substrait2SqlTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
44
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
56
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
67
import static org.junit.jupiter.api.Assertions.assertTrue;
78

@@ -51,14 +52,23 @@ void currentDate() throws Exception {
5152

5253
@Test
5354
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.
5655
assertFullRoundTrip("select current_timezone from part");
56+
}
5757

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().
5963
Plan plan = toSubstraitPlan("select current_timezone from part", TPCH_CATALOG);
64+
String sql = toSql(plan);
6065
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);
6272
}
6373

6474
@Test

0 commit comments

Comments
 (0)