Skip to content

Commit 3e9e60b

Browse files
committed
'gender' in test data should contain keyword subfield
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 23e179e commit 3e9e60b

6 files changed

Lines changed: 32 additions & 55 deletions

File tree

benchmarks/src/jmh/java/org/opensearch/sql/expression/operator/predicate/MergeArrayAndObjectMapBenchmark.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Map;
1313
import org.openjdk.jmh.annotations.Benchmark;
1414
import org.opensearch.sql.opensearch.data.type.OpenSearchDataType;
15-
import org.opensearch.sql.opensearch.request.system.OpenSearchDescribeIndexRequest;
15+
import org.opensearch.sql.opensearch.util.MergeRules.MergeRuleHelper;
1616

1717
public class MergeArrayAndObjectMapBenchmark {
1818
private static final List<Map<String, OpenSearchDataType>> candidateMaps = prepareListOfMaps(120);
@@ -21,7 +21,7 @@ public class MergeArrayAndObjectMapBenchmark {
2121
public void testMerge() {
2222
Map<String, OpenSearchDataType> finalResult = new HashMap<>();
2323
for (Map<String, OpenSearchDataType> map : candidateMaps) {
24-
OpenSearchDescribeIndexRequest.mergeObjectAndArrayInsideMap(finalResult, map);
24+
MergeRuleHelper.merge(finalResult, map);
2525
}
2626
}
2727

integ-test/src/test/java/org/opensearch/sql/legacy/PrettyFormatResponseIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public void aggregationFunctionInHaving() throws IOException {
437437

438438
JSONArray dataRows = getDataRows(response);
439439
assertEquals(1, dataRows.length());
440-
assertEquals("m", dataRows.getJSONArray(0).getString(0));
440+
assertEquals("M", dataRows.getJSONArray(0).getString(0));
441441
}
442442

443443
/**

integ-test/src/test/java/org/opensearch/sql/ppl/RareCommandIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void testRareWithGroup() throws IOException {
5959
rows("F", "OK", 7),
6060
rows("F", "KS", 7),
6161
rows("F", "CO", 7),
62-
rows("F", "NV", 8),
62+
rows("F", "AR", 8),
6363
rows("M", "NE", 5),
6464
rows("M", "RI", 5),
6565
rows("M", "NV", 5),

integ-test/src/test/java/org/opensearch/sql/ppl/StatsCommandIT.java

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import static org.opensearch.sql.util.MatcherUtils.rows;
1212
import static org.opensearch.sql.util.MatcherUtils.schema;
1313
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
14-
import static org.opensearch.sql.util.MatcherUtils.verifyDataRowsInOrder;
1514
import static org.opensearch.sql.util.MatcherUtils.verifySchema;
1615
import static org.opensearch.sql.util.MatcherUtils.verifySchemaInOrder;
1716

@@ -358,27 +357,15 @@ public void testStatsBySpanAndMultipleFields() throws IOException {
358357
schema("span(age,10)", null, "int"),
359358
schema("gender", null, "string"),
360359
schema("state", null, "string"));
361-
if (isCalciteEnabled()) {
362-
verifyDataRows(
363-
response,
364-
rows(1, 20, "F", "VA"),
365-
rows(1, 30, "F", "IN"),
366-
rows(1, 30, "F", "PA"),
367-
rows(1, 30, "M", "IL"),
368-
rows(1, 30, "M", "MD"),
369-
rows(1, 30, "M", "TN"),
370-
rows(1, 30, "M", "WA"));
371-
} else {
372-
verifyDataRowsInOrder(
373-
response,
374-
rows(1, 20, "f", "VA"),
375-
rows(1, 30, "f", "IN"),
376-
rows(1, 30, "f", "PA"),
377-
rows(1, 30, "m", "IL"),
378-
rows(1, 30, "m", "MD"),
379-
rows(1, 30, "m", "TN"),
380-
rows(1, 30, "m", "WA"));
381-
}
360+
verifyDataRows(
361+
response,
362+
rows(1, 20, "F", "VA"),
363+
rows(1, 30, "F", "IN"),
364+
rows(1, 30, "F", "PA"),
365+
rows(1, 30, "M", "IL"),
366+
rows(1, 30, "M", "MD"),
367+
rows(1, 30, "M", "TN"),
368+
rows(1, 30, "M", "WA"));
382369
}
383370

384371
@Test
@@ -395,27 +382,15 @@ public void testStatsByMultipleFieldsAndSpan() throws IOException {
395382
schema("span(age,10)", null, "int"),
396383
schema("gender", null, "string"),
397384
schema("state", null, "string"));
398-
if (isCalciteEnabled()) {
399-
verifyDataRows(
400-
response,
401-
rows(1, 20, "F", "VA"),
402-
rows(1, 30, "F", "IN"),
403-
rows(1, 30, "F", "PA"),
404-
rows(1, 30, "M", "IL"),
405-
rows(1, 30, "M", "MD"),
406-
rows(1, 30, "M", "TN"),
407-
rows(1, 30, "M", "WA"));
408-
} else {
409-
verifyDataRowsInOrder(
410-
response,
411-
rows(1, 20, "f", "VA"),
412-
rows(1, 30, "f", "IN"),
413-
rows(1, 30, "f", "PA"),
414-
rows(1, 30, "m", "IL"),
415-
rows(1, 30, "m", "MD"),
416-
rows(1, 30, "m", "TN"),
417-
rows(1, 30, "m", "WA"));
418-
}
385+
verifyDataRows(
386+
response,
387+
rows(1, 20, "F", "VA"),
388+
rows(1, 30, "F", "IN"),
389+
rows(1, 30, "F", "PA"),
390+
rows(1, 30, "M", "IL"),
391+
rows(1, 30, "M", "MD"),
392+
rows(1, 30, "M", "TN"),
393+
rows(1, 30, "M", "WA"));
419394
}
420395

421396
@Test

integ-test/src/test/resources/indexDefinitions/account_index_mapping.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
"properties": {
44
"gender": {
55
"type": "text",
6+
"fielddata": true,
67
"fields": {
7-
"subfield1": {
8+
"keyword": {
89
"type": "keyword",
910
"ignore_above": 256
1011
}
1112
}
1213
},
1314
"address": {
1415
"type": "text",
15-
"fields": {
16-
"subfield2": {
17-
"type": "keyword",
18-
"ignore_above": 256
19-
}
20-
}
16+
"fielddata": true
2117
},
2218
"firstname": {
2319
"type": "text",

integ-test/src/test/resources/indexDefinitions/bank_index_mapping.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
},
3131
"gender": {
3232
"type": "text",
33-
"fielddata": true
33+
"fielddata": true,
34+
"fields": {
35+
"keyword": {
36+
"type": "keyword",
37+
"ignore_above": 256
38+
}
39+
}
3440
},
3541
"lastname": {
3642
"type": "keyword"

0 commit comments

Comments
 (0)