Skip to content

Commit 0be7cb4

Browse files
committed
Fix append and multisearch ITs (1932/2066)
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 6a30697 commit 0be7cb4

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/utils/OpenSearchTypeFactory.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ public Type getJavaClass(RelDataType type) {
340340
int timeCount = 0;
341341
int ipCount = 0;
342342
int binaryCount = 0;
343+
int otherCount = 0;
343344
for (RelDataType t : types) {
344345
if (t.isNullable()) {
345346
nullableCount++;
@@ -349,6 +350,9 @@ public Type getJavaClass(RelDataType type) {
349350
} else if (t.getSqlTypeName() == SqlTypeName.ANY) {
350351
anyCount++;
351352
}
353+
if (t.getSqlTypeName() == SqlTypeName.OTHER) {
354+
otherCount++;
355+
}
352356
if (OpenSearchTypeUtil.isDate(t)) {
353357
dateCount++;
354358
} else if (OpenSearchTypeUtil.isTime(t)) {
@@ -365,7 +369,10 @@ public Type getJavaClass(RelDataType type) {
365369
udt = createUDT(ExprUDT.EXPR_DATE, nullableCount > 0);
366370
} else if (timeCount == types.size()) {
367371
udt = createUDT(ExprUDT.EXPR_TIME, nullableCount > 0);
368-
} else if (ipCount == types.size()) {
372+
}
373+
// There are cases where UDT IP interleaves with its intermediate SQL type for validation
374+
// OTHER, we check otherCount to patch such cases
375+
else if (ipCount == types.size() || otherCount == types.size()) {
369376
udt = createUDT(ExprUDT.EXPR_IP, nullableCount > 0);
370377
} else if (binaryCount == types.size()) {
371378
udt = createUDT(ExprUDT.EXPR_BINARY, nullableCount > 0);

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMultisearchCommandIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ public void testMultisearchWithTimestampInterleaving() throws IOException {
152152

153153
verifySchema(
154154
result,
155-
schema("@timestamp", null, "string"),
155+
schema("@timestamp", null, "timestamp"),
156156
schema("category", null, "string"),
157157
schema("value", null, "int"),
158-
schema("timestamp", null, "string"));
158+
schema("timestamp", null, "timestamp"));
159159

160160
verifyDataRows(
161161
result,

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLAppendCommandIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void testAppendSchemaMergeWithTimestampUDT() throws IOException {
253253
schema("account_number", "bigint"),
254254
schema("firstname", "string"),
255255
schema("age", "int"),
256-
schema("birthdate", "string"));
256+
schema("birthdate", "timestamp"));
257257
verifyDataRows(actual, rows(32, null, 34, "2018-08-11 00:00:00"));
258258
}
259259

0 commit comments

Comments
 (0)