This is an automated email from the ASF dual-hosted git repository.
timothyfarkas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 671c315 DRILL-6101: Optimized implicit columns handling within scanner
671c315 is described below
commit 671c315e7ec9c0cb8e0131baeb5702107b529ee2
Author: Salim Achouche <[email protected]>
AuthorDate: Tue Jul 31 09:55:18 2018 -0700
DRILL-6101: Optimized implicit columns handling within scanner
closes #1414
---
.../drill/exec/planner/logical/DrillScanRel.java | 28 ++++++++++++++++++----
.../apache/drill/exec/store/ColumnExplorer.java | 14 +++++++----
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java
index df80a10..a64831b 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.planner.logical;
+import java.util.ArrayList;
import java.io.IOException;
import java.util.List;
@@ -61,12 +62,12 @@ public class DrillScanRel extends DrillScanRelBase
implements DrillRel {
final RelOptTable table) {
this(cluster, traits, table, false);
}
- /** Creates a DrillScan. */
+ /** Creates a DrillScan. */
public DrillScanRel(final RelOptCluster cluster, final RelTraitSet traits,
- final RelOptTable table, boolean partitionFilterPushdown) {
+ final RelOptTable table, boolean
partitionFilterPushdown) {
// By default, scan does not support project pushdown.
// Decision whether push projects into scan will be made solely in
DrillPushProjIntoScanRule.
- this(cluster, traits, table, table.getRowType(), GroupScan.ALL_COLUMNS,
partitionFilterPushdown);
+ this(cluster, traits, table, table.getRowType(),
getProjectedColumns(table, true), partitionFilterPushdown);
this.settings = PrelUtil.getPlannerSettings(cluster.getPlanner());
}
@@ -78,7 +79,7 @@ public class DrillScanRel extends DrillScanRelBase implements
DrillRel {
/** Creates a DrillScan. */
public DrillScanRel(final RelOptCluster cluster, final RelTraitSet traits,
- final RelOptTable table, final RelDataType rowType, final
List<SchemaPath> columns, boolean partitionFilterPushdown) {
+ final RelOptTable table, final RelDataType rowType,
final List<SchemaPath> columns, boolean partitionFilterPushdown) {
super(DRILL_LOGICAL, cluster, traits, table);
this.settings = PrelUtil.getPlannerSettings(cluster.getPlanner());
this.rowType = rowType;
@@ -100,7 +101,7 @@ public class DrillScanRel extends DrillScanRelBase
implements DrillRel {
/** Creates a DrillScanRel for a particular GroupScan */
public DrillScanRel(final RelOptCluster cluster, final RelTraitSet traits,
- final RelOptTable table, final GroupScan groupScan, final RelDataType
rowType, final List<SchemaPath> columns, boolean partitionFilterPushdown) {
+ final RelOptTable table, final GroupScan groupScan,
final RelDataType rowType, final List<SchemaPath> columns, boolean
partitionFilterPushdown) {
super(DRILL_LOGICAL, cluster, traits, table);
this.rowType = rowType;
this.columns = columns;
@@ -194,4 +195,21 @@ public class DrillScanRel extends DrillScanRelBase
implements DrillRel {
return this.partitionFilterPushdown;
}
+ private static List<SchemaPath> getProjectedColumns(final RelOptTable table,
boolean isSelectStar) {
+ List<String> columnNames = table.getRowType().getFieldNames();
+ List<SchemaPath> projectedColumns = new
ArrayList<SchemaPath>(columnNames.size());
+
+ for (String columnName : columnNames) {
+ projectedColumns.add(SchemaPath.getSimplePath(columnName));
+ }
+
+ // If the row-type doesn't contain the STAR keyword, then insert it
+ // as we are dealing with a SELECT_STAR query.
+ if (isSelectStar && !Utilities.isStarQuery(projectedColumns)) {
+ projectedColumns.add(SchemaPath.STAR_COLUMN);
+ }
+
+ return projectedColumns;
+ }
+
}
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ColumnExplorer.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ColumnExplorer.java
index 48dad7f..e435719 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ColumnExplorer.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ColumnExplorer.java
@@ -255,13 +255,17 @@ public class ColumnExplorer {
* 1. table columns
* 2. partition columns
* 3. implicit file columns
+ * If it is a star query, then only includes implicit columns that were
+ * explicitly selected (e.g., SELECT *, FILENAME FROM ..)
*/
private void init() {
- if (isStarQuery) {
- selectedImplicitColumns.putAll(allImplicitColumns);
- } else {
- for (SchemaPath column : columns) {
- String path = column.getRootSegmentPath();
+ for (SchemaPath column : columns) {
+ final String path = column.getRootSegmentPath();
+ if (isStarQuery) {
+ if (allImplicitColumns.get(path) != null) {
+ selectedImplicitColumns.put(path, allImplicitColumns.get(path));
+ }
+ } else {
if (isPartitionColumn(partitionDesignator, path)) {
selectedPartitionColumns.add(Integer.parseInt(path.substring(partitionDesignator.length())));
} else if (allImplicitColumns.get(path) != null) {