Skip to content

Conversation

@yuancu
Copy link
Collaborator

@yuancu yuancu commented May 6, 2025

Description

Implement CIDRMATCH on Calcite engine with a UDF

Issues Resolved

Resolves #3505

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

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: Yuanchun Shen <yuanchu@amazon.com>
@yuancu yuancu changed the title Implementcidrmatch udf Implement cidrmatch udf May 6, 2025
@yuancu yuancu changed the title Implement cidrmatch udf Implement cidrmatch UDF May 6, 2025
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
@yuancu yuancu marked this pull request as ready for review May 6, 2025 09:51
@yuancu yuancu changed the title Implement cidrmatch UDF Implement cidrmatch udf with Calcite May 6, 2025
@noCharger noCharger added the calcite calcite migration releated label May 6, 2025
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
qianheng-aws
qianheng-aws previously approved these changes May 8, 2025
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
@yuancu yuancu requested a review from qianheng-aws May 20, 2025 02:20
Usage: `cidrmatch(ip, cidr)` checks if `ip` is within the specified `cidr` range.

Argument type: STRING, STRING
Argument type: STRING/IP, STRING
Copy link
Member

Choose a reason for hiding this comment

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

Is the IP argument supported in v2?

Copy link
Collaborator Author

@yuancu yuancu May 21, 2025

Choose a reason for hiding this comment

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

Yes. I've tested. It doesn't work in v2.19 but works in v3.1.0 with calcite disabled.

According to the implementation at IPFunctions.java#L36, IP is the only supported argument type. Strings may be cast to IP.

The documentation may be out of date since the IP's PR came later that cidrmatch's PR. cidrmatch is implemented in #3110; IP data type is added in #3145 .

@LantaoJin LantaoJin merged commit 730f066 into opensearch-project:main May 22, 2025
22 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* Implement cidrmatch UDF

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Add class documentation for cidrmatch udf

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Update cidrmatch doc: add IP as an acceptable parameter type

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

---------

Signed-off-by: Yuanchun Shen <yuanchu@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

calcite calcite migration releated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][Calcite engine] Support function cidrmatch

5 participants