Skip to content

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

Merged
merged 5 commits into from
Apr 16, 2025
Merged

Conversation

qianheng-aws
Copy link
Collaborator

Description

We previous transform OpenSearch binary type to Calcite's SqlTypeName.BINARY. However, OpenSearch stores binary value as string while Calcite stores it as ByteString, the gap will lead to execution error if transforming directly.

This PR fixes it by viewing our OpenSearch binary type as a new UDT, which maps to SqlTypeName.VARCHAR

Related Issues

Resolves #3548

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
@@ -60,6 +61,21 @@ public void test_nonnumeric_data_types() throws IOException {
schema("object_value", "struct"),
schema("nested_value", "array"),
schema("geo_point_value", "geo_point"));
verifyDataRows(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change verifySchema to verifySchemaInOrder and verifyDataRows to verifyDataRowsInOrder for this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -51,6 +51,8 @@ public enum ExprCoreType implements ExprType {
/** Geometry. Only support point now. */
GEO_POINT(UNDEFINED),

BINARY(UNDEFINED),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

ExprType exprType = convertRelDataTypeToExprType(fieldType);

new JSONObject("{\"last\": \"Dale\", \"first\": \"Dale\"}"),
"keyword",
new JSONObject("{\"lon\": 74, \"lat\": 40.71}"),
"U29tZSBiaW5hcnkgYmxvYg=="));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is current value without this PR?

Copy link
Collaborator Author

@qianheng-aws qianheng-aws Apr 16, 2025

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

@qianheng-aws qianheng-aws Apr 16, 2025

Choose a reason for hiding this comment

The 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.

"ignore this class since IP type is unsupported in calcite engine");

Signed-off-by: Heng Qian <[email protected]>
# Conflicts:
#	integ-test/src/test/java/org/opensearch/sql/calcite/remote/nonfallback/NonFallbackCalciteDataTypeIT.java
@penghuo penghuo merged commit 15aeec7 into opensearch-project:main Apr 16, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Calcite Engine: Support BINARY type
3 participants