Skip to content

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 <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
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

/** 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 <qianheng@amazon.com>
# Conflicts:
#	integ-test/src/test/java/org/opensearch/sql/calcite/remote/nonfallback/NonFallbackCalciteDataTypeIT.java
Signed-off-by: Heng Qian <qianheng@amazon.com>
@penghuo penghuo merged commit 15aeec7 into opensearch-project:main Apr 16, 2025
22 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
---------

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
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