-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1196) (#1294) * Extend comparison methods to accept different datetime types. (#129) * Extend comparison methods to accept different datetime types. Signed-off-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]> * Typo fix. Signed-off-by: Yury-Fridlyand <[email protected]> * Rework fix according to @dai-chen's comment. #1196 (review) * Revert `BinaryPredicateOperator`. * Add automatic cast rules `DATE`/`TIME`/`DATETIME` -> `DATETIME`/TIMESTAMP`. * Update unit tests. Signed-off-by: Yury-Fridlyand <[email protected]> * Add doctest sample. Signed-off-by: Yury-Fridlyand <[email protected]> * Docs typo fix. Signed-off-by: Yury-Fridlyand <[email protected]> * Minor comments update. Signed-off-by: Yury-Fridlyand <[email protected]> * Doctest typo fix. Signed-off-by: Yury-Fridlyand <[email protected]> * Doctest typo fix. Signed-off-by: Yury-Fridlyand <[email protected]> * Doctest typo fix. Signed-off-by: Yury-Fridlyand <[email protected]> * Modify `ExprCoreType` dependencies. Signed-off-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]> (cherry picked from commit a4f8066) Co-authored-by: Yury-Fridlyand <[email protected]>
- Loading branch information
1 parent
db9be18
commit 982d366
Showing
19 changed files
with
1,796 additions
and
104 deletions.
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
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
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
60 changes: 60 additions & 0 deletions
60
core/src/test/java/org/opensearch/sql/data/model/ExprStringValueTest.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,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.data.model; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.opensearch.sql.data.type.ExprCoreType.STRING; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.sql.exception.ExpressionEvaluationException; | ||
|
||
public class ExprStringValueTest { | ||
@Test | ||
public void equals_to_self() { | ||
ExprValue string = ExprValueUtils.stringValue("str"); | ||
assertEquals(string.stringValue(), "str"); | ||
assertTrue(string.equals(string)); | ||
} | ||
|
||
@Test | ||
public void equal() { | ||
ExprValue v1 = new ExprStringValue("str"); | ||
ExprValue v2 = ExprValueUtils.stringValue("str"); | ||
assertTrue(v1.equals(v2)); | ||
assertTrue(v2.equals(v1)); | ||
assertEquals(0, ((ExprStringValue)v1).compare((ExprStringValue)v2)); | ||
assertEquals(0, ((ExprStringValue)v2).compare((ExprStringValue)v1)); | ||
} | ||
|
||
@Test | ||
public void compare() { | ||
ExprStringValue v1 = new ExprStringValue("str1"); | ||
ExprStringValue v2 = new ExprStringValue("str2"); | ||
assertEquals(-1, v1.compare(v2)); | ||
assertEquals(1, v2.compare(v1)); | ||
} | ||
|
||
@Test | ||
public void invalid_get_value() { | ||
ExprDateValue value = new ExprDateValue("2020-08-20"); | ||
assertThrows(ExpressionEvaluationException.class, value::stringValue, | ||
String.format("invalid to get intervalValue from value of type %s", value.type())); | ||
} | ||
|
||
@Test | ||
public void value() { | ||
ExprValue value = new ExprStringValue("string"); | ||
assertEquals("string", value.value()); | ||
} | ||
|
||
@Test | ||
public void type() { | ||
ExprValue value = new ExprStringValue("string"); | ||
assertEquals(STRING, value.type()); | ||
} | ||
} |
Oops, something went wrong.