You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/09/17 03:10:43 UTC
[iotdb] branch nested-operations updated (0560e67 -> 394c540)
This is an automated email from the ASF dual-hosted git repository.
rong pushed a change to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git.
from 0560e67 add tests: testNestedRowByRowUDFExpressions & testNestedArithmeticExpressions
new 4528ad0 fix function name parsing errors
new 394c540 fix tests
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 | 7 +++++-
.../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 4 ++--
.../iotdb/db/integration/IoTDBNestedQueryIT.java | 28 ++++++++++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)
[iotdb] 02/02: fix tests
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 394c540c13edef67f86107395c84a65d73425406
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Fri Sep 17 11:09:56 2021 +0800
fix tests
---
.../iotdb/db/integration/IoTDBNestedQueryIT.java | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBNestedQueryIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBNestedQueryIT.java
index 5f455c9..3366db8 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBNestedQueryIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBNestedQueryIT.java
@@ -173,4 +173,32 @@ public class IoTDBNestedQueryIT {
fail(throwable.getMessage());
}
}
+
+ @Test
+ public void testUDFTerminateMethodInNestedExpressions() {
+ String sqlStr =
+ "select bottom_k(top_k(top_k(s1 + s1 / s1 - s2 / s1, 'k'='100'), 'k'='1'), 'k'='1'), top_k(top_k(s1 + s1 / s1 - s2 / s1, 'k'='100'), 'k'='1'), top_k(s1 + s1 / s1 - s2 / s1, 'k'='1'), top_k(s1, 'k'='1'), top_k(s2, 'k'='1') from root.vehicle.d2";
+
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ ResultSet resultSet = statement.executeQuery(sqlStr);
+
+ assertEquals(1 + 5, resultSet.getMetaData().getColumnCount());
+
+ int count = 0;
+ while (resultSet.next()) {
+ ++count;
+ assertEquals(ITERATION_TIMES, Double.parseDouble(resultSet.getString(1)), 1e-5);
+ assertEquals(ITERATION_TIMES, Double.parseDouble(resultSet.getString(2)), 1e-5);
+ assertEquals(ITERATION_TIMES, Double.parseDouble(resultSet.getString(3)), 1e-5);
+ assertEquals(ITERATION_TIMES, Double.parseDouble(resultSet.getString(4)), 1e-5);
+ assertEquals(ITERATION_TIMES, Double.parseDouble(resultSet.getString(5)), 1e-5);
+ }
+ assertEquals(1, count);
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
}
[iotdb] 01/02: fix function name parsing errors
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 4528ad021ecd175702bd587f2ba83093e3e5f25b
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Fri Sep 17 10:53:44 2021 +0800
fix function name parsing errors
---
antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 | 7 ++++++-
.../src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 4 ++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
index d0d4185..e55645c 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
@@ -128,11 +128,16 @@ expression
| (PLUS | MINUS) unaryAfterSign=expression
| leftExpression=expression (STAR | DIV | MOD) rightExpression=expression
| leftExpression=expression (PLUS | MINUS) rightExpression=expression
- | functionName=ID LR_BRACKET expression (COMMA expression)* functionAttribute* RR_BRACKET
+ | functionName LR_BRACKET expression (COMMA expression)* functionAttribute* RR_BRACKET
| suffixPath
| literal=SINGLE_QUOTE_STRING_LITERAL
;
+functionName
+ : ID
+ | COUNT
+ ;
+
functionAttribute
: COMMA functionAttributeKey=stringLiteral OPERATOR_EQ functionAttributeValue=stringLiteral
;
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 5e611ff..92a9629 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -1368,7 +1368,7 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> {
// functionName=suffixPath LR_BRACKET expression (COMMA expression)* functionAttribute*
// RR_BRACKET
- if (context.functionName != null) {
+ if (context.functionName() != null) {
return parseFunctionExpression(context);
}
@@ -1387,7 +1387,7 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> {
private Expression parseFunctionExpression(ExpressionContext functionClause) {
FunctionExpression functionExpression =
- new FunctionExpression(functionClause.functionName.getText());
+ new FunctionExpression(functionClause.functionName().getText());
// expressions
for (ExpressionContext expression : functionClause.expression()) {