-
Notifications
You must be signed in to change notification settings - Fork 141
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
Merged
YANG-DB
merged 26 commits into
opensearch-project:main
from
Bit-Quill:opensearch-sql-3145
Dec 19, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a8da96d
Add `ExprIpValue` and `IP` data type
currantw 19b9100
Add support for casting (`cast(field_name to ip)`) and remove existin…
currantw f842ddb
Update comparison logic to compare in IPv6
currantw 16b1825
Fix bug casting to IP
currantw 8e33635
Fix failing tests
currantw 24aa29e
Assert that comparison only valid if same type, update tests accordingly
currantw 021b727
Add additional tests to increase code coverage
currantw d203425
Integrate `cidrmatch` changes
currantw aadc8f8
Remove `OpenSearchIPType` data type
currantw 1aed13e
Fix more failing tests
currantw 47746e4
Minor cleanup
currantw d03bd4f
Add new tests for IP data type to `SortCommandIT`, and update `weblog…
currantw 7569d08
Fixing IT test failure.
currantw bfcd86d
Spotless and update test to sort in SQL
currantw 9cd9817
Fix broken link
currantw 8c52d2b
Fix failing code coverage
currantw 0278f0b
Fix failing doctest
currantw f0d4f6d
Fix failing `ip.rst` doctest
currantw 774861b
Fix test failure due to merge.
currantw a2ec8cf
Fix spotless
currantw 7036e5f
Add missing `url` field
currantw ac9c300
Address minor review comments.
currantw 6355b2d
Revert sort syntax changes
currantw b8bf9b8
Minor doc update
currantw 5298b38
FIx failing `ip.rst` doctest
currantw 4718848
Add `IPComparisonIT` tests for comparison operators, rename modules a…
currantw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/src/main/java/org/opensearch/sql/data/model/ExprIpValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.data.model; | ||
|
||
import inet.ipaddr.IPAddress; | ||
import org.opensearch.sql.data.type.ExprCoreType; | ||
import org.opensearch.sql.data.type.ExprType; | ||
import org.opensearch.sql.utils.IPUtils; | ||
|
||
/** Expression IP Address Value. */ | ||
public class ExprIpValue extends AbstractExprValue { | ||
private final IPAddress value; | ||
|
||
public ExprIpValue(String addressString) { | ||
value = IPUtils.toAddress(addressString); | ||
} | ||
|
||
@Override | ||
public String value() { | ||
return value.toCanonicalString(); | ||
} | ||
|
||
@Override | ||
public ExprType type() { | ||
return ExprCoreType.IP; | ||
} | ||
|
||
@Override | ||
public int compare(ExprValue other) { | ||
return IPUtils.compare(value, ((ExprIpValue) other).value); | ||
} | ||
|
||
@Override | ||
public boolean equal(ExprValue other) { | ||
return compare(other) == 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("IP %s", value()); | ||
} | ||
|
||
@Override | ||
public IPAddress ipValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@currantw just making sure - why was changed ?
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.
Noticed while reading through this that
Doctest.md
no longer exists, so corrected the link.