Skip to content
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

#3145 Add IP Address Data Type #3175

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

currantw
Copy link
Contributor

@currantw currantw commented Nov 29, 2024

Signed-off-by: currantw [email protected]

Description

#3145 Add IP Address Data Type

Related Issues

Resolves #3145
#3036

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.

YANG-DB
YANG-DB previously approved these changes Dec 6, 2024
@YANG-DB
Copy link
Member

YANG-DB commented Dec 6, 2024

@currantw can we test an IP range query as well?
With operations such as < and in range

@currantw currantw closed this Dec 10, 2024
@currantw currantw reopened this Dec 10, 2024
@currantw
Copy link
Contributor Author

Woops! Didn't mean to close this... 😬

@YANG-DB
Copy link
Member

YANG-DB commented Dec 10, 2024

@currantw can u plz resolve conflicts ?

@currantw
Copy link
Contributor Author

@currantw can we test an IP range query as well? With operations such as < and in range

I have added a test to SortCommandIT for testing sorting of the IP address. There are also unit tests in ExprIpValueTest that test compareTo.

Let me know which additional tests you think may be needed. I didn't find any existing integration tests for comparisons -- perhaps this is something that should be added?

I'm not sure exactly what you mean by "in range" operations: can you give an example query?

YANG-DB
YANG-DB previously approved these changes Dec 11, 2024
@YANG-DB
Copy link
Member

YANG-DB commented Dec 11, 2024

@currantw LGTM 👍
@penghuo @dai-chen @acarbonetto could u plz review ?

@YANG-DB
Copy link
Member

YANG-DB commented Dec 11, 2024

@currantw can u plz check the failed CI plz ?

Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
@currantw currantw force-pushed the opensearch-sql-3145 branch from 3f9e428 to b45114a Compare December 13, 2024 07:26
: (PLUS | MINUS)? sortFieldExpression
;

sortFieldExpression
Copy link
Member

Choose a reason for hiding this comment

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

@currantw was this sortFieldExpression used in a query anywhere ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it is used in sortField, which is used by Trendline and SORT BY. @currantw we sure we want to include these changes?

public class ExprIpValue extends AbstractExprValue {
private final IPAddress value;

public ExprIpValue(String s) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
public ExprIpValue(String s) {
public ExprIpValue(String addressStr) {

}

return ExprValueUtils.booleanValue(range.contains(address));
return ExprValueUtils.LITERAL_TRUE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

return (IPUtils.compare(address, range.getLower()) < 0) || (IPUtils.compare(address, range.getUpper()) > 0) ? ExprValueUtils.LITERAL_FALSE : ExprValueUtils.LITERAL_TRUE;

private static DefaultFunctionResolver castToIp() {
return FunctionDSL.define(
BuiltinFunctionName.CAST_TO_IP.getName(),
impl(nullMissingHandling((v) -> v), IP, IP),
Copy link
Collaborator

Choose a reason for hiding this comment

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

ordering matters - make sure to but the naive cast last

}

private static final double TOLERANCE = 1E-5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did you move this?

void test_non_date_field_type() {
String dateString = "2021-11-08";
void test_string_field_type() {
String dateString = "STRING";
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert?

AUTO: 'AUTO';
STR: 'STR';
IP: 'IP';
NUM: 'NUM';
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert?

: (PLUS | MINUS)? sortFieldExpression
;

sortFieldExpression
Copy link
Collaborator

Choose a reason for hiding this comment

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

it is used in sortField, which is used by Trendline and SORT BY. @currantw we sure we want to include these changes?

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] Add Support for IP Data Type
3 participants