This is an automated email from the ASF dual-hosted git repository. qiaojialin pushed a commit to branch fix_group_by_fill in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 81b42315519ab6f6c89439b6f49b526b4ef33ae0 Author: qiaojialin <[email protected]> AuthorDate: Tue May 26 16:10:30 2020 +0800 fix group by fill grammar and some logic.. --- .../apache/iotdb/db/qp/strategy/LogicalGenerator.java | 2 +- .../db/query/dataset/groupby/GroupByFillDataSet.java | 4 +++- .../org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java index 4da9f2d..01dde43 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java @@ -792,7 +792,7 @@ public class LogicalGenerator extends SqlBaseBaseListener { } } else { // previous until last if (ctx.previousUntilLastClause().DURATION() != null) { - long preRange = parseDuration(ctx.previousClause().DURATION().getText()); + long preRange = parseDuration(ctx.previousUntilLastClause().DURATION().getText()); fillTypes.put(dataType, new PreviousFill(preRange, true)); } else { fillTypes.put(dataType, new PreviousFill(defaultFillInterval, true)); diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByFillDataSet.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByFillDataSet.java index c751b14..29a779a 100644 --- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByFillDataSet.java +++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/GroupByFillDataSet.java @@ -63,7 +63,9 @@ public class GroupByFillDataSet extends QueryDataSet { for (int i = 0; i < paths.size(); i++) { Path path = paths.get(i); TSDataType dataType = dataTypes.get(i); - IFill fill = new PreviousFill(dataType, groupByEngineDataSet.getStartTime(), -1L); + IFill fill = new PreviousFill(dataType, groupByEngineDataSet.getStartTime(), + ((PreviousFill) fillTypes.get(dataType)).getBeforeRange(), + ((PreviousFill) fillTypes.get(dataType)).isUntilLast()); fill.configureFill(path, dataType, groupByEngineDataSet.getStartTime(), groupByFillPlan.getAllMeasurementsInDevice(path.getDevice()), context); TimeValuePair timeValuePair = fill.getFillResult(); diff --git a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java index 97266c1..e150032 100644 --- a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java +++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java @@ -374,6 +374,25 @@ public class PhysicalPlanTest { } @Test + public void testGroupByFill7() { + String sqlStr = + "select last_value(d1.s1), last_value(d2.s1)" + " from root.vehicle " + + "group by([8,737), 3ms) fill(int32[previousuntillast,10ms], int64[previous,10ms])"; + try { + PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr); + if (!plan.isQuery()) { + fail(); + } + if (!(plan instanceof GroupByFillPlan)) { + fail(); + } + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + @Test public void testQuery1() throws QueryProcessException { String sqlStr = "SELECT s1 FROM root.vehicle.d1 WHERE time > 5000"; PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr);
