Skip to content

Commit a81a510

Browse files
committed
fix IT by adding fields
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent ffd11a5 commit a81a510

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLCaseFunctionIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testCaseWhenWithCast() {
6666
cast(response as int) >= 400 AND cast(response as int) < 500, "Client Error",
6767
cast(response as int) >= 500 AND cast(response as int) < 600, "Server Error"
6868
else concat("Incorrect HTTP status code for", url))
69-
| where status != "Success"
69+
| where status != "Success" | fields host, method, bytes, response, url, status
7070
""",
7171
TEST_INDEX_WEBLOGS));
7272
verifySchema(
@@ -110,7 +110,7 @@ public void testCaseWhenNoElse() {
110110
cast(response as int) >= 300 AND cast(response as int) < 400, "Redirection",
111111
cast(response as int) >= 400 AND cast(response as int) < 500, "Client Error",
112112
cast(response as int) >= 500 AND cast(response as int) < 600, "Server Error")
113-
| where isnull(status) OR status != "Success"
113+
| where isnull(status) OR status != "Success" | fields host, method, bytes, response, url, status
114114
""",
115115
TEST_INDEX_WEBLOGS));
116116
verifySchema(
@@ -149,7 +149,7 @@ response in ('300', '301'), "Redirection",
149149
response in ('400', '403'), "Client Error",
150150
response in ('500', '505'), "Server Error"
151151
else concat("Incorrect HTTP status code for", url))
152-
| where status != "Success"
152+
| where status != "Success" | fields host, method, bytes, response, url, status
153153
""",
154154
TEST_INDEX_WEBLOGS));
155155
verifySchema(
@@ -194,6 +194,7 @@ response in ('300', '301'), false,
194194
response in ('400', '403'), false,
195195
response in ('500', '505'), false
196196
else false)
197+
| fields host, method, bytes, response, url
197198
""",
198199
TEST_INDEX_WEBLOGS));
199200
verifySchema(
@@ -228,6 +229,7 @@ response in ('500', '505'), "500"
228229
else concat("Incorrect HTTP status code for", url))
229230
| fields new_response
230231
]
232+
| fields host, method, bytes, response, url
231233
""",
232234
TEST_INDEX_WEBLOGS, TEST_INDEX_WEBLOGS));
233235
verifySchema(

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public void testGeoIpEnrichment() {
8383
JSONObject resultGeoIp =
8484
executeQuery(
8585
String.format(
86-
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s)",
86+
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s) | fields name, ip,"
87+
+ " enrichmentResult",
8788
TEST_INDEX_GEOIP, "dummycityindex", "ip"));
8889

8990
verifyColumn(resultGeoIp, columnName("name"), columnName("ip"), columnName("enrichmentResult"));
@@ -100,7 +101,8 @@ public void testGeoIpEnrichmentWithSingleOption() {
100101
JSONObject resultGeoIp =
101102
executeQuery(
102103
String.format(
103-
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s,\\\"%s\\\")",
104+
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s,\\\"%s\\\") |"
105+
+ " fields name, ip, enrichmentResult",
104106
TEST_INDEX_GEOIP, "dummycityindex", "ip", "city"));
105107

106108
verifyColumn(resultGeoIp, columnName("name"), columnName("ip"), columnName("enrichmentResult"));
@@ -117,7 +119,8 @@ public void testGeoIpEnrichmentWithSpaceSeparatedMultipleOptions() {
117119
JSONObject resultGeoIp =
118120
executeQuery(
119121
String.format(
120-
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s,\\\"%s\\\")",
122+
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s,\\\"%s\\\") |"
123+
+ " fields name, ip, enrichmentResult",
121124
TEST_INDEX_GEOIP, "dummycityindex", "ip", "city , country"));
122125

123126
verifyColumn(resultGeoIp, columnName("name"), columnName("ip"), columnName("enrichmentResult"));

opensearch/src/main/java/org/opensearch/sql/opensearch/request/system/OpenSearchDescribeIndexRequest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import java.util.ArrayList;
1212
import java.util.Arrays;
13-
import java.util.HashMap;
1413
import java.util.LinkedHashMap;
1514
import java.util.List;
1615
import java.util.Locale;
@@ -99,10 +98,9 @@ public List<ExprValue> search() {
9998
*/
10099
// TODO possible collision if two indices have fields with the same name and different mappings
101100
public Map<String, OpenSearchDataType> getFieldTypes() {
102-
Map<String, OpenSearchDataType> fieldTypes = new HashMap<>();
101+
Map<String, OpenSearchDataType> fieldTypes = new LinkedHashMap<>();
103102
Map<String, IndexMapping> indexMappings =
104103
client.getIndexMappings(getLocalIndexNames(indexName.getIndexNames()));
105-
log.error(indexMappings.keySet());
106104
for (IndexMapping indexMapping : indexMappings.values()) {
107105
mergeObjectAndArrayInsideMap(fieldTypes, indexMapping.getFieldMappings());
108106
}

0 commit comments

Comments
 (0)