Skip to content

Commit 425da58

Browse files
committed
Fix test failure
Signed-off-by: Tomoyuki Morita <moritato@amazon.com>
1 parent 4ea8d6f commit 425da58

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/rel/RelFieldBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public RexNode dynamicField(int inputCount, int inputOrdinal, String fieldName)
125125
relBuilder.field(inputCount, inputOrdinal, DYNAMIC_FIELDS_MAP), fieldName);
126126
}
127127

128-
public RexNode createItemAccess(RexNode field, String itemName) {
128+
private RexNode createItemAccess(RexNode field, String itemName) {
129129
return PPLFuncImpTable.INSTANCE.resolve(
130130
rexBuilder, BuiltinFunctionName.INTERNAL_ITEM, field, rexBuilder.makeLiteral(itemName));
131131
}

ppl/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,10 @@ public UnresolvedPlan visitSpathCommand(OpenSearchPPLParser.SpathCommandContext
764764
if (inField == null) {
765765
throw new IllegalArgumentException("`input` parameter is required for `spath`");
766766
}
767+
if (outField != null && path == null) {
768+
throw new IllegalArgumentException(
769+
"`path` parameter is required when `output` is specified for `spath`");
770+
}
767771

768772
return new SPath(inField, outField, path);
769773
}

ppl/src/test/java/org/opensearch/sql/ppl/calcite/CalcitePPLSpathTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public void testEvalWithOutput() {
4747
}
4848

4949
@Test
50-
public void testSpathWithoutOutput() {
50+
public void testSpathWithoutPath() {
5151
String ppl = "source=EMP | fields ENAME | spath input=ENAME";
5252
RelNode root = getRelNode(ppl);
5353

5454
String expectedSparkSql =
55-
"SELECT `append`(`ENAME`, `JSON_EXTRACT_ALL`(`ENAME`)['ENAME']) `ENAME`,"
55+
"SELECT `APPEND`(`ENAME`, `JSON_EXTRACT_ALL`(`ENAME`)['ENAME']) `ENAME`,"
5656
+ " `MAP_REMOVE`(`JSON_EXTRACT_ALL`(`ENAME`), ARRAY ('ENAME')) `_MAP`\n"
5757
+ "FROM `scott`.`EMP`";
5858
verifyPPLToSparkSQL(root, expectedSparkSql);

ppl/src/test/java/org/opensearch/sql/ppl/utils/SPathRewriteTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public void testSpathMissingInputArgumentHandling() {
5555
plan("source = t | spath path=a output=a");
5656
}
5757

58+
@Test(expected = IllegalArgumentException.class)
59+
public void testSpathMissingPathArgumentHandling() {
60+
plan("source = t | spath input=a output=a");
61+
}
62+
5863
@Test
5964
public void testSpathArgumentDeshuffle() {
6065
assertEquals(plan("source = t | spath path=a input=a"), plan("source = t | spath input=a a"));

0 commit comments

Comments
 (0)