From 826e85b3cda3b4cb61aa4bef3e151b608856bf82 Mon Sep 17 00:00:00 2001 From: jzl18thu Date: Sat, 9 Nov 2024 10:00:54 +0800 Subject: [PATCH] fix(sql): fix filter in sql with tagKV (#478) fix filter in sql with tagKV to enable the support of TSBS --- .../logical/generator/QueryGenerator.java | 9 +- .../naive/NaiveOperatorMemoryExecutor.java | 40 + .../memory/execute/utils/FilterUtils.java | 14 +- .../iginx/engine/shared/data/read/Header.java | 4 +- .../shared/operator/RemoveNullColumn.java | 53 + .../shared/operator/type/OperatorType.java | 1 + .../iginx/influxdb/InfluxDBStorage.java | 22 +- .../tsinghua/iginx/iotdb/IoTDBStorage.java | 50 +- .../iginx/relational/RelationalStorage.java | 118 +- .../integration/func/session/PySessionIT.java | 26 +- .../integration/func/session/SessionIT.java | 5 +- .../integration/func/sql/SQLSessionIT.java | 1424 +++++++++-------- .../iginx/integration/func/tag/TagIT.java | 177 +- .../iginx/integration/func/udf/UDFIT.java | 38 +- 14 files changed, 1114 insertions(+), 867 deletions(-) create mode 100644 core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/RemoveNullColumn.java diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/logical/generator/QueryGenerator.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/logical/generator/QueryGenerator.java index 984ecbf0bb..e2c5d7c963 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/logical/generator/QueryGenerator.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/logical/generator/QueryGenerator.java @@ -115,7 +115,14 @@ protected Operator generateRoot(Statement statement) { root = new Rename(new OperatorSource(root), cte.getAliasList()); cte.setRoot(root); }); - return generateRoot(selectStatement); + + // 计算语句的操作符树 + Operator root = generateRoot(selectStatement); + + // 去除最终结果的空列 + root = new RemoveNullColumn(new OperatorSource(root)); + + return root; } private Operator generateRoot(SelectStatement selectStatement) { diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/naive/NaiveOperatorMemoryExecutor.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/naive/NaiveOperatorMemoryExecutor.java index 9e9dc54446..23e6f6c3ff 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/naive/NaiveOperatorMemoryExecutor.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/naive/NaiveOperatorMemoryExecutor.java @@ -142,6 +142,8 @@ public RowStream executeUnaryOperator( return executeGroupBy((GroupBy) operator, table); case AddSequence: return executeAddSequence((AddSequence) operator, table); + case RemoveNullColumn: + return executeRemoveNullColumn(table); case Distinct: return executeDistinct((Distinct) operator, table); case ValueToSelectedPath: @@ -568,6 +570,44 @@ private RowStream executeDistinct(Distinct distinct, Table table) throws Physica return new Table(newHeader, targetRows); } + private RowStream executeRemoveNullColumn(Table table) { + Header header = table.getHeader(); + int fieldSize = header.getFieldSize(); + List rows = table.getRows(); + + List remainIndexes = new ArrayList<>(); + for (int i = 0; i < fieldSize; i++) { + int finalI = i; + boolean isEmptyColumn = rows.stream().allMatch(row -> row.getValue(finalI) == null); + if (!isEmptyColumn) { + remainIndexes.add(finalI); + } + } + + int remainColumnSize = remainIndexes.size(); + if (remainColumnSize == fieldSize) { // 没有空列 + return table; + } else if (remainIndexes.isEmpty()) { // 全是空列 + return rows.isEmpty() ? table : Table.EMPTY_TABLE; + } + + List newFields = new ArrayList<>(remainColumnSize); + for (int index : remainIndexes) { + newFields.add(header.getField(index)); + } + Header newHeader = new Header(header.getKey(), newFields); + + List newRows = new ArrayList<>(); + for (Row row : rows) { + Object[] values = new Object[remainColumnSize]; + for (int i = 0; i < remainColumnSize; i++) { + values[i] = row.getValue(remainIndexes.get(i)); + } + newRows.add(new Row(newHeader, row.getKey(), values)); + } + return new Table(newHeader, newRows); + } + private RowStream executeValueToSelectedPath(ValueToSelectedPath operator, Table table) { String prefix = operator.getPrefix(); boolean prefixIsEmpty = prefix.isEmpty(); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/utils/FilterUtils.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/utils/FilterUtils.java index 51608b9473..c34d771bbe 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/utils/FilterUtils.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/physical/memory/execute/utils/FilterUtils.java @@ -64,7 +64,7 @@ public static boolean validate(Filter filter, Row row) throws PhysicalException if (row.getKey() == Row.NON_EXISTED_KEY) { return false; } - return validateTimeFilter(keyFilter, row); + return validateKeyFilter(keyFilter, row); case Value: ValueFilter valueFilter = (ValueFilter) filter; return validateValueFilter(valueFilter, row); @@ -125,7 +125,7 @@ private static boolean validateInFilter(InFilter inFilter, Row row) { } } - private static boolean validateTimeFilter(KeyFilter keyFilter, Row row) { + private static boolean validateKeyFilter(KeyFilter keyFilter, Row row) { long timestamp = row.getKey(); switch (keyFilter.getOp()) { case E: @@ -161,8 +161,8 @@ private static boolean validateValueFilter(ValueFilter valueFilter, Row row) return false; } - if (path.contains("*")) { // 带通配符的filter - List valueList = row.getAsValueByPattern(path); + List valueList = row.getAsValueByPattern(path); + if (valueList.size() > 1) { // filter的路径名带通配符或同一列名有多个tag if (Op.isOrOp(valueFilter.getOp())) { for (Value value : valueList) { if (value == null || value.isNull()) { @@ -186,12 +186,14 @@ private static boolean validateValueFilter(ValueFilter valueFilter, Row row) } else { throw new IllegalArgumentException("Unknown op type: " + valueFilter.getOp()); } - } else { - Value value = row.getAsValue(path); + } else if (valueList.size() == 1) { + Value value = valueList.get(0); if (value == null || value.isNull()) { // value是空值,则认为不可比较 return false; } return validateValueCompare(valueFilter.getOp(), value, targetValue); + } else { + return false; } } diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/data/read/Header.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/data/read/Header.java index a427238faa..af6940bd37 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/data/read/Header.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/data/read/Header.java @@ -108,7 +108,7 @@ public List patternIndexOf(String pattern) { List indexList = new ArrayList<>(); fields.forEach( field -> { - if (Pattern.matches(StringUtils.reformatPath(pattern), field.getFullName())) { + if (Pattern.matches(StringUtils.reformatPath(pattern), field.getName())) { indexList.add(indexOf(field.getFullName())); } }); @@ -119,7 +119,7 @@ public List patternIndexOf(String pattern) { @Override public String toString() { - return "Header{" + "time=" + key + ", fields=" + fields + '}'; + return "Header{" + "key=" + key + ", fields=" + fields + '}'; } @Override diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/RemoveNullColumn.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/RemoveNullColumn.java new file mode 100644 index 0000000000..6ebadf01c0 --- /dev/null +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/RemoveNullColumn.java @@ -0,0 +1,53 @@ +/* + * IGinX - the polystore system with high performance + * Copyright (C) Tsinghua University + * TSIGinX@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package cn.edu.tsinghua.iginx.engine.shared.operator; + +import cn.edu.tsinghua.iginx.engine.shared.operator.type.OperatorType; +import cn.edu.tsinghua.iginx.engine.shared.source.Source; + +public class RemoveNullColumn extends AbstractUnaryOperator { + + public RemoveNullColumn(Source source) { + super(OperatorType.RemoveNullColumn, source); + } + + @Override + public Operator copy() { + return new RemoveNullColumn(getSource().copy()); + } + + @Override + public UnaryOperator copyWithSource(Source source) { + return new RemoveNullColumn(source); + } + + @Override + public String getInfo() { + return "RemoveNullColumn"; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + return object != null && getClass() == object.getClass(); + } +} diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/type/OperatorType.java b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/type/OperatorType.java index 0d430d8045..80547b224a 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/type/OperatorType.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/engine/shared/operator/type/OperatorType.java @@ -66,6 +66,7 @@ public enum OperatorType { GroupBy, Distinct, AddSequence, + RemoveNullColumn, ProjectWaitingForPath, ValueToSelectedPath; diff --git a/dataSource/influxdb/src/main/java/cn/edu/tsinghua/iginx/influxdb/InfluxDBStorage.java b/dataSource/influxdb/src/main/java/cn/edu/tsinghua/iginx/influxdb/InfluxDBStorage.java index 450f621b4d..0bca3a2c83 100644 --- a/dataSource/influxdb/src/main/java/cn/edu/tsinghua/iginx/influxdb/InfluxDBStorage.java +++ b/dataSource/influxdb/src/main/java/cn/edu/tsinghua/iginx/influxdb/InfluxDBStorage.java @@ -25,6 +25,7 @@ import cn.edu.tsinghua.iginx.engine.logical.utils.LogicalFilterUtils; import cn.edu.tsinghua.iginx.engine.physical.exception.PhysicalException; import cn.edu.tsinghua.iginx.engine.physical.exception.StorageInitializationException; +import cn.edu.tsinghua.iginx.engine.physical.memory.execute.utils.FilterUtils; import cn.edu.tsinghua.iginx.engine.physical.storage.IStorage; import cn.edu.tsinghua.iginx.engine.physical.storage.domain.Column; import cn.edu.tsinghua.iginx.engine.physical.storage.domain.DataArea; @@ -73,6 +74,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -623,7 +625,12 @@ private String generateQueryStatement( statement += filterStr; } - if (filter != null) { + // TODO:filter中的path有多个tag时暂未实现下推 + List filterPaths = FilterUtils.getAllPathsFromFilter(filter); + List columns = getColumns(new HashSet<>(filterPaths), tagFilter); + boolean hasMultiTags = hasMultiTags(columns); + + if (filter != null && !hasMultiTags) { boolean patternHasMeasurementWildCards = false; for (String path : paths) { if (path.startsWith("*")) { @@ -687,6 +694,19 @@ private String generateQueryStatement( return statement; } + private boolean hasMultiTags(List columns) { + Map>> tagsMap = new HashMap<>(); + for (Column column : columns) { + String path = column.getPath(); + if (!tagsMap.containsKey(path)) { + tagsMap.put(path, new ArrayList<>(Collections.singletonList(column.getTags()))); + } else if (!tagsMap.get(path).contains(column.getTags())) { + return true; + } + } + return false; + } + private Filter setTrueByMeasurement(Filter filter, String measurementName) { switch (filter.getType()) { case And: diff --git a/dataSource/iotdb12/src/main/java/cn/edu/tsinghua/iginx/iotdb/IoTDBStorage.java b/dataSource/iotdb12/src/main/java/cn/edu/tsinghua/iginx/iotdb/IoTDBStorage.java index 0314bf967b..12c16d6722 100644 --- a/dataSource/iotdb12/src/main/java/cn/edu/tsinghua/iginx/iotdb/IoTDBStorage.java +++ b/dataSource/iotdb12/src/main/java/cn/edu/tsinghua/iginx/iotdb/IoTDBStorage.java @@ -911,20 +911,14 @@ private boolean match(String s, String p) { } private String getFilterString(Filter filter, String storageUnit) throws PhysicalException { - String filterStr = FilterTransformer.toString(filter); - if (filterStr.contains("*")) { - List columns = new ArrayList<>(); - Map columns2Fragment = new HashMap<>(); - getColumns2StorageUnit(columns, columns2Fragment, new HashSet<>(), null); - filterStr = - FilterTransformer.toString( - expandFilterWildcard(filter.copy(), columns, columns2Fragment, storageUnit)); - } - - return filterStr; + List columns = new ArrayList<>(); + Map columns2Fragment = new HashMap<>(); + getColumns2StorageUnit(columns, columns2Fragment, new HashSet<>(), null); + Filter fullFilter = expandFilter(filter.copy(), columns, columns2Fragment, storageUnit); + return FilterTransformer.toString(fullFilter); } - private Filter expandFilterWildcard( + private Filter expandFilter( Filter filter, List columns, Map columns2Fragment, @@ -935,9 +929,9 @@ private Filter expandFilterWildcard( List children = andFilter.getChildren(); List newAndFilters = new ArrayList<>(); for (Filter f : children) { - Filter newFilter = expandFilterWildcard(f, columns, columns2Fragment, storageUnit); + Filter newFilter = expandFilter(f, columns, columns2Fragment, storageUnit); if (newFilter != null) { - newAndFilters.add(expandFilterWildcard(f, columns, columns2Fragment, storageUnit)); + newAndFilters.add(expandFilter(f, columns, columns2Fragment, storageUnit)); } } return new AndFilter(newAndFilters); @@ -946,17 +940,16 @@ private Filter expandFilterWildcard( List orChildren = orFilter.getChildren(); List newOrFilters = new ArrayList<>(); for (Filter f : orChildren) { - Filter newFilter = expandFilterWildcard(f, columns, columns2Fragment, storageUnit); + Filter newFilter = expandFilter(f, columns, columns2Fragment, storageUnit); if (newFilter != null) { - newOrFilters.add(expandFilterWildcard(f, columns, columns2Fragment, storageUnit)); + newOrFilters.add(expandFilter(f, columns, columns2Fragment, storageUnit)); } } return new OrFilter(newOrFilters); case Not: NotFilter notFilter = (NotFilter) filter; Filter notChild = notFilter.getChild(); - Filter newNotFilter = - expandFilterWildcard(notChild, columns, columns2Fragment, storageUnit); + Filter newNotFilter = expandFilter(notChild, columns, columns2Fragment, storageUnit); if (newNotFilter != null) return new NotFilter(newNotFilter); else return null; case Key: @@ -965,16 +958,15 @@ private Filter expandFilterWildcard( ValueFilter valueFilter = (ValueFilter) filter; DataType valueType = valueFilter.getValue().getDataType(); String path = valueFilter.getPath(); - - if (path.contains("*")) { - List matchedPath = - getMatchPath(path, valueType, columns, columns2Fragment, storageUnit); - if (matchedPath.size() == 0) { - return null; - } - + List matchedPaths = + getMatchPath(path, valueType, columns, columns2Fragment, storageUnit); + if (matchedPaths.size() == 1) { + return new ValueFilter(matchedPaths.get(0), valueFilter.getOp(), valueFilter.getValue()); + } else if (matchedPaths.isEmpty()) { + return null; + } else { List newFilters = new ArrayList<>(); - for (String p : matchedPath) { + for (String p : matchedPaths) { newFilters.add(new ValueFilter(p, valueFilter.getOp(), valueFilter.getValue())); } if (Op.isOrOp(valueFilter.getOp())) { @@ -982,8 +974,6 @@ private Filter expandFilterWildcard( } else { return new AndFilter(newFilters); } - } else { - return filter; } case In: InFilter inFilter = (InFilter) filter; @@ -1043,7 +1033,7 @@ private List getMatchPath( Matcher matcher = pattern.matcher(columnName); if (matcher.find()) { - matchedPath.add(columnName); + matchedPath.add(TagKVUtils.toFullName(columnName, col.getTags())); } } diff --git a/dataSource/relational/src/main/java/cn/edu/tsinghua/iginx/relational/RelationalStorage.java b/dataSource/relational/src/main/java/cn/edu/tsinghua/iginx/relational/RelationalStorage.java index 3c746bc0eb..7acfd9b345 100644 --- a/dataSource/relational/src/main/java/cn/edu/tsinghua/iginx/relational/RelationalStorage.java +++ b/dataSource/relational/src/main/java/cn/edu/tsinghua/iginx/relational/RelationalStorage.java @@ -533,6 +533,8 @@ private TaskExecuteResult executeProjectWithFilter( Map tableNameToColumnNames = splitAndMergeQueryPatterns(databaseName, project.getPatterns()); + Filter expandFilter = expandFilter(filter.copy(), tableNameToColumnNames); + String statement; // 如果table>1的情况下存在Value或Path Filter,说明filter的匹配需要跨table,此时需要将所有table join到一起进行查询 if (!filter.toString().contains("*") @@ -541,7 +543,7 @@ && filterContainsType(Arrays.asList(FilterType.Value, FilterType.Path), filter)) for (Map.Entry entry : tableNameToColumnNames.entrySet()) { String tableName = entry.getKey(); String quotColumnNames = getQuotColumnNames(entry.getValue()); - String filterStr = filterTransformer.toString(filter); + String filterStr = filterTransformer.toString(expandFilter); statement = String.format( relationalMeta.getQueryStatement(), @@ -593,23 +595,8 @@ else if (!tableNameToColumnNames.isEmpty()) { // 将所有表进行full join String fullTableName = getFullJoinTables(tableNames, fullColumnNamesList); - // 对通配符做处理,将通配符替换成对应的列名 - if (filterTransformer.toString(filter).contains("*")) { - // 把fullColumnNamesList中的列名全部用removeFullColumnNameQuote去掉引号 - fullColumnNamesList.replaceAll( - columnNames -> { - List newColumnNames = new ArrayList<>(); - for (String columnName : columnNames) { - newColumnNames.add(removeFullColumnNameQuote(columnName)); - } - return newColumnNames; - }); - filter = generateWildCardsFilter(filter, fullColumnNamesList); - filter = LogicalFilterUtils.mergeTrue(filter); - } - String fullColumnNamesStr = fullColumnNames.toString(); - String filterStr = filterTransformer.toString(filter); + String filterStr = filterTransformer.toString(expandFilter); String orderByKey = RelationSchema.getQuoteFullName(tableNames.get(0), KEY_NAME, relationalMeta.getQuote()); if (!relationalMeta.isSupportFullJoin()) { @@ -836,54 +823,68 @@ private String getDummyFullJoinTables( return fullTableName.toString(); } - private Filter generateWildCardsFilter(Filter filter, List> columnNamesList) { + private Filter expandFilter(Filter filter, Map tableNameToColumnNames) { + List> fullColumnNamesList = new ArrayList<>(); + for (Map.Entry entry : tableNameToColumnNames.entrySet()) { + List fullColumnNames = new ArrayList<>(Arrays.asList(entry.getValue().split(", "))); + // 将columnNames中的列名加上tableName前缀 + fullColumnNames.replaceAll( + s -> RelationSchema.getQuoteFullName(entry.getKey(), s, relationalMeta.getQuote())); + fullColumnNamesList.add(fullColumnNames); + } + // 把fullColumnNamesList中的列名全部用removeFullColumnNameQuote去掉引号 + fullColumnNamesList.replaceAll( + columnNames -> { + List newColumnNames = new ArrayList<>(); + for (String columnName : columnNames) { + newColumnNames.add(removeFullColumnNameQuote(columnName)); + } + return newColumnNames; + }); + filter = expandFilter(filter, fullColumnNamesList); + filter = LogicalFilterUtils.mergeTrue(filter); + return filter; + } + + private Filter expandFilter(Filter filter, List> columnNamesList) { switch (filter.getType()) { case And: List andChildren = ((AndFilter) filter).getChildren(); for (Filter child : andChildren) { - Filter newFilter = generateWildCardsFilter(child, columnNamesList); + Filter newFilter = expandFilter(child, columnNamesList); andChildren.set(andChildren.indexOf(child), newFilter); } return new AndFilter(andChildren); case Or: List orChildren = ((OrFilter) filter).getChildren(); for (Filter child : orChildren) { - Filter newFilter = generateWildCardsFilter(child, columnNamesList); + Filter newFilter = expandFilter(child, columnNamesList); orChildren.set(orChildren.indexOf(child), newFilter); } return new OrFilter(orChildren); case Not: Filter notChild = ((NotFilter) filter).getChild(); - Filter newFilter = generateWildCardsFilter(notChild, columnNamesList); + Filter newFilter = expandFilter(notChild, columnNamesList); return new NotFilter(newFilter); case Value: - String path = ((ValueFilter) filter).getPath(); - if (path.contains("*")) { - List matchedPath = getMatchedPath(path, columnNamesList); - if (matchedPath.size() == 0) { - return new BoolFilter(true); - } else if (matchedPath.size() == 1) { - return new ValueFilter( - matchedPath.get(0), - ((ValueFilter) filter).getOp(), - ((ValueFilter) filter).getValue()); + ValueFilter valueFilter = ((ValueFilter) filter); + String path = valueFilter.getPath(); + List matchedPaths = getMatchedPath(path, columnNamesList); + if (matchedPaths.isEmpty()) { + return new BoolFilter(true); + } else if (matchedPaths.size() == 1) { + return new ValueFilter(matchedPaths.get(0), valueFilter.getOp(), valueFilter.getValue()); + } else { + List newFilters = new ArrayList<>(); + for (String matched : matchedPaths) { + newFilters.add(new ValueFilter(matched, valueFilter.getOp(), valueFilter.getValue())); + } + if (Op.isOrOp(valueFilter.getOp())) { + return new OrFilter(newFilters); } else { - List valueChildren = new ArrayList<>(); - for (String matched : matchedPath) { - valueChildren.add( - new ValueFilter( - matched, ((ValueFilter) filter).getOp(), ((ValueFilter) filter).getValue())); - } - - if (Op.isOrOp(((ValueFilter) filter).getOp())) { - return new OrFilter(valueChildren); - } - return new AndFilter(valueChildren); + return new AndFilter(newFilters); } } - - return filter; - case In: InFilter inFilter = (InFilter) filter; String inPath = inFilter.getPath(); @@ -936,7 +937,7 @@ private Filter generateWildCardsFilter(Filter filter, List> columnN if (pathB.contains("*")) { if (filter.getType() != FilterType.Path) { - return generateWildCardsFilter(filter, columnNamesList); + return expandFilter(filter, columnNamesList); } List matchedPath = getMatchedPath(pathB, columnNamesList); @@ -975,10 +976,9 @@ private List getMatchedPath(String path, List> columnNamesL List matchedPath = new ArrayList<>(); path = StringUtils.reformatPath(path); Pattern pattern = Pattern.compile("^" + path + "$"); - for (int i = 0; i < columnNamesList.size(); i++) { - List columnNames = columnNamesList.get(i); + for (List columnNames : columnNamesList) { for (String columnName : columnNames) { - Matcher matcher = pattern.matcher(columnName); + Matcher matcher = pattern.matcher(splitFullName(columnName).k); if (matcher.find()) { matchedPath.add(columnName); } @@ -1111,7 +1111,7 @@ private TaskExecuteResult executeProjectDummyWithFilter(Project project, Filter if (!filter.toString().contains("*") && !(tableNameToColumnNames.size() > 1 && filterContainsType(Arrays.asList(FilterType.Value, FilterType.Path), filter))) { - + Filter expandFilter = expandFilter(filter.copy(), tableNameToColumnNames); for (Map.Entry entry : splitEntry.getValue().entrySet()) { String tableName = entry.getKey(); String fullQuotColumnNames = getQuotColumnNames(entry.getValue()); @@ -1121,7 +1121,8 @@ && filterContainsType(Arrays.asList(FilterType.Value, FilterType.Path), filter)) String filterStr = filterTransformer.toString( dummyFilterSetTrueByColumnNames( - cutFilterDatabaseNameForDummy(filter.copy(), databaseName), fullPathList)); + cutFilterDatabaseNameForDummy(expandFilter.copy(), databaseName), + fullPathList)); String concatKey = buildConcat(fullPathList); statement = String.format( @@ -1172,20 +1173,7 @@ else if (!tableNameToColumnNames.isEmpty()) { cutFilterDatabaseNameForDummy(filter.copy(), databaseName), fullColumnNamesList.stream().flatMap(List::stream).collect(Collectors.toList())); - // 对通配符做处理,将通配符替换成对应的列名 - if (filterTransformer.toString(copyFilter).contains("*")) { - // 把fullColumnNamesList中的列名全部用removeFullColumnNameQuote去掉引号 - fullColumnNamesList.replaceAll( - columnNames -> { - List newColumnNames = new ArrayList<>(); - for (String columnName : columnNames) { - newColumnNames.add(removeFullColumnNameQuote(columnName)); - } - return newColumnNames; - }); - copyFilter = generateWildCardsFilter(copyFilter, fullColumnNamesList); - copyFilter = LogicalFilterUtils.mergeTrue(copyFilter); - } + copyFilter = expandFilter(copyFilter, tableNameToColumnNames); String filterStr = filterTransformer.toString(copyFilter); String orderByKey = diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/PySessionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/PySessionIT.java index 6cd358a541..f222e79e54 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/PySessionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/PySessionIT.java @@ -441,19 +441,19 @@ public void testDeleteRow() { } // 检查Python脚本的输出是否符合预期 String expected = - " key test.a.a test.a.b test.b.b test.c.c\n" - + "0 0 b'a' b'b' None None\n" - + "1 2 None None None b'c'\n" - + "2 3 b'Q' b'W' None b'R'\n" - + "3 5 None None None b'b'\n" - + "4 6 b'b' None None None\n" - + "5 7 b'R' b'E' None b'Q'\n" - + " key test.a.a test.a.b test.b.b test.c.c\n" - + "0 0 b'a' b'b' None None\n" - + "1 2 None None None b'c'\n" - + "2 3 b'Q' b'W' None b'R'\n" - + "3 5 None None None b'b'\n" - + "4 7 b'R' b'E' None b'Q'\n"; + " key test.a.a test.a.b test.c.c\n" + + "0 0 b'a' b'b' None\n" + + "1 2 None None b'c'\n" + + "2 3 b'Q' b'W' b'R'\n" + + "3 5 None None b'b'\n" + + "4 6 b'b' None None\n" + + "5 7 b'R' b'E' b'Q'\n" + + " key test.a.a test.a.b test.c.c\n" + + "0 0 b'a' b'b' None\n" + + "1 2 None None b'c'\n" + + "2 3 b'Q' b'W' b'R'\n" + + "3 5 None None b'b'\n" + + "4 7 b'R' b'E' b'Q'\n"; assertEquals(expected, result); } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/SessionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/SessionIT.java index d036319f14..48ebedf244 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/SessionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/session/SessionIT.java @@ -573,7 +573,8 @@ public void sessionTest() throws SessionException, InterruptedException { long key = delDataInColumnDataSet.getKeys()[i]; assertEquals(i + START_KEY, key); List result = delDataInColumnDataSet.getValues().get(i); - for (int j = 0; j < dataInColumnLen; j++) { + assertEquals(dataInColumnLen - deleteDataInColumnLen, delDataInColumnResPaths.size()); + for (int j = 0; j < dataInColumnLen - deleteDataInColumnLen; j++) { int pathNum = getPathNum(delDataInColumnResPaths.get(j)); assertNotEquals(pathNum, -1); if (pathNum < currPath + deleteDataInColumnLen) { // Here is the removed rows @@ -969,7 +970,7 @@ public void sessionTest() throws SessionException, InterruptedException { long key = dtDelColDataSet.getKeys()[i]; assertEquals(i + START_KEY, key); List result = dtDelColDataSet.getValues().get(i); - for (int j = 0; j < 6; j++) { + for (int j = 0; j < 4; j++) { int currPathPos = getPathNum(dtDelColResPaths.get(j)) - currPath; if (currPathPos < dtDelColumnNum) { assertNull(result.get(j)); diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/sql/SQLSessionIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/sql/SQLSessionIT.java index 665d4eac9a..922d15486b 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/sql/SQLSessionIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/sql/SQLSessionIT.java @@ -2733,15 +2733,16 @@ public void testGroupBy() { query = "explain select avg(a), sum(b), c, b, d from test group by c, b, d order by c, b, d;"; expected = "ResultSets:\n" - + "+----------------+-------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------+-------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: avg(test.a),sum(test.b),test.c,test.b,test.d|\n" - + "| +--Sort | Sort| SortBy: test.c,test.b,test.d, SortType: ASC,ASC,ASC|\n" - + "| +--GroupBy | GroupBy|GroupByCols: test.c,test.b,test.d, FuncList(Name, FuncType): (avg, System),(sum, System), MappingType: SetMapping isDistinct: false|\n" - + "| +--Project| Project| Patterns: test.a,test.b,test.c,test.d, Target DU: unit0000000002|\n" - + "+----------------+-------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 4\n"; + + "+------------------+----------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------+----------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: avg(test.a),sum(test.b),test.c,test.b,test.d|\n" + + "| +--Sort | Sort| SortBy: test.c,test.b,test.d, SortType: ASC,ASC,ASC|\n" + + "| +--GroupBy | GroupBy|GroupByCols: test.c,test.b,test.d, FuncList(Name, FuncType): (avg, System),(sum, System), MappingType: SetMapping isDistinct: false|\n" + + "| +--Project| Project| Patterns: test.a,test.b,test.c,test.d, Target DU: unit0000000002|\n" + + "+------------------+----------------+-----------------------------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 5\n"; executor.executeAndCompare(query, expected); } @@ -6457,28 +6458,30 @@ public void testExplain() { String explain = "explain select max(s2), min(s1) from us.d1;"; String expected = "ResultSets:\n" - + "+-----------------+-------------+--------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------+-------------+--------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: max(us.d1.s2),min(us.d1.s1)|\n" - + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (max, System), (min, System), MappingType: SetMapping, isDistinct: false|\n" - + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" - + "+-----------------+-------------+--------------------------------------------------------------------------------------------------+\n" - + "Total line number = 3\n"; + + "+-------------------+----------------+--------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------+----------------+--------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: max(us.d1.s2),min(us.d1.s1)|\n" + + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (max, System), (min, System), MappingType: SetMapping, isDistinct: false|\n" + + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" + + "+-------------------+----------------+--------------------------------------------------------------------------------------------------+\n" + + "Total line number = 4\n"; executor.executeAndCompare(explain, expected); explain = "explain select s1 from us.d1 where s1 > 10 and s1 < 100;"; expected = "ResultSets:\n" - + "+----------------+-------------+---------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------+-------------+---------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.s1|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Select | Select| Filter: (us.d1.s1 > 10 && us.d1.s1 < 100)|\n" - + "| +--Project| Project|Patterns: us.d1.s1, Target DU: unit0000000000|\n" - + "+----------------+-------------+---------------------------------------------+\n" - + "Total line number = 4\n"; + + "+------------------+----------------+---------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------+----------------+---------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.s1|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Select | Select| Filter: (us.d1.s1 > 10 && us.d1.s1 < 100)|\n" + + "| +--Project| Project|Patterns: us.d1.s1, Target DU: unit0000000000|\n" + + "+------------------+----------------+---------------------------------------------+\n" + + "Total line number = 5\n"; executor.executeAndCompare(explain, expected); explain = "explain physical select max(s2), min(s1) from us.d1;"; @@ -7065,351 +7068,370 @@ public void testFilterPushDownExplain() { new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < 4;", "ResultSets:\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+--------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 4)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < 5 and d1.s2 > 2;", "ResultSets:\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+--------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 5 && us.d1.s2 > 2)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < 6 and d2.s1 > 3;", "ResultSets:\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 6 && us.d2.s1 > 3)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 6 && us.d2.s1 > 3)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 6)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: (us.d2.s1 > 3)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 11\n"), + + "+--------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 6 && us.d2.s1 > 3)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 6 && us.d2.s1 > 3)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 6)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: (us.d2.s1 > 3)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 12\n"), new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < 6 or d2.s1 < 7;\n", "ResultSets:\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: ((us.d1.s1 < 6 || us.d2.s1 < 7))|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: ((us.d1.s1 < 6 || us.d2.s1 < 7))|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "Total line number = 9\n"), + + "+------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: ((us.d1.s1 < 6 || us.d2.s1 < 7))|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: ((us.d1.s1 < 6 || us.d2.s1 < 7))|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 10\n"), new Pair<>( "explain SELECT * FROM us WHERE d2.c like \"[a|s]\";", "ResultSets:\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+--------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: (us.d2.c like \"[a|s]\")|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE key < 4;\n", "ResultSets:\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (key < 4)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: (key < 4)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Select | Select| Filter: (key < 4)|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+----------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (key < 4)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: (key < 4)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Select | Select| Filter: (key < 4)|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE key < 5 and key > 1;\n", "ResultSets:\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+----------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Select | Select| Filter: (key < 5 && key > 1)|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE key < 5 or key > 1003;", "ResultSets:\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+----------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Select | Select| Filter: ((key < 5 || key > 1003))|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < d1.s2;\n", "ResultSets:\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 10\n"), + + "+--------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < us.d1.s2)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+--------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us WHERE d1.s1 < d2.s1;\n", "ResultSets:\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < us.d2.s1)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < us.d2.s1)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+----------------------+-------------+-----------------------------------------+\n" - + "Total line number = 9\n"), + + "+------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < us.d2.s1)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < us.d2.s1)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 10\n"), new Pair<>( "explain SELECT * FROM (SELECT * FROM us WHERE us.d1.s1 < 5) WHERE us.d1.s2 < 5;\n", "ResultSets:\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 12\n"), + + "+------------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 < 5 && us.d1.s1 < 5)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+------------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 13\n"), new Pair<>( "explain SELECT * FROM (SELECT * FROM us WHERE us.d1.s1 < 5) WHERE us.d2.s1 < 10;", "ResultSets:\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--Reorder | Reorder| Order: us.*|\n" - + "| +--Project | Project| Patterns: us.*|\n" - + "| +--Select | Select| Filter: (us.d2.s1 < 10 && us.d1.s1 < 5)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d2.s1 < 10 && us.d1.s1 < 5)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 5)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" - + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" - + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" - + "+----------------------------+-------------+-----------------------------------------+\n" - + "Total line number = 13\n"), + + "+------------------------------+----------------+-----------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------------+----------------+-----------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--Reorder | Reorder| Order: us.*|\n" + + "| +--Project | Project| Patterns: us.*|\n" + + "| +--Select | Select| Filter: (us.d2.s1 < 10 && us.d1.s1 < 5)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d2.s1 < 10 && us.d1.s1 < 5)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 5)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000000|\n" + + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" + + "| +--Project| Project|Patterns: us.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.*, Target DU: unit0000000002|\n" + + "+------------------------------+----------------+-----------------------------------------+\n" + + "Total line number = 14\n"), new Pair<>( "explain SELECT * FROM us.d1 LEFT OUTER JOIN us.d2 ON us.d1.s1 = us.d2.s1 AND us.d1.s1 < 10 AND us.d2.s1 < 10 WHERE us.d1.s2 > 10;", "ResultSets:\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--OuterJoin | OuterJoin|PrefixA: us.d1, PrefixB: us.d2, OuterJoinType: LEFT, IsNatural: false, Filter: (us.d1.s1 == us.d2.s1 && us.d1.s1 < 10)|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 13\n"), + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--OuterJoin | OuterJoin|PrefixA: us.d1, PrefixB: us.d2, OuterJoinType: LEFT, IsNatural: false, Filter: (us.d1.s1 == us.d2.s1 && us.d1.s1 < 10)|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 14\n"), new Pair<>( "explain SELECT * FROM us.d1, us.d2, us.d3 WHERE us.d1.s1 = us.d2.s1 AND us.d2.s1 = us.d3.s1 AND us.d2.s1 < 10;", "ResultSets:\n" - + "+----------------------+-------------+--------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+--------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--InnerJoin | InnerJoin|PrefixA: us.d2, PrefixB: us.d3, IsNatural: false, Filter: (us.d2.s1 == us.d3.s1)|\n" - + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false, Filter: (us.d1.s1 == us.d2.s1)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d3.*, Target DU: unit0000000001|\n" - + "+----------------------+-------------+--------------------------------------------------------------------------------+\n" - + "Total line number = 12\n"), + + "+------------------------+----------------+--------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+--------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--InnerJoin | InnerJoin|PrefixA: us.d2, PrefixB: us.d3, IsNatural: false, Filter: (us.d2.s1 == us.d3.s1)|\n" + + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false, Filter: (us.d1.s1 == us.d2.s1)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Select | Select| Filter: (us.d2.s1 < 10)|\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d3.*, Target DU: unit0000000001|\n" + + "+------------------------+----------------+--------------------------------------------------------------------------------+\n" + + "Total line number = 13\n"), new Pair<>( "explain SELECT * FROM (SELECT max(s2), min(s3), s1 FROM us.d1 GROUP BY s1) WHERE us.d1.s1 < 10 AND max(us.d1.s2) > 10;", "ResultSets:\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--Reorder | Reorder| Order: max(us.d1.s2),min(us.d1.s3),us.d1.s1|\n" - + "| +--Select | Select| Filter: (max(us.d1.s2) > 10)|\n" - + "| +--GroupBy | GroupBy|GroupByCols: us.d1.s1, FuncList(Name, FuncType): (max, System),(min, System), MappingType: SetMapping isDistinct: false|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" - + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 7\n"), + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--Reorder | Reorder| Order: max(us.d1.s2),min(us.d1.s3),us.d1.s1|\n" + + "| +--Select | Select| Filter: (max(us.d1.s2) > 10)|\n" + + "| +--GroupBy | GroupBy|GroupByCols: us.d1.s1, FuncList(Name, FuncType): (max, System),(min, System), MappingType: SetMapping isDistinct: false|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" + + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 8\n"), new Pair<>( "explain SELECT * FROM (SELECT avg(s2), count(s3) FROM us.d1) WHERE avg(us.d1.s2) < 10;", "ResultSets:\n" - + "+-----------------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--Reorder | Reorder| Order: avg(us.d1.s2),count(us.d1.s3)|\n" - + "| +--Select | Select| Filter: avg(us.d1.s2) < 10|\n" - + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), (count, System), MappingType: SetMapping, isDistinct: false|\n" - + "| +--Project | Project| Patterns: us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" - + "+-----------------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "Total line number = 6\n"), + + "+-------------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--Reorder | Reorder| Order: avg(us.d1.s2),count(us.d1.s3)|\n" + + "| +--Select | Select| Filter: avg(us.d1.s2) < 10|\n" + + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), (count, System), MappingType: SetMapping, isDistinct: false|\n" + + "| +--Project | Project| Patterns: us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" + + "+-------------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "Total line number = 7\n"), new Pair<>( "explain SELECT s1 FROM us.d1 WHERE s1 < 10 && EXISTS (SELECT s1 FROM us.d2 WHERE us.d1.s1 > us.d2.s1);", "ResultSets:\n" - + "+--------------------------+-------------+-------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------------+-------------+-------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.s1|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Select | Select| Filter: (&mark11 == true)|\n" - + "| +--MarkJoin | MarkJoin|Filter: True, MarkColumn: &mark11, IsAntiJoin: false, ExtraJoinPrefix: us.d1.s1|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" - + "| +--Project | Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" - + "| +--Project | Project| Patterns: us.d1.s1,us.d2.s1|\n" - + "| +--InnerJoin | InnerJoin| PrefixA: null, PrefixB: null, IsNatural: false, Filter: (us.d1.s1 > us.d2.s1)|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" - + "| +--Project| Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" - + "| +--Project | Project| Patterns: us.d2.s1, Target DU: unit0000000001|\n" - + "+--------------------------+-------------+-------------------------------------------------------------------------------+\n" - + "Total line number = 12\n"), + + "+----------------------------+----------------+-------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------------+----------------+-------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.s1|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Select | Select| Filter: (&mark11 == true)|\n" + + "| +--MarkJoin | MarkJoin|Filter: True, MarkColumn: &mark11, IsAntiJoin: false, ExtraJoinPrefix: us.d1.s1|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" + + "| +--Project | Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" + + "| +--Project | Project| Patterns: us.d1.s1,us.d2.s1|\n" + + "| +--InnerJoin | InnerJoin| PrefixA: null, PrefixB: null, IsNatural: false, Filter: (us.d1.s1 > us.d2.s1)|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Select | Select| Filter: (us.d1.s1 < 10)|\n" + + "| +--Project| Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" + + "| +--Project | Project| Patterns: us.d2.s1, Target DU: unit0000000001|\n" + + "+----------------------------+----------------+-------------------------------------------------------------------------------+\n" + + "Total line number = 13\n"), new Pair<>( "explain SELECT * FROM us.d1 LEFT OUTER JOIN us.d2 ON us.d1.s1 = us.d2.s1 WHERE us.d2.s2 < 10;", "ResultSets:\n" - + "+--------------------+-------------+------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false, Filter: us.d1.s1 == us.d2.s1|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Select | Select| Filter: (us.d2.s2 < 10)|\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" - + "+--------------------+-------------+------------------------------------------------------------------------------+\n" - + "Total line number = 10\n"), + + "+----------------------+----------------+------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false, Filter: us.d1.s1 == us.d2.s1|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Select | Select| Filter: (us.d2.s2 < 10)|\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" + + "+----------------------+----------------+------------------------------------------------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "explain SELECT * FROM us.d1 FULL OUTER JOIN us.d2 ON us.d1.s1 = us.d2.s1 WHERE us.d1.s2 > 10;", "ResultSets:\n" - + "+--------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--Project | Project| Patterns: *|\n" - + "| +--OuterJoin | OuterJoin|PrefixA: us.d1, PrefixB: us.d2, OuterJoinType: LEFT, IsNatural: false, Filter: us.d1.s1 == us.d2.s1|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" - + "+--------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "Total line number = 12\n")); + + "+----------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--Project | Project| Patterns: *|\n" + + "| +--OuterJoin | OuterJoin|PrefixA: us.d1, PrefixB: us.d2, OuterJoinType: LEFT, IsNatural: false, Filter: us.d1.s1 == us.d2.s1|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Select | Select| Filter: (us.d1.s2 > 10)|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000001|\n" + + "+----------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "Total line number = 13\n")); for (Pair pair : statementsAndExpectRes) { String statement = pair.k; @@ -7488,46 +7510,48 @@ public void testFilterFragmentOptimizer() { new Pair<>( "EXPLAIN SELECT s1 FROM us.d1 JOIN us.d2 WHERE key < 100;", "ResultSets:\n" - + "+------------------------+-------------+------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+------------------------------------------------+\n" - + "|Reorder | Reorder| Order: s1|\n" - + "| +--Project | Project| Patterns: s1|\n" - + "| +--Select | Select| Filter: key < 100|\n" - + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false|\n" - + "| +--PathUnion | PathUnion| |\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000004|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000003|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000005|\n" - + "| +--PathUnion | PathUnion| |\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000002|\n" - + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000003|\n" - + "+------------------------+-------------+------------------------------------------------+\n" - + "Total line number = 18\n"), + + "+--------------------------+----------------+------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: s1|\n" + + "| +--Project | Project| Patterns: s1|\n" + + "| +--Select | Select| Filter: key < 100|\n" + + "| +--InnerJoin | InnerJoin|PrefixA: us.d1, PrefixB: us.d2, IsNatural: false|\n" + + "| +--PathUnion | PathUnion| |\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000004|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000003|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000005|\n" + + "| +--PathUnion | PathUnion| |\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000002|\n" + + "| +--Project | Project| Patterns: us.d2.*, Target DU: unit0000000003|\n" + + "+--------------------------+----------------+------------------------------------------------+\n" + + "Total line number = 19\n"), new Pair<>( "EXPLAIN SELECT avg(bb) FROM (SELECT a as aa, b as bb FROM us.d2) WHERE key > 2 GROUP BY aa;", "ResultSets:\n" - + "+------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: avg(bb)|\n" - + "| +--GroupBy | GroupBy|GroupByCols: aa, FuncList(Name, FuncType): (avg, System), MappingType: SetMapping isDistinct: false|\n" - + "| +--Select | Select| Filter: key > 2|\n" - + "| +--Rename | Rename| AliasList: (us.d2.a, aa),(us.d2.b, bb)|\n" - + "| +--Reorder | Reorder| Order: us.d2.a,us.d2.b|\n" - + "| +--Project | Project| Patterns: us.d2.a,us.d2.b|\n" - + "| +--PathUnion| PathUnion| |\n" - + "| +--Project| Project| Patterns: us.d2.a,us.d2.b, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: us.d2.a,us.d2.b, Target DU: unit0000000003|\n" - + "+------------------------+-------------+---------------------------------------------------------------------------------------------------+\n" - + "Total line number = 9\n")); + + "+--------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: avg(bb)|\n" + + "| +--GroupBy | GroupBy|GroupByCols: aa, FuncList(Name, FuncType): (avg, System), MappingType: SetMapping isDistinct: false|\n" + + "| +--Select | Select| Filter: key > 2|\n" + + "| +--Rename | Rename| AliasList: (us.d2.a, aa),(us.d2.b, bb)|\n" + + "| +--Reorder | Reorder| Order: us.d2.a,us.d2.b|\n" + + "| +--Project | Project| Patterns: us.d2.a,us.d2.b|\n" + + "| +--PathUnion| PathUnion| |\n" + + "| +--Project| Project| Patterns: us.d2.a,us.d2.b, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: us.d2.a,us.d2.b, Target DU: unit0000000003|\n" + + "+--------------------------+----------------+---------------------------------------------------------------------------------------------------+\n" + + "Total line number = 10\n")); // 这里的测例是filter_fragment能处理的节点,开关会导致变化 List> statementsAndExpectResAfterOptimize = @@ -7540,47 +7564,50 @@ public void testFilterFragmentOptimizer() { + ")\n" + "OVER WINDOW (size 20 IN [1000, 1100));", "ResultSets:\n" - + "+------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: count(*)|\n" - + "| +--Downsample | Downsample| Precision: 20, SlideDistance: 20, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (count, System), MappingType: SetMapping|\n" - + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" - + "| +--Rename | Rename| AliasList: (avg(us.d1.s1), avg_s1),(sum(us.d1.s2), sum_s2)|\n" - + "| +--Reorder | Reorder| Order: avg(us.d1.s1),sum(us.d1.s2)|\n" - + "| +--Downsample | Downsample|Precision: 10, SlideDistance: 10, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (avg, System), (sum, System), MappingType: SetMapping|\n" - + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" - + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" - + "+------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 8\n"), + + "+--------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: count(*)|\n" + + "| +--Downsample | Downsample| Precision: 20, SlideDistance: 20, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (count, System), MappingType: SetMapping|\n" + + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" + + "| +--Rename | Rename| AliasList: (avg(us.d1.s1), avg_s1),(sum(us.d1.s2), sum_s2)|\n" + + "| +--Reorder | Reorder| Order: avg(us.d1.s1),sum(us.d1.s2)|\n" + + "| +--Downsample | Downsample|Precision: 10, SlideDistance: 10, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (avg, System), (sum, System), MappingType: SetMapping|\n" + + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" + + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" + + "+--------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 9\n"), new Pair<>( "EXPLAIN SELECT d1.* FROM us where key < 10;", "ResultSets:\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.*|\n" - + "| +--Project | Project| Patterns: us.d1.*|\n" - + "| +--Select | Select| Filter: key < 10|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000004|\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "Total line number = 8\n"), + + "+----------------------+----------------+--------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+--------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.*|\n" + + "| +--Project | Project| Patterns: us.d1.*|\n" + + "| +--Select | Select| Filter: key < 10|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000004|\n" + + "+----------------------+----------------+--------------------------------------------+\n" + + "Total line number = 9\n"), new Pair<>( "EXPLAIN SELECT d2.c FROM us where key < 10;", "ResultSets:\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d2.c|\n" - + "| +--Project | Project| Patterns: us.d2.c|\n" - + "| +--Select | Select| Filter: key < 10|\n" - + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000002|\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "Total line number = 4\n")); + + "+------------------+----------------+--------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------+----------------+--------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d2.c|\n" + + "| +--Project | Project| Patterns: us.d2.c|\n" + + "| +--Select | Select| Filter: key < 10|\n" + + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000002|\n" + + "+------------------+----------------+--------------------------------------------+\n" + + "Total line number = 5\n")); executor.concurrentExecuteAndCompare(statementsAndExpectResAfterOptimize); executor.concurrentExecuteAndCompare(statementsAndExpectResNoChange); @@ -7599,55 +7626,58 @@ public void testFilterFragmentOptimizer() { + ")\n" + "OVER WINDOW (size 20 IN [1000, 1100));", "ResultSets:\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: count(*)|\n" - + "| +--Downsample | Downsample| Precision: 20, SlideDistance: 20, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (count, System), MappingType: SetMapping|\n" - + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" - + "| +--Rename | Rename| AliasList: (avg(us.d1.s1), avg_s1),(sum(us.d1.s2), sum_s2)|\n" - + "| +--Reorder | Reorder| Order: avg(us.d1.s1),sum(us.d1.s2)|\n" - + "| +--Downsample | Downsample|Precision: 10, SlideDistance: 10, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (avg, System), (sum, System), MappingType: SetMapping|\n" - + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" - + "| +--PathUnion| PathUnion| |\n" - + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" - + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000001|\n" - + "+--------------------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 10\n"), + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: count(*)|\n" + + "| +--Downsample | Downsample| Precision: 20, SlideDistance: 20, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (count, System), MappingType: SetMapping|\n" + + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" + + "| +--Rename | Rename| AliasList: (avg(us.d1.s1), avg_s1),(sum(us.d1.s2), sum_s2)|\n" + + "| +--Reorder | Reorder| Order: avg(us.d1.s1),sum(us.d1.s2)|\n" + + "| +--Downsample | Downsample|Precision: 10, SlideDistance: 10, TimeRange: [1000, 1100), FuncList(Name, FunctionType): (avg, System), (sum, System), MappingType: SetMapping|\n" + + "| +--Select | Select| Filter: (key >= 1000 && key < 1100)|\n" + + "| +--PathUnion| PathUnion| |\n" + + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" + + "| +--Project| Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000001|\n" + + "+----------------------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 11\n"), new Pair<>( "EXPLAIN SELECT d1.* FROM us;", "ResultSets:\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.*|\n" - + "| +--Project | Project| Patterns: us.d1.*|\n" - + "| +--PathUnion | PathUnion| |\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000004|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000003|\n" - + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000005|\n" - + "+--------------------+-------------+--------------------------------------------+\n" - + "Total line number = 13\n"), + + "+----------------------+----------------+--------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+--------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.*|\n" + + "| +--Project | Project| Patterns: us.d1.*|\n" + + "| +--PathUnion | PathUnion| |\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000004|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000003|\n" + + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000005|\n" + + "+----------------------+----------------+--------------------------------------------+\n" + + "Total line number = 14\n"), new Pair<>( "EXPLAIN SELECT d2.c FROM us;", "ResultSets:\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d2.c|\n" - + "| +--Project | Project| Patterns: us.d2.c|\n" - + "| +--PathUnion| PathUnion| |\n" - + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000002|\n" - + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000003|\n" - + "+----------------+-------------+--------------------------------------------+\n" - + "Total line number = 5\n")); + + "+------------------+----------------+--------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------+----------------+--------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d2.c|\n" + + "| +--Project | Project| Patterns: us.d2.c|\n" + + "| +--PathUnion| PathUnion| |\n" + + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000002|\n" + + "| +--Project| Project|Patterns: us.d2.c, Target DU: unit0000000003|\n" + + "+------------------+----------------+--------------------------------------------+\n" + + "Total line number = 6\n")); executor.concurrentExecuteAndCompare(statementsAndExpectResBeforeOptimize); executor.concurrentExecuteAndCompare(statementsAndExpectResNoChange); @@ -7708,14 +7738,15 @@ public void testSetMappingTransform() { query = "explain SELECT count(s1), avg(s2) from us.d1;"; expect = "ResultSets:\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: count(us.d1.s1),avg(us.d1.s2)|\n" - + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (count, System), (avg, System), MappingType: SetMapping, isDistinct: false|\n" - + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------------------+\n" - + "Total line number = 3\n"; + + "+-------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: count(us.d1.s1),avg(us.d1.s2)|\n" + + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (count, System), (avg, System), MappingType: SetMapping, isDistinct: false|\n" + + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2, Target DU: unit0000000000|\n" + + "+-------------------+----------------+----------------------------------------------------------------------------------------------------+\n" + + "Total line number = 4\n"; executor.executeAndCompare(query, expect); } } @@ -7751,16 +7782,17 @@ public void testMappingTransform() { query = "explain SELECT first(s1), last(s2), first(s3), last(s4) from us.d1;"; expect = "ResultSets:\n" - + "+---------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree| Operator Type| Operator Info|\n" - + "+---------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: path,value|\n" - + "| +--MappingTransform|MappingTransform|FuncList(Name, FuncType): (first, System), (last, System), (first, System), (last, System), MappingType: Mapping|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" - + "| +--Project | Project| Patterns: us.d1.s4, Target DU: unit0000000001|\n" - + "+---------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 5\n"; + + "+-----------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-----------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: path,value|\n" + + "| +--MappingTransform|MappingTransform|FuncList(Name, FuncType): (first, System), (last, System), (first, System), (last, System), MappingType: Mapping|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project | Project| Patterns: us.d1.s1,us.d1.s2,us.d1.s3, Target DU: unit0000000000|\n" + + "| +--Project | Project| Patterns: us.d1.s4, Target DU: unit0000000001|\n" + + "+-----------------------+----------------+----------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 6\n"; executor.executeAndCompare(query, expect); } } @@ -7827,108 +7859,114 @@ public void testColumnPruningAndFragmentPruning() { String expect1 = "ResultSets:\n" - + "+----------------------+-------------+--------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+--------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.s1|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Reorder | Reorder| Order: us.d1.*|\n" - + "| +--Project | Project| Patterns: us.d1.*|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "+----------------------+-------------+--------------------------------------------+\n" - + "Total line number = 9\n"; + + "+------------------------+----------------+--------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+--------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.s1|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Reorder | Reorder| Order: us.d1.*|\n" + + "| +--Project | Project| Patterns: us.d1.*|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project|Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project|Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "+------------------------+----------------+--------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql1, expect1); String expect2 = "ResultSets:\n" - + "+--------------------+-------------+-------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a|\n" - + "| +--Project | Project| Patterns: test.a.a|\n" - + "| +--InnerJoin | InnerJoin|PrefixA: test.a, PrefixB: us.d1, IsNatural: false, Filter: test.a.b == us.d1.s1|\n" - + "| +--Project | Project| Patterns: test.a.*, Target DU: unit0000000002|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Join | Join| JoinBy: key|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" - + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" - + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-------------------------------------------------------------------------------+\n" - + "Total line number = 9\n"; + + "+----------------------+----------------+-------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a|\n" + + "| +--Project | Project| Patterns: test.a.a|\n" + + "| +--InnerJoin | InnerJoin|PrefixA: test.a, PrefixB: us.d1, IsNatural: false, Filter: test.a.b == us.d1.s1|\n" + + "| +--Project | Project| Patterns: test.a.*, Target DU: unit0000000002|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Join | Join| JoinBy: key|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000000|\n" + + "| +--Project| Project| Patterns: us.d1.*, Target DU: unit0000000001|\n" + + "| +--Project | Project| Patterns: us.d1.*, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-------------------------------------------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql2, expect2); String expect3 = "ResultSets:\n" - + "+------------------+-------------+-------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------+-------------+-------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" - + "| +--Project | Project| Patterns: test.b.k,test.a.e,test.a.a|\n" - + "| +--Reorder | Reorder| Order: test.*|\n" - + "| +--Project | Project| Patterns: test.*|\n" - + "| +--Project| Project|Patterns: test.*, Target DU: unit0000000002|\n" - + "+------------------+-------------+-------------------------------------------+\n" - + "Total line number = 5\n"; + + "+--------------------+----------------+-------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------+----------------+-------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" + + "| +--Project | Project| Patterns: test.b.k,test.a.e,test.a.a|\n" + + "| +--Reorder | Reorder| Order: test.*|\n" + + "| +--Project | Project| Patterns: test.*|\n" + + "| +--Project| Project|Patterns: test.*, Target DU: unit0000000002|\n" + + "+--------------------+----------------+-------------------------------------------+\n" + + "Total line number = 6\n"; executor.executeAndCompare(sql3, expect3); String expect4 = "ResultSets:\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,avg(test.a.b)|\n" - + "| +--Project | Project| Patterns: avg(test.a.b),test.a.a|\n" - + "| +--SingleJoin | SingleJoin| Filter: True|\n" - + "| +--Reorder | Reorder| Order: test.a.*|\n" - + "| +--Project | Project| Patterns: test.a.*|\n" - + "| +--Project | Project| Patterns: test.a.*, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: avg(test.a.b)|\n" - + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), MappingType: SetMapping, isDistinct: false|\n" - + "| +--Project | Project| Patterns: test.a.b, Target DU: unit0000000002|\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "Total line number = 9\n"; + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,avg(test.a.b)|\n" + + "| +--Project | Project| Patterns: avg(test.a.b),test.a.a|\n" + + "| +--SingleJoin | SingleJoin| Filter: True|\n" + + "| +--Reorder | Reorder| Order: test.a.*|\n" + + "| +--Project | Project| Patterns: test.a.*|\n" + + "| +--Project | Project| Patterns: test.a.*, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: avg(test.a.b)|\n" + + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), MappingType: SetMapping, isDistinct: false|\n" + + "| +--Project | Project| Patterns: test.a.b, Target DU: unit0000000002|\n" + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql4, expect4); String expect5 = "ResultSets:\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Union | Union|LeftOrder: test.a.*, RightOrder: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j, isDistinct: true|\n" - + "| +--Reorder | Reorder| Order: test.a.*|\n" - + "| +--Project | Project| Patterns: test.a.*|\n" - + "| +--Project| Project| Patterns: test.a.*, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j|\n" - + "| +--Project | Project| Patterns: test.b.h,test.b.i,test.b.j,test.b.f,test.b.g|\n" - + "| +--Project| Project| Patterns: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------------------------+\n" - + "Total line number = 9\n"; + + "+----------------------+----------------+-----------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-----------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Union | Union|LeftOrder: test.a.*, RightOrder: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j, isDistinct: true|\n" + + "| +--Reorder | Reorder| Order: test.a.*|\n" + + "| +--Project | Project| Patterns: test.a.*|\n" + + "| +--Project| Project| Patterns: test.a.*, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j|\n" + + "| +--Project | Project| Patterns: test.b.h,test.b.i,test.b.j,test.b.f,test.b.g|\n" + + "| +--Project| Project| Patterns: test.b.f,test.b.g,test.b.h,test.b.i,test.b.j, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-----------------------------------------------------------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql5, expect5); String expect6 = "ResultSets:\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Intersect | Intersect|LeftOrder: test.a.a,test.a.b,test.a.c,test.a.d, RightOrder: test.b.f,test.b.g,test.b.h,test.b.i, isDistinct: true|\n" - + "| +--Reorder | Reorder| Order: test.a.a,test.a.b,test.a.c,test.a.d|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b,test.a.c,test.a.d|\n" - + "| +--Select | Select| Filter: test.a.a < 50000|\n" - + "| +--Project| Project| Patterns: test.a.a,test.a.b,test.a.c,test.a.d, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: test.b.f,test.b.g,test.b.h,test.b.i|\n" - + "| +--Project | Project| Patterns: test.b.h,test.b.i,test.b.f,test.b.g|\n" - + "| +--Select | Select| Filter: test.b.f > 30000|\n" - + "| +--Project| Project| Patterns: test.b.f,test.b.g,test.b.h,test.b.i, Target DU: unit0000000002|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------------------------------------------+\n" - + "Total line number = 11\n"; + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Intersect | Intersect|LeftOrder: test.a.a,test.a.b,test.a.c,test.a.d, RightOrder: test.b.f,test.b.g,test.b.h,test.b.i, isDistinct: true|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b,test.a.c,test.a.d|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b,test.a.c,test.a.d|\n" + + "| +--Select | Select| Filter: test.a.a < 50000|\n" + + "| +--Project| Project| Patterns: test.a.a,test.a.b,test.a.c,test.a.d, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: test.b.f,test.b.g,test.b.h,test.b.i|\n" + + "| +--Project | Project| Patterns: test.b.h,test.b.i,test.b.f,test.b.g|\n" + + "| +--Select | Select| Filter: test.b.f > 30000|\n" + + "| +--Project| Project| Patterns: test.b.f,test.b.g,test.b.h,test.b.i, Target DU: unit0000000002|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------------------------------------------+\n" + + "Total line number = 12\n"; executor.executeAndCompare(sql6, expect6); String openRule = "SET RULES ColumnPruningRule=ON;"; @@ -7936,100 +7974,106 @@ public void testColumnPruningAndFragmentPruning() { expect1 = "ResultSets:\n" - + "+------------------+-------------+---------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------+-------------+---------------------------------------------+\n" - + "|Reorder | Reorder| Order: us.d1.s1|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Reorder | Reorder| Order: us.d1.s1|\n" - + "| +--Project | Project| Patterns: us.d1.s1|\n" - + "| +--Project| Project|Patterns: us.d1.s1, Target DU: unit0000000000|\n" - + "+------------------+-------------+---------------------------------------------+\n" - + "Total line number = 5\n"; + + "+--------------------+----------------+---------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------+----------------+---------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: us.d1.s1|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Reorder | Reorder| Order: us.d1.s1|\n" + + "| +--Project | Project| Patterns: us.d1.s1|\n" + + "| +--Project| Project|Patterns: us.d1.s1, Target DU: unit0000000000|\n" + + "+--------------------+----------------+---------------------------------------------+\n" + + "Total line number = 6\n"; executor.executeAndCompare(sql1, expect1); expect2 = "ResultSets:\n" - + "+----------------+-------------+-------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------+-------------+-------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a|\n" - + "| +--Project | Project| Patterns: test.a.a|\n" - + "| +--InnerJoin| InnerJoin|PrefixA: test.a, PrefixB: us.d1, IsNatural: false, Filter: test.a.b == us.d1.s1|\n" - + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" - + "+----------------+-------------+-------------------------------------------------------------------------------+\n" - + "Total line number = 5\n"; + + "+------------------+----------------+-------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------+----------------+-------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a|\n" + + "| +--Project | Project| Patterns: test.a.a|\n" + + "| +--InnerJoin| InnerJoin|PrefixA: test.a, PrefixB: us.d1, IsNatural: false, Filter: test.a.b == us.d1.s1|\n" + + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: us.d1.s1, Target DU: unit0000000000|\n" + + "+------------------+----------------+-------------------------------------------------------------------------------+\n" + + "Total line number = 6\n"; executor.executeAndCompare(sql2, expect2); expect3 = "ResultSets:\n" - + "+------------------+-------------+---------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+------------------+-------------+---------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.e,test.b.k|\n" - + "| +--Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.e,test.b.k|\n" - + "| +--Project| Project|Patterns: test.a.a,test.a.e,test.b.k, Target DU: unit0000000002|\n" - + "+------------------+-------------+---------------------------------------------------------------+\n" - + "Total line number = 5\n"; + + "+--------------------+----------------+---------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+--------------------+----------------+---------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.e,test.b.k|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.e,test.b.k|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.e,test.b.k|\n" + + "| +--Project| Project|Patterns: test.a.a,test.a.e,test.b.k, Target DU: unit0000000002|\n" + + "+--------------------+----------------+---------------------------------------------------------------+\n" + + "Total line number = 6\n"; executor.executeAndCompare(sql3, expect3); expect4 = "ResultSets:\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,avg(test.a.b)|\n" - + "| +--Project | Project| Patterns: avg(test.a.b),test.a.a|\n" - + "| +--SingleJoin | SingleJoin| Filter: True|\n" - + "| +--Reorder | Reorder| Order: test.a.a|\n" - + "| +--Project | Project| Patterns: test.a.a|\n" - + "| +--Project | Project| Patterns: test.a.a, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: avg(test.a.b)|\n" - + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), MappingType: SetMapping, isDistinct: false|\n" - + "| +--Project | Project| Patterns: test.a.b, Target DU: unit0000000002|\n" - + "+-----------------------+-------------+-----------------------------------------------------------------------------------+\n" - + "Total line number = 9\n"; + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,avg(test.a.b)|\n" + + "| +--Project | Project| Patterns: avg(test.a.b),test.a.a|\n" + + "| +--SingleJoin | SingleJoin| Filter: True|\n" + + "| +--Reorder | Reorder| Order: test.a.a|\n" + + "| +--Project | Project| Patterns: test.a.a|\n" + + "| +--Project | Project| Patterns: test.a.a, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: avg(test.a.b)|\n" + + "| +--SetTransform| SetTransform|FuncList(Name, FuncType): (avg, System), MappingType: SetMapping, isDistinct: false|\n" + + "| +--Project | Project| Patterns: test.a.b, Target DU: unit0000000002|\n" + + "+-------------------------+----------------+-----------------------------------------------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql4, expect4); expect5 = "ResultSets:\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Union | Union|LeftOrder: test.a.a,test.a.b, RightOrder: test.b.f,test.b.g, isDistinct: true|\n" - + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: test.b.f,test.b.g|\n" - + "| +--Project | Project| Patterns: test.b.f,test.b.g|\n" - + "| +--Project| Project| Patterns: test.b.f,test.b.g, Target DU: unit0000000002|\n" - + "+--------------------+-------------+-----------------------------------------------------------------------------+\n" - + "Total line number = 9\n"; + + "+----------------------+----------------+-----------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+-----------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Union | Union|LeftOrder: test.a.a,test.a.b, RightOrder: test.b.f,test.b.g, isDistinct: true|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: test.b.f,test.b.g|\n" + + "| +--Project | Project| Patterns: test.b.f,test.b.g|\n" + + "| +--Project| Project| Patterns: test.b.f,test.b.g, Target DU: unit0000000002|\n" + + "+----------------------+----------------+-----------------------------------------------------------------------------+\n" + + "Total line number = 10\n"; executor.executeAndCompare(sql5, expect5); expect6 = "ResultSets:\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Intersect | Intersect|LeftOrder: test.a.a,test.a.b, RightOrder: test.b.f,test.b.g, isDistinct: true|\n" - + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" - + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" - + "| +--Select | Select| Filter: test.a.a < 50000|\n" - + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: test.b.f,test.b.g|\n" - + "| +--Project | Project| Patterns: test.b.f,test.b.g|\n" - + "| +--Select | Select| Filter: test.b.f > 30000|\n" - + "| +--Project| Project| Patterns: test.b.f,test.b.g, Target DU: unit0000000002|\n" - + "+----------------------+-------------+-----------------------------------------------------------------------------+\n" - + "Total line number = 11\n"; + + "+------------------------+----------------+-----------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Intersect | Intersect|LeftOrder: test.a.a,test.a.b, RightOrder: test.b.f,test.b.g, isDistinct: true|\n" + + "| +--Reorder | Reorder| Order: test.a.a,test.a.b|\n" + + "| +--Project | Project| Patterns: test.a.a,test.a.b|\n" + + "| +--Select | Select| Filter: test.a.a < 50000|\n" + + "| +--Project| Project| Patterns: test.a.a,test.a.b, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: test.b.f,test.b.g|\n" + + "| +--Project | Project| Patterns: test.b.f,test.b.g|\n" + + "| +--Select | Select| Filter: test.b.f > 30000|\n" + + "| +--Project| Project| Patterns: test.b.f,test.b.g, Target DU: unit0000000002|\n" + + "+------------------------+----------------+-----------------------------------------------------------------------------+\n" + + "Total line number = 12\n"; executor.executeAndCompare(sql6, expect6); } @@ -8462,57 +8506,59 @@ public void testJoinFactorizationRule() { executor.executeAndCompare(optimizing, result); String expect = "ResultSets:\n" - + "+----------------------------+-------------+------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------------+-------------+------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: t1.c1,t2.c2|\n" - + "| +--Project | Project| Patterns: t1.c1,t2.c2|\n" - + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1)|\n" - + "| +--CrossJoin | CrossJoin| PrefixA: t1, PrefixB: null|\n" - + "| +--Project | Project| Patterns: t1.*, Target DU: unit0000000002|\n" - + "| +--Union | Union|LeftOrder: t2.c2,t2.c1, RightOrder: t2.c2,t2.c1, isDistinct: false|\n" - + "| +--Reorder | Reorder| Order: t2.c1,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c1,t2.c2|\n" - + "| +--Select | Select| Filter: (t2.c2 == 2 && t3.c2 == 2)|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t2, PrefixB: t3|\n" - + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t3.c2, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: t2.c1,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c1,t2.c2|\n" - + "| +--Select | Select| Filter: (t2.c1 == t4.c1)|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t2, PrefixB: t4|\n" - + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t4.c1, Target DU: unit0000000002|\n" - + "+----------------------------+-------------+------------------------------------------------------------------+\n" - + "Total line number = 18\n"; + + "+------------------------------+----------------+------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------------+----------------+------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: t1.c1,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c1,t2.c2|\n" + + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1)|\n" + + "| +--CrossJoin | CrossJoin| PrefixA: t1, PrefixB: null|\n" + + "| +--Project | Project| Patterns: t1.c1, Target DU: unit0000000002|\n" + + "| +--Union | Union|LeftOrder: t2.c2,t2.c1, RightOrder: t2.c2,t2.c1, isDistinct: false|\n" + + "| +--Reorder | Reorder| Order: t2.c2,t2.c1|\n" + + "| +--Project | Project| Patterns: t2.c2,t2.c1|\n" + + "| +--Select | Select| Filter: (t2.c2 == 2 && t3.c2 == 2)|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t2, PrefixB: t3|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t3.c2, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: t2.c2,t2.c1|\n" + + "| +--Project | Project| Patterns: t2.c2,t2.c1|\n" + + "| +--Select | Select| Filter: (t2.c1 == t4.c1)|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t2, PrefixB: t4|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t4.c1, Target DU: unit0000000002|\n" + + "+------------------------------+----------------+------------------------------------------------------------------+\n" + + "Total line number = 19\n"; assertEquals(expect, executor.execute("EXPLAIN " + statement)); executor.execute(closeRule); assertTrue(TestUtils.compareTables(executor.execute(optimizing), result)); expect = "ResultSets:\n" - + "+----------------------+-------------+------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+----------------------+-------------+------------------------------------------------------------------+\n" - + "|Union | Union|LeftOrder: t1.c1,t2.c2, RightOrder: t1.c1,t2.c2, isDistinct: false|\n" - + "| +--Reorder | Reorder| Order: t1.c1,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c2,t1.c1|\n" - + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1 && t2.c2 == 2 && t3.c2 == 2)|\n" - + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: t3|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" - + "| +--Project| Project| Patterns: t1.*, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t2.*, Target DU: unit0000000002|\n" - + "| +--Project | Project| Patterns: t3.*, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: t1.c1,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c2,t1.c1|\n" - + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1 && t2.c1 == t4.c1)|\n" - + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: t4|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" - + "| +--Project| Project| Patterns: t1.*, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t2.*, Target DU: unit0000000002|\n" - + "| +--Project | Project| Patterns: t4.*, Target DU: unit0000000002|\n" - + "+----------------------+-------------+------------------------------------------------------------------+\n" - + "Total line number = 17\n"; + + "+------------------------+----------------+------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+------------------------+----------------+------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Union | Union|LeftOrder: t1.c1,t2.c2, RightOrder: t1.c1,t2.c2, isDistinct: false|\n" + + "| +--Reorder | Reorder| Order: t1.c1,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c1,t2.c2|\n" + + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1 && t2.c2 == 2 && t3.c2 == 2)|\n" + + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: t3|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" + + "| +--Project| Project| Patterns: t1.c1, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Project | Project| Patterns: t3.c2, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: t1.c1,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c1,t2.c2|\n" + + "| +--Select | Select| Filter: (t1.c1 == t2.c1 && t1.c1 > 1 && t2.c1 == t4.c1)|\n" + + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: t4|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" + + "| +--Project| Project| Patterns: t1.c1, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Project | Project| Patterns: t4.c1, Target DU: unit0000000002|\n" + + "+------------------------+----------------+------------------------------------------------------------------+\n" + + "Total line number = 18\n"; assertEquals(expect, executor.execute("EXPLAIN " + statement)); statement = @@ -8541,49 +8587,51 @@ public void testJoinFactorizationRule() { executor.executeAndCompare(optimizing, result); expect = "ResultSets:\n" - + "+--------------------------+-------------+------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------------+-------------+------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: t1.c2,t2.c2|\n" - + "| +--Project | Project| Patterns: t1.c2,t2.c2|\n" - + "| +--Select | Select| Filter: (t1.c1 == t2.c1)|\n" - + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: null|\n" - + "| +--Project | Project| Patterns: t2.*, Target DU: unit0000000002|\n" - + "| +--Union | Union|LeftOrder: t1.c2,t1.c1, RightOrder: t1.c2,t1.c1, isDistinct: false|\n" - + "| +--Reorder | Reorder| Order: t1.c1,t1.c2|\n" - + "| +--Project | Project| Patterns: t1.c1,t1.c2|\n" - + "| +--Select | Select| Filter: (t1.c1 == 1)|\n" - + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: t1.c1,t1.c2|\n" - + "| +--Project | Project| Patterns: t1.c1,t1.c2|\n" - + "| +--Select | Select| Filter: (t1.c1 == 2)|\n" - + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" - + "+--------------------------+-------------+------------------------------------------------------------------+\n" - + "Total line number = 14\n"; + + "+----------------------------+----------------+------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------------+----------------+------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: t1.c2,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c2,t2.c2|\n" + + "| +--Select | Select| Filter: (t1.c1 == t2.c1)|\n" + + "| +--CrossJoin | CrossJoin| PrefixA: t2, PrefixB: null|\n" + + "| +--Project | Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Union | Union|LeftOrder: t1.c2,t1.c1, RightOrder: t1.c2,t1.c1, isDistinct: false|\n" + + "| +--Reorder | Reorder| Order: t1.c2,t1.c1|\n" + + "| +--Project | Project| Patterns: t1.c2,t1.c1|\n" + + "| +--Select | Select| Filter: (t1.c1 == 1)|\n" + + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: t1.c2,t1.c1|\n" + + "| +--Project | Project| Patterns: t1.c2,t1.c1|\n" + + "| +--Select | Select| Filter: (t1.c1 == 2)|\n" + + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" + + "+----------------------------+----------------+------------------------------------------------------------------+\n" + + "Total line number = 15\n"; assertEquals(expect, executor.execute("EXPLAIN " + statement)); executor.execute(closeRule); assertTrue(TestUtils.compareTables(executor.execute(optimizing), result)); expect = "ResultSets:\n" - + "+--------------------+-------------+------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+--------------------+-------------+------------------------------------------------------------------+\n" - + "|Union | Union|LeftOrder: t1.c2,t2.c2, RightOrder: t1.c2,t2.c2, isDistinct: false|\n" - + "| +--Reorder | Reorder| Order: t1.c2,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c2,t1.c2|\n" - + "| +--Select | Select| Filter: (t2.c1 == 1 && t1.c1 == 1)|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" - + "| +--Project| Project| Patterns: t1.*, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t2.*, Target DU: unit0000000002|\n" - + "| +--Reorder | Reorder| Order: t1.c2,t2.c2|\n" - + "| +--Project | Project| Patterns: t2.c2,t1.c2|\n" - + "| +--Select | Select| Filter: (t2.c1 == 2 && t1.c1 == 2)|\n" - + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" - + "| +--Project| Project| Patterns: t1.*, Target DU: unit0000000002|\n" - + "| +--Project| Project| Patterns: t2.*, Target DU: unit0000000002|\n" - + "+--------------------+-------------+------------------------------------------------------------------+\n" - + "Total line number = 13\n"; + + "+----------------------+----------------+------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+----------------------+----------------+------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Union | Union|LeftOrder: t1.c2,t2.c2, RightOrder: t1.c2,t2.c2, isDistinct: false|\n" + + "| +--Reorder | Reorder| Order: t1.c2,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c2,t2.c2|\n" + + "| +--Select | Select| Filter: (t2.c1 == 1 && t1.c1 == 1)|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" + + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "| +--Reorder | Reorder| Order: t1.c2,t2.c2|\n" + + "| +--Project | Project| Patterns: t1.c2,t2.c2|\n" + + "| +--Select | Select| Filter: (t2.c1 == 2 && t1.c1 == 2)|\n" + + "| +--CrossJoin| CrossJoin| PrefixA: t1, PrefixB: t2|\n" + + "| +--Project| Project| Patterns: t1.c1,t1.c2, Target DU: unit0000000002|\n" + + "| +--Project| Project| Patterns: t2.c1,t2.c2, Target DU: unit0000000002|\n" + + "+----------------------+----------------+------------------------------------------------------------------+\n" + + "Total line number = 14\n"; assertEquals(expect, executor.execute("EXPLAIN " + statement)); } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/tag/TagIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/tag/TagIT.java index 1e18619693..6103c13f00 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/tag/TagIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/tag/TagIT.java @@ -283,7 +283,7 @@ private String execute(String statement) { if (res.getParseErrorMsg() != null && !res.getParseErrorMsg().equals("")) { LOGGER.error( - "Statement: \"{}\" execute fail. Caused by: ", statement, res.getParseErrorMsg()); + "Statement: \"{}\" execute fail. Caused by: {}", statement, res.getParseErrorMsg()); fail(); return ""; } @@ -523,6 +523,101 @@ public void testBasicQuery() { executeAndCompare(statement, expected); } + @Test + public void testKeyFilter() { + String statement = "SELECT s FROM ah.* WHERE key < 100;"; + String expected = + "ResultSets:\n" + + "+---+---------+-----------------------+\n" + + "|key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|\n" + + "+---+---------+-----------------------+\n" + + "| 0| 1| 3|\n" + + "| 1| 2| 4|\n" + + "| 2| 3| 5|\n" + + "| 3| 4| 6|\n" + + "+---+---------+-----------------------+\n" + + "Total line number = 4\n"; + executeAndCompare(statement, expected); + + statement = "SELECT s FROM ah.* WHERE key >= 2 WITHOUT TAG;"; + expected = + "ResultSets:\n" + + "+---+---------+---------+\n" + + "|key|ah.hr01.s|ah.hr02.s|\n" + + "+---+---------+---------+\n" + + "| 2| 3| null|\n" + + "| 3| 4| null|\n" + + "|100| null| true|\n" + + "+---+---------+---------+\n" + + "Total line number = 3\n"; + executeAndCompare(statement, expected); + + statement = "SELECT s FROM ah.* WHERE key > 2 and key < 1000 with t1=v1;"; + expected = + "ResultSets:\n" + + "+---+-----------------------+----------------+\n" + + "|key|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s{t1=v1}|\n" + + "+---+-----------------------+----------------+\n" + + "| 3| 6| null|\n" + + "|400| null| false|\n" + + "+---+-----------------------+----------------+\n" + + "Total line number = 2\n"; + executeAndCompare(statement, expected); + + statement = "SELECT s FROM ah.* WHERE key > 2 and key < 1000 with_precise t1=v1;"; + expected = + "ResultSets:\n" + + "+---+----------------+\n" + + "|key|ah.hr02.s{t1=v1}|\n" + + "+---+----------------+\n" + + "|400| false|\n" + + "+---+----------------+\n" + + "Total line number = 1\n"; + executeAndCompare(statement, expected); + } + + @Test + public void testValueFilter() { + // 至少有一列的值大于等于4 + String statement = "SELECT s FROM ah.hr01 WHERE s >= 4;"; + String expected = + "ResultSets:\n" + + "+---+---------+-----------------------+\n" + + "|key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|\n" + + "+---+---------+-----------------------+\n" + + "| 1| 2| 4|\n" + + "| 2| 3| 5|\n" + + "| 3| 4| 6|\n" + + "+---+---------+-----------------------+\n" + + "Total line number = 3\n"; + executeAndCompare(statement, expected); + + // 每列的值均大于等于4 + statement = "SELECT s FROM ah.hr01 WHERE s &>= 4;"; + expected = + "ResultSets:\n" + + "+---+---------+-----------------------+\n" + + "|key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|\n" + + "+---+---------+-----------------------+\n" + + "| 3| 4| 6|\n" + + "+---+---------+-----------------------+\n" + + "Total line number = 1\n"; + executeAndCompare(statement, expected); + + statement = "SELECT s FROM ah.hr01 WHERE s >= 4 with t1=*;"; + expected = + "ResultSets:\n" + + "+---+-----------------------+\n" + + "|key|ah.hr01.s{t1=v1,t2=vv1}|\n" + + "+---+-----------------------+\n" + + "| 1| 4|\n" + + "| 2| 5|\n" + + "| 3| 6|\n" + + "+---+-----------------------+\n" + + "Total line number = 3\n"; + executeAndCompare(statement, expected); + } + @Test public void testQueryWithoutTags() { String statement = "SELECT s FROM ah.*;"; @@ -704,16 +799,16 @@ public void testDeleteWithTag() { statement = "SELECT s FROM ah.*;"; expected = "ResultSets:\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr02.s{t1=v1}|ah.hr03.s{t1=v1,t2=vv2}|ah.hr03.s{t1=vv1,t2=v2}|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| 0| 1| 3| null| null| null| null|\n" - + "| 1| 2| 4| null| null| null| null|\n" - + "| 2| 3| 5| null| null| null| null|\n" - + "| 3| 4| 6| null| null| null| null|\n" - + "| 100| null| null| true| null| null| null|\n" - + "|1600| null| null| null| null| null| true|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr03.s{t1=vv1,t2=v2}|\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + + "| 0| 1| 3| null| null|\n" + + "| 1| 2| 4| null| null|\n" + + "| 2| 3| 5| null| null|\n" + + "| 3| 4| 6| null| null|\n" + + "| 100| null| null| true| null|\n" + + "|1600| null| null| null| true|\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + "Total line number = 6\n"; executeAndCompare(statement, expected); } @@ -745,17 +840,17 @@ public void testDeleteWithMultiTags() { statement = "SELECT s FROM ah.*;"; expected = "ResultSets:\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr02.s{t1=v1}|ah.hr03.s{t1=v1,t2=vv2}|ah.hr03.s{t1=vv1,t2=v2}|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| 0| 1| 3| null| null| null| null|\n" - + "| 1| 2| 4| null| null| null| null|\n" - + "| 2| 3| 5| null| null| null| null|\n" - + "| 3| 4| 6| null| null| null| null|\n" - + "| 100| null| null| true| null| null| null|\n" - + "| 400| null| null| null| false| null| null|\n" - + "|1600| null| null| null| null| null| true|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" + + "+----+---------+-----------------------+---------+----------------+-----------------------+\n" + + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr02.s{t1=v1}|ah.hr03.s{t1=vv1,t2=v2}|\n" + + "+----+---------+-----------------------+---------+----------------+-----------------------+\n" + + "| 0| 1| 3| null| null| null|\n" + + "| 1| 2| 4| null| null| null|\n" + + "| 2| 3| 5| null| null| null|\n" + + "| 3| 4| 6| null| null| null|\n" + + "| 100| null| null| true| null| null|\n" + + "| 400| null| null| null| false| null|\n" + + "|1600| null| null| null| null| true|\n" + + "+----+---------+-----------------------+---------+----------------+-----------------------+\n" + "Total line number = 7\n"; executeAndCompare(statement, expected); @@ -765,16 +860,16 @@ public void testDeleteWithMultiTags() { statement = "SELECT s FROM ah.*;"; expected = "ResultSets:\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr02.s{t1=v1}|ah.hr03.s{t1=v1,t2=vv2}|ah.hr03.s{t1=vv1,t2=v2}|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| 0| 1| 3| null| null| null| null|\n" - + "| 1| 2| 4| null| null| null| null|\n" - + "| 2| 3| 5| null| null| null| null|\n" - + "| 3| 4| 6| null| null| null| null|\n" - + "| 100| null| null| true| null| null| null|\n" - + "|1600| null| null| null| null| null| true|\n" - + "+----+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + + "| key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr03.s{t1=vv1,t2=v2}|\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + + "| 0| 1| 3| null| null|\n" + + "| 1| 2| 4| null| null|\n" + + "| 2| 3| 5| null| null|\n" + + "| 3| 4| 6| null| null|\n" + + "| 100| null| null| true| null|\n" + + "|1600| null| null| null| true|\n" + + "+----+---------+-----------------------+---------+-----------------------+\n" + "Total line number = 6\n"; executeAndCompare(statement, expected); @@ -784,15 +879,15 @@ public void testDeleteWithMultiTags() { statement = "SELECT s FROM ah.*;"; expected = "ResultSets:\n" - + "+---+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "|key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|ah.hr02.s{t1=v1}|ah.hr03.s{t1=v1,t2=vv2}|ah.hr03.s{t1=vv1,t2=v2}|\n" - + "+---+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" - + "| 0| 1| 3| null| null| null| null|\n" - + "| 1| 2| 4| null| null| null| null|\n" - + "| 2| 3| 5| null| null| null| null|\n" - + "| 3| 4| 6| null| null| null| null|\n" - + "|100| null| null| true| null| null| null|\n" - + "+---+---------+-----------------------+---------+----------------+-----------------------+-----------------------+\n" + + "+---+---------+-----------------------+---------+\n" + + "|key|ah.hr01.s|ah.hr01.s{t1=v1,t2=vv1}|ah.hr02.s|\n" + + "+---+---------+-----------------------+---------+\n" + + "| 0| 1| 3| null|\n" + + "| 1| 2| 4| null|\n" + + "| 2| 3| 5| null|\n" + + "| 3| 4| 6| null|\n" + + "|100| null| null| true|\n" + + "+---+---------+-----------------------+---------+\n" + "Total line number = 5\n"; executeAndCompare(statement, expected); } diff --git a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/udf/UDFIT.java b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/udf/UDFIT.java index 550ae41358..278051b348 100644 --- a/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/udf/UDFIT.java +++ b/test/src/test/java/cn/edu/tsinghua/iginx/integration/func/udf/UDFIT.java @@ -1039,30 +1039,32 @@ public void testRowTransform() { ret = tool.execute(query); expected = "ResultSets:\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: test.a,cos(test.a)|\n" - + "| +--RowTransform| RowTransform|FuncList(Name, FuncType): (arithmetic_expr, System), (cos, UDF), MappingType: RowMapping|\n" - + "| +--Project | Project| Patterns: test.a|\n" - + "| +--Project | Project| Patterns: test.a, Target DU: unit0000000002|\n" - + "+-----------------+-------------+----------------------------------------------------------------------------------------+\n" - + "Total line number = 4\n"; + + "+-------------------+----------------+----------------------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------+----------------+----------------------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: test.a,cos(test.a)|\n" + + "| +--RowTransform| RowTransform|FuncList(Name, FuncType): (arithmetic_expr, System), (cos, UDF), MappingType: RowMapping|\n" + + "| +--Project | Project| Patterns: test.a|\n" + + "| +--Project | Project| Patterns: test.a, Target DU: unit0000000002|\n" + + "+-------------------+----------------+----------------------------------------------------------------------------------------+\n" + + "Total line number = 5\n"; assertEquals(expected, ret.getResultInString(false, "")); query = "explain select cos(a), pow(b, 2) from test;"; ret = tool.execute(query); expected = "ResultSets:\n" - + "+-----------------+-------------+-------------------------------------------------------------------------+\n" - + "| Logical Tree|Operator Type| Operator Info|\n" - + "+-----------------+-------------+-------------------------------------------------------------------------+\n" - + "|Reorder | Reorder| Order: *|\n" - + "| +--RowTransform| RowTransform|FuncList(Name, FuncType): (cos, UDF), (pow, UDF), MappingType: RowMapping|\n" - + "| +--Project | Project| Patterns: test.b,test.a|\n" - + "| +--Project | Project| Patterns: test.a,test.b, Target DU: unit0000000002|\n" - + "+-----------------+-------------+-------------------------------------------------------------------------+\n" - + "Total line number = 4\n"; + + "+-------------------+----------------+-------------------------------------------------------------------------+\n" + + "| Logical Tree| Operator Type| Operator Info|\n" + + "+-------------------+----------------+-------------------------------------------------------------------------+\n" + + "|RemoveNullColumn |RemoveNullColumn| RemoveNullColumn|\n" + + "| +--Reorder | Reorder| Order: *|\n" + + "| +--RowTransform| RowTransform|FuncList(Name, FuncType): (cos, UDF), (pow, UDF), MappingType: RowMapping|\n" + + "| +--Project | Project| Patterns: test.b,test.a|\n" + + "| +--Project | Project| Patterns: test.a,test.b, Target DU: unit0000000002|\n" + + "+-------------------+----------------+-------------------------------------------------------------------------+\n" + + "Total line number = 5\n"; assertEquals(expected, ret.getResultInString(false, "")); }