Skip to content

Commit

Permalink
Fix type resolution in IT.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jul 21, 2023
1 parent b9df096 commit b8f84da
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void test_numeric_data_types() throws IOException {
schema("byte_number", "byte"),
schema("double_number", "double"),
schema("float_number", "float"),
schema("half_float_number", "float"),
schema("scaled_float_number", "double"));
schema("half_float_number", "half_float"),
schema("scaled_float_number", "scaled_float"));
}

@Test
Expand All @@ -51,8 +51,8 @@ public void test_nonnumeric_data_types() throws IOException {
schema("binary_value", "binary"),
schema("date_value", "timestamp"),
schema("ip_value", "ip"),
schema("object_value", "struct"),
schema("nested_value", "array"),
schema("object_value", "object"),
schema("nested_value", "nested"),
schema("geo_point_value", "geo_point"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ public void typeof_opensearch_types() throws IOException {
+ " | fields `double`, `long`, `integer`, `byte`, `short`, `float`, `half_float`, `scaled_float`",
TEST_INDEX_DATATYPE_NUMERIC));
verifyDataRows(response,
rows("DOUBLE", "LONG", "INTEGER", "BYTE", "SHORT", "FLOAT", "FLOAT", "DOUBLE"));
rows("DOUBLE", "LONG", "INTEGER", "BYTE", "SHORT", "FLOAT", "HALF_FLOAT", "SCALED_FLOAT"));

response = executeQuery(String.format("source=%s | eval "
+ "`text` = typeof(text_value), `date` = typeof(date_value),"
+ "`boolean` = typeof(boolean_value), `object` = typeof(object_value),"
+ "`keyword` = typeof(keyword_value), `ip` = typeof(ip_value),"
+ "`binary` = typeof(binary_value), `geo_point` = typeof(geo_point_value)"
// TODO activate this test once `ARRAY` type supported, see ExpressionAnalyzer::isTypeNotSupported
//+ ", `nested` = typeof(nested_value)"
+ " | fields `text`, `date`, `boolean`, `object`, `keyword`, `ip`, `binary`, `geo_point`",
+ "`binary` = typeof(binary_value), `geo_point` = typeof(geo_point_value),"
+ "`nested` = typeof(nested_value)"
+ " | fields `text`, `date`, `boolean`, `object`, `keyword`, `ip`, `binary`, `geo_point`, `nested`",
TEST_INDEX_DATATYPE_NONNUMERIC));
verifyDataRows(response,
rows("TEXT", "TIMESTAMP", "BOOLEAN", "OBJECT", "KEYWORD",
"IP", "BINARY", "GEO_POINT"));
"IP", "BINARY", "GEO_POINT", "NESTED"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void ifnullWithNullInputTest() {
+ " WHERE balance is null limit 2", "jdbc"));

verifySchema(response,
schema("IFNULL(null, firstname)", "IFNULL1", "text"),
schema("IFNULL(null, firstname)", "IFNULL1", "keyword"),
schema("IFNULL(firstname, null)", "IFNULL2", "text"),
schema("IFNULL(null, null)", "IFNULL3", "byte"));
verifyDataRows(response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ public void typeof_opensearch_types() {
+ "typeof(float_number), typeof(half_float_number), typeof(scaled_float_number)"
+ " from %s;", TEST_INDEX_DATATYPE_NUMERIC));
verifyDataRows(response,
rows("DOUBLE", "LONG", "INTEGER", "BYTE", "SHORT", "FLOAT", "FLOAT", "DOUBLE"));
rows("DOUBLE", "LONG", "INTEGER", "BYTE", "SHORT", "FLOAT", "HALF_FLOAT", "SCALED_FLOAT"));

response = executeJdbcRequest(String.format("SELECT typeof(text_value),"
+ "typeof(date_value), typeof(boolean_value), typeof(object_value), typeof(keyword_value),"
+ "typeof(ip_value), typeof(binary_value), typeof(geo_point_value)"
// TODO activate this test once `ARRAY` type supported, see ExpressionAnalyzer::isTypeNotSupported
//+ ", typeof(nested_value)"
+ "typeof(ip_value), typeof(binary_value), typeof(geo_point_value), typeof(nested_value)"
+ " from %s;", TEST_INDEX_DATATYPE_NONNUMERIC));
verifyDataRows(response,
rows("TEXT", "TIMESTAMP", "BOOLEAN", "OBJECT", "KEYWORD",
"IP", "BINARY", "GEO_POINT"));
"IP", "BINARY", "GEO_POINT", "NESTED"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean equals(final Object o) {
}
OpenSearchDataType other = (OpenSearchDataType) o;
if (mappingType != null && other.mappingType != null) {
return mappingType.equals(other.mappingType);
return mappingType.equals(other.mappingType) && exprCoreType.equals(other.exprCoreType);
}
return exprCoreType.equals(other.exprCoreType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public void extendTypeMapping(Map<String, OpenSearchDataType> typeMapping) {
(c, dt) -> new ExprFloatValue(c.floatValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Double),
(c, dt) -> new ExprDoubleValue(c.doubleValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.HalfFloat),
(c, dt) -> new ExprFloatValue(c.floatValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.ScaledFloat),
(c, dt) -> new ExprDoubleValue(c.doubleValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Text),
(c, dt) -> new OpenSearchExprTextValue(c.stringValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Keyword),
Expand Down

0 comments on commit b8f84da

Please sign in to comment.