Skip to content

Commit

Permalink
Fix bug where invalid schema name was being used for returned highlig…
Browse files Browse the repository at this point in the history
…ht fields

Signed-off-by: forestmvey <[email protected]>
  • Loading branch information
forestmvey committed Aug 4, 2022
1 parent 9fbea30 commit 23a24e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public HighlightExpression(Expression highlightField) {
}

/**
* Return String or Map value matching highlight field.
* Return collection value matching highlight field.
* @param valueEnv : Dataset to parse value from.
* @return : String or Map value of highlight fields.
* @return : collection value of highlight fields.
*/
@Override
public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
Expand All @@ -47,7 +47,7 @@ public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
*/
@Override
public ExprType type() {
return ExprCoreType.STRING;
return ExprCoreType.ARRAY;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opensearch.sql.data.type.ExprCoreType.ARRAY;
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;

import com.google.common.collect.ImmutableMap;
Expand All @@ -26,7 +27,7 @@ public void single_highlight_test() {
HighlightExpression expr = new HighlightExpression(DSL.literal("Title"));
ExprValue resultVal = expr.valueOf(hlTuple);

assertEquals(expr.type(), resultVal.type());
assertEquals(expr.type(), ARRAY);
assertEquals("result value", resultVal.stringValue());
}

Expand Down Expand Up @@ -54,7 +55,7 @@ public void highlight_all_test() {
HighlightExpression hlExpr = new HighlightExpression(DSL.literal("*"));
ExprValue resultVal = hlExpr.valueOf(
ExprTupleValue.fromExprValueMap(builder.build()).bindingTuples());
assertEquals(STRUCT, resultVal.type());
assertEquals(ARRAY, resultVal.type());
for (var field : resultVal.tupleValue().entrySet()) {
assertTrue(field.toString().contains(hlExpr.getHighlightField().toString()));
}
Expand Down

0 comments on commit 23a24e2

Please sign in to comment.