-
Notifications
You must be signed in to change notification settings - Fork 194
Support UDT for BINARY #3549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support UDT for BINARY #3549
Changes from all commits
c2b3508
3180d0b
1d47586
2227325
0225ae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.calcite.type; | ||
|
|
||
| import org.apache.calcite.sql.type.SqlTypeName; | ||
| import org.opensearch.sql.calcite.utils.OpenSearchTypeFactory; | ||
| import org.opensearch.sql.calcite.utils.OpenSearchTypeFactory.ExprUDT; | ||
|
|
||
| public class ExprBinaryType extends ExprSqlType { | ||
| public ExprBinaryType(OpenSearchTypeFactory typeFactory) { | ||
| super(typeFactory, ExprUDT.EXPR_BINARY, SqlTypeName.VARCHAR); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -14,9 +14,12 @@ | |||
| import static org.opensearch.sql.util.MatcherUtils.rows; | ||||
| import static org.opensearch.sql.util.MatcherUtils.schema; | ||||
| import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||||
| import static org.opensearch.sql.util.MatcherUtils.verifyDataRowsInOrder; | ||||
| import static org.opensearch.sql.util.MatcherUtils.verifySchema; | ||||
| import static org.opensearch.sql.util.MatcherUtils.verifySchemaInOrder; | ||||
|
|
||||
| import java.io.IOException; | ||||
| import org.json.JSONArray; | ||||
| import org.json.JSONObject; | ||||
| import org.junit.Test; | ||||
|
|
||||
|
|
@@ -48,18 +51,33 @@ public void test_numeric_data_types() throws IOException { | |||
| @Test | ||||
| public void test_nonnumeric_data_types() throws IOException { | ||||
| JSONObject result = executeQuery(String.format("source=%s", TEST_INDEX_DATATYPE_NONNUMERIC)); | ||||
| verifySchema( | ||||
| verifySchemaInOrder( | ||||
| result, | ||||
| schema("boolean_value", "boolean"), | ||||
| schema("keyword_value", "string"), | ||||
| schema("text_value", "string"), | ||||
| schema("binary_value", "binary"), | ||||
| schema("date_value", "timestamp"), | ||||
| schema("date_nanos_value", "timestamp"), | ||||
| schema("date_value", "timestamp"), | ||||
| schema("boolean_value", "boolean"), | ||||
| schema("ip_value", "ip"), | ||||
| schema("object_value", "struct"), | ||||
| schema("nested_value", "array"), | ||||
| schema("geo_point_value", "geo_point")); | ||||
| schema("object_value", "struct"), | ||||
| schema("keyword_value", "string"), | ||||
| schema("geo_point_value", "geo_point"), | ||||
| schema("binary_value", "binary")); | ||||
| verifyDataRowsInOrder( | ||||
| result, | ||||
| rows( | ||||
| "text", | ||||
| "2019-03-24 01:34:46.123456789", | ||||
| "2020-10-13 13:00:00", | ||||
| true, | ||||
| "127.0.0.1", | ||||
| new JSONArray( | ||||
| "[{\"last\": \"Smith\", \"first\": \"John\"}, {\"last\": \"White\", \"first\":" | ||||
| + " \"Alice\"}]"), | ||||
| new JSONObject("{\"last\": \"Dale\", \"first\": \"Dale\"}"), | ||||
| "keyword", | ||||
| new JSONObject("{\"lon\": 74, \"lat\": 40.71}"), | ||||
| "U29tZSBiaW5hcnkgYmxvYg==")); | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is current value without this PR?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the value V2 returned. For Calcite, it will throw exception. But this test was ignored in Calcite's IT previously so CI can pass.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback reason in Calcite's IT is outdated actually, we already have supported IP type. It's true reason is the incompatible BIANRY type. sql/integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteDataTypeIT.java Line 29 in 3c1591a
|
||||
| } | ||||
|
|
||||
| @Test | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Calcite impl required ExprCoreType mapping? Should we consider deprecated ExprCoreType in future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the current implementation it requires, because we will always populate the final results with ExprValue transformed from Calcite's results.
sql/opensearch/src/main/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngine.java
Line 215 in 3c1591a