You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2022/06/21 14:05:43 UTC
[iotdb] 01/01: add semantic check
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/FillDebug
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b3b3070228715c021604350d9acc7813723174a4
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Tue Jun 21 15:05:21 2022 +0800
add semantic check
---
.../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 d1e3c4cdf8..2121da8ec6 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
@@ -61,7 +61,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;
@@ -398,14 +397,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(
@@ -854,15 +863,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) {