-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move function definition in ANTLR grammar into a separate group; * Move SQL integration tests outside of legacy block; * Extend integration tests. Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
- Loading branch information
1 parent
0bb6997
commit d02e16f
Showing
8 changed files
with
99 additions
and
23 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
58 changes: 58 additions & 0 deletions
58
integ-test/src/test/java/org/opensearch/sql/sql/SystemFunctionIT.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,58 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NONNUMERIC; | ||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DATATYPE_NUMERIC; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
public class SystemFunctionIT extends SQLIntegTestCase { | ||
|
||
@Override | ||
protected void init() throws Exception { | ||
loadIndex(Index.DATA_TYPE_NONNUMERIC); | ||
loadIndex(Index.DATA_TYPE_NUMERIC); | ||
} | ||
|
||
@Test | ||
public void typeof_sql_types() { | ||
JSONObject response = executeJdbcRequest("SELECT typeof('pewpew'), typeof(NULL), typeof(1.0)," | ||
+ "typeof(12345), typeof(1234567891011), typeof(INTERVAL 2 DAY);"); | ||
verifyDataRows(response, | ||
rows("STRING", "UNDEFINED", "DOUBLE", "INTEGER", "LONG", "INTERVAL")); | ||
|
||
response = executeJdbcRequest("SELECT" | ||
+ " typeof(CAST('1961-04-12 09:07:00' AS TIMESTAMP))," | ||
+ " typeof(CAST('09:07:00' AS TIME))," | ||
+ " typeof(CAST('1961-04-12' AS DATE))," | ||
+ " typeof(DATETIME('1961-04-12 09:07:00'))"); | ||
verifyDataRows(response, | ||
rows("TIMESTAMP", "TIME", "DATE", "DATETIME")); | ||
} | ||
|
||
@Test | ||
public void typeof_opensearch_types() { | ||
JSONObject response = executeJdbcRequest(String.format("SELECT typeof(double_number)," | ||
+ "typeof(long_number), typeof(integer_number), typeof(byte_number), typeof(short_number)," | ||
+ "typeof(float_number), typeof(half_float_number), typeof(scaled_float_number)" | ||
+ " from %s;", TEST_INDEX_DATATYPE_NUMERIC)); | ||
verifyDataRows(response, | ||
rows("DOUBLE", "LONG", "INTEGER", "BYTE", "SHORT", "FLOAT", "FLOAT", "DOUBLE")); | ||
|
||
response = executeJdbcRequest(String.format("SELECT typeof(text_value)," | ||
+ "typeof(date_value), typeof(boolean_value), typeof(object_value), typeof(keyword_value)" | ||
// TODO activate these tests once `typeof` fixed to recognize `OpenSearchDataType` | ||
//+ "typeof(ip_value), typeof(nested_value), typeof(binary_value)" | ||
+ " from %s;", TEST_INDEX_DATATYPE_NONNUMERIC)); | ||
verifyDataRows(response, | ||
rows("STRING", "TIMESTAMP", "BOOLEAN", "STRUCT", "STRING")); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{"index":{"_id":"1"}} | ||
{"boolean_value": true, "keyword_value": "keyword", "text_value": "text", "binary_value": "U29tZSBiaW5hcnkgYmxvYg==", "date_value": "2020-10-13 13:00:00", "ip_value": "127.0.0.0.1", "object_value": {"first": "Dale", "last": "Dale"}, "nested_value": [{"first" : "John", "last" : "Smith"}, {"first" : "Alice", "last" : "White"}} | ||
{"boolean_value": true, "keyword_value": "keyword", "text_value": "text", "binary_value": "U29tZSBiaW5hcnkgYmxvYg==", "date_value": "2020-10-13 13:00:00", "ip_value": "127.0.0.1", "object_value": {"first": "Dale", "last": "Dale"}, "nested_value": [{"first" : "John", "last" : "Smith"}, {"first" : "Alice", "last" : "White"}]} |
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