Skip to content

Commit 03ed5e9

Browse files
committed
test(api): pin UnifiedQueryContext PATTERN_* defaults via planner test
Per @dai-chen: verify the RelNode produced when `patterns <field>` is run without explicit method=/mode= args — exercises that the PATTERN_METHOD and PATTERN_MODE defaults flow through to AstBuilder.visitPatternsCommand and produce a valid SIMPLE/LABEL lowering with a `patterns_field` projection. Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent 975f8cc commit 03ed5e9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

api/src/test/java/org/opensearch/sql/api/UnifiedQueryPlannerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,18 @@ public void testUnsupportedStatementType() {
115115
public void testPlanPropagatingSyntaxCheckException() {
116116
planner.plan("source = catalog.employees | eval"); // Trigger syntax error from parser
117117
}
118+
119+
/**
120+
* Without the {@code PATTERN_*} defaults in {@link UnifiedQueryContext}, a bare
121+
* {@code patterns <field>} (no explicit {@code method=}/{@code mode=}) dies at parse time
122+
* with {@code PatternMethod.valueOf("NULL")} because {@code AstBuilder.visitPatternsCommand}
123+
* reads a null from {@code settings.getSettingValue(Key.PATTERN_METHOD)}. With the defaults
124+
* present, the planner lowers patterns to SIMPLE / LABEL mode and adds {@code patterns_field}.
125+
*/
126+
@Test
127+
public void testPPLPatternsPicksUpDefaults() {
128+
givenQuery("source = catalog.employees | patterns name")
129+
.assertPlanContains("REGEXP_REPLACE")
130+
.assertFields("id", "name", "age", "department", "patterns_field");
131+
}
118132
}

0 commit comments

Comments
 (0)