This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new ff5a14a86d [IOTDB-3577] Add semantic checks for linear fill (#6372)
ff5a14a86d is described below
commit ff5a14a86d55e73238144caf9c8937fa7c0319f3
Author: liuminghui233 <[email protected]>
AuthorDate: Wed Jun 22 08:29:06 2022 +0800
[IOTDB-3577] Add semantic checks for linear fill (#6372)
---
.../apache/iotdb/db/mpp/plan/analyze/Analyzer.java | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
index 00ef240329..4314c8faeb 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
@@ -62,7 +62,6 @@ import
org.apache.iotdb.db.mpp.plan.statement.crud.QueryStatement;
import
org.apache.iotdb.db.mpp.plan.statement.internal.InternalCreateTimeSeriesStatement;
import org.apache.iotdb.db.mpp.plan.statement.internal.LastPointFetchStatement;
import org.apache.iotdb.db.mpp.plan.statement.internal.SchemaFetchStatement;
-import org.apache.iotdb.db.mpp.plan.statement.literal.Literal;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.AlterTimeSeriesStatement;
import org.apache.iotdb.db.mpp.plan.statement.metadata.CountDevicesStatement;
import
org.apache.iotdb.db.mpp.plan.statement.metadata.CountLevelTimeSeriesStatement;
@@ -401,14 +400,24 @@ public class Analyzer {
if (queryStatement.getFillComponent() != null) {
FillComponent fillComponent = queryStatement.getFillComponent();
+ List<Expression> fillColumnList =
+
outputExpressions.stream().map(Pair::getLeft).distinct().collect(Collectors.toList());
if (fillComponent.getFillPolicy() == FillPolicy.VALUE) {
- List<Expression> fillColumnList =
- outputExpressions.stream()
- .map(Pair::getLeft)
- .distinct()
- .collect(Collectors.toList());
for (Expression fillColumn : fillColumnList) {
- checkDataTypeConsistencyInFill(fillColumn,
fillComponent.getFillValue());
+ TSDataType checkedDataType =
typeProvider.getType(fillColumn.getExpressionString());
+ if
(!fillComponent.getFillValue().isDataTypeConsistency(checkedDataType)) {
+ throw new SemanticException(
+ "FILL: the data type of the fill value should be the same
as the output column");
+ }
+ }
+ } else if (fillComponent.getFillPolicy() == FillPolicy.LINEAR) {
+ for (Expression fillColumn : fillColumnList) {
+ TSDataType checkedDataType =
typeProvider.getType(fillColumn.getExpressionString());
+ if (!checkedDataType.isNumeric()) {
+ throw new SemanticException(
+ String.format(
+ "FILL: dataType %s doesn't support linear fill.",
checkedDataType));
+ }
}
}
analysis.setFillDescriptor(
@@ -857,15 +866,6 @@ public class Analyzer {
}
}
- private void checkDataTypeConsistencyInFill(Expression fillColumn, Literal
fillValue) {
- TSDataType checkedDataType =
typeProvider.getType(fillColumn.getExpressionString());
- if (!fillValue.isDataTypeConsistency(checkedDataType)) {
- // TODO: consider type casting
- throw new SemanticException(
- "FILL: the data type of the fill value should be the same as the
output column");
- }
- }
-
@Override
public Analysis visitLastPointFetch(
LastPointFetchStatement statement, MPPQueryContext context) {