You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2015/06/22 20:00:55 UTC
[1/3] drill git commit: DRILL-3246 : Query planning support for
partition by clause in CTAS statement.
Repository: drill
Updated Branches:
refs/heads/master 6ebfbb9d0 -> 9c125b0d9
DRILL-3246 : Query planning support for partition by clause in CTAS statement.
Add partition comparator function into project under writer.
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/4c444663
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/4c444663
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/4c444663
Branch: refs/heads/master
Commit: 4c444663fa9fc9ef6104396a426f8d6fa6c4afa0
Parents: 6ebfbb9
Author: Jinfeng Ni <jn...@apache.org>
Authored: Mon Jun 1 18:14:50 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Sat Jun 20 15:42:36 2015 -0700
----------------------------------------------------------------------
.../src/main/codegen/includes/parserImpls.ftl | 11 +-
.../exec/planner/logical/CreateTableEntry.java | 3 +
.../exec/planner/logical/DrillWriterRel.java | 33 ++++
.../logical/FileSystemCreateTableEntry.java | 17 +-
.../drill/exec/planner/physical/WriterPrel.java | 3 +-
.../exec/planner/physical/WriterPrule.java | 22 ++-
.../physical/visitor/StarColumnConverter.java | 7 +-
.../sql/handlers/CreateTableHandler.java | 155 ++++++++++++++++++-
.../planner/sql/handlers/SqlHandlerUtil.java | 105 +++++++++++++
.../sql/parser/CompoundIdentifierConverter.java | 2 +-
.../exec/planner/sql/parser/SqlCreateTable.java | 42 +++--
.../exec/planner/sql/parser/SqlCreateView.java | 15 +-
.../apache/drill/exec/store/AbstractSchema.java | 9 +-
.../drill/exec/store/SubSchemaWrapper.java | 5 +-
.../exec/store/dfs/FileSystemSchemaFactory.java | 5 +-
.../drill/exec/store/dfs/FormatPlugin.java | 2 +-
.../exec/store/dfs/WorkspaceSchemaFactory.java | 6 +-
.../exec/store/dfs/easy/EasyFormatPlugin.java | 4 +-
.../drill/exec/store/dfs/easy/EasyWriter.java | 9 +-
.../exec/store/parquet/ParquetFormatPlugin.java | 4 +-
.../drill/exec/store/parquet/ParquetWriter.java | 14 +-
.../org/apache/drill/TestExampleQueries.java | 23 +++
22 files changed, 438 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
index 1605b06..eedba99 100644
--- a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
+++ b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
@@ -154,7 +154,7 @@ SqlNodeList ParseFieldList(String relType) :
}
|
{
- return null;
+ return SqlNodeList.EMPTY;
}
}
@@ -208,16 +208,23 @@ SqlNode SqlCreateTable() :
SqlParserPos pos;
SqlIdentifier tblName;
SqlNodeList fieldList;
+ SqlNodeList partitionFieldList;
SqlNode query;
}
{
+ {
+ partitionFieldList = SqlNodeList.EMPTY;
+ }
<CREATE> { pos = getPos(); }
<TABLE>
tblName = CompoundIdentifier()
fieldList = ParseFieldList("Table")
+ ( <PARTITION> <BY>
+ partitionFieldList = ParseFieldList("Partition")
+ )?
<AS>
query = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY)
{
- return new SqlCreateTable(pos, tblName, fieldList, query);
+ return new SqlCreateTable(pos, tblName, fieldList, partitionFieldList, query);
}
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java
index 673e8c6..593ba17 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java
@@ -19,6 +19,7 @@
package org.apache.drill.exec.planner.logical;
import java.io.IOException;
+import java.util.List;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.physical.base.Writer;
@@ -38,4 +39,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
public interface CreateTableEntry {
Writer getWriter(PhysicalOperator child) throws IOException;
+
+ List<String> getPartitionColumns();
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWriterRel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWriterRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWriterRel.java
index fc93c3e..94de680 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWriterRel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillWriterRel.java
@@ -19,6 +19,14 @@ package org.apache.drill.exec.planner.logical;
import java.util.List;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelCollationImpl;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.logical.data.LogicalOperator;
import org.apache.drill.common.logical.data.Writer;
import org.apache.drill.exec.planner.common.DrillWriterRelBase;
@@ -28,9 +36,12 @@ import org.apache.calcite.plan.RelTraitSet;
public class DrillWriterRel extends DrillWriterRelBase implements DrillRel {
+ private final List<Integer> partitionKeys;
+
public DrillWriterRel(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, CreateTableEntry createTableEntry) {
super(DRILL_LOGICAL, cluster, traitSet, input, createTableEntry);
setRowType();
+ this.partitionKeys = resolvePartitionKeys();
}
@Override
@@ -47,4 +58,26 @@ public class DrillWriterRel extends DrillWriterRelBase implements DrillRel {
.setCreateTableEntry(getCreateTableEntry())
.build();
}
+
+
+ private List<Integer> resolvePartitionKeys(){
+ final List<Integer> keys = Lists.newArrayList();
+ final RelDataType inputRowType = getInput().getRowType();
+ final List<String> partitionCol = getCreateTableEntry().getPartitionColumns();
+
+ for (final String col : partitionCol) {
+ final RelDataTypeField field = inputRowType.getField(col, false, false);
+ Preconditions.checkArgument(field != null,
+ String.format("partition col %s could not be resolved in table's column lists!", col));
+ keys.add(field.getIndex());
+ }
+
+ return keys;
+ }
+
+ public List<Integer> getPartitionKeys() {
+ return this.partitionKeys;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/FileSystemCreateTableEntry.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/FileSystemCreateTableEntry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/FileSystemCreateTableEntry.java
index 6784888..672092d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/FileSystemCreateTableEntry.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/FileSystemCreateTableEntry.java
@@ -18,8 +18,10 @@
package org.apache.drill.exec.planner.logical;
import java.io.IOException;
+import java.util.List;
import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.logical.FormatPluginConfig;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.physical.base.Writer;
@@ -31,6 +33,7 @@ import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.drill.exec.store.ischema.Records;
/**
* Implements <code>CreateTableEntry</code> interface to create new tables in FileSystem storage.
@@ -41,24 +44,29 @@ public class FileSystemCreateTableEntry implements CreateTableEntry {
private FileSystemConfig storageConfig;
private FormatPlugin formatPlugin;
private String location;
+ private final List<String> partitionColumns;
@JsonCreator
public FileSystemCreateTableEntry(@JsonProperty("storageConfig") FileSystemConfig storageConfig,
@JsonProperty("formatConfig") FormatPluginConfig formatConfig,
@JsonProperty("location") String location,
+ @JsonProperty("partitionColumn") List<String> partitionColumns,
@JacksonInject StoragePluginRegistry engineRegistry)
throws ExecutionSetupException {
this.storageConfig = storageConfig;
this.formatPlugin = engineRegistry.getFormatPlugin(storageConfig, formatConfig);
this.location = location;
+ this.partitionColumns = partitionColumns;
}
public FileSystemCreateTableEntry(FileSystemConfig storageConfig,
FormatPlugin formatPlugin,
- String location) {
+ String location,
+ List<String> partitionColumns) {
this.storageConfig = storageConfig;
this.formatPlugin = formatPlugin;
this.location = location;
+ this.partitionColumns = partitionColumns;
}
@JsonProperty("storageConfig")
@@ -73,6 +81,11 @@ public class FileSystemCreateTableEntry implements CreateTableEntry {
@Override
public Writer getWriter(PhysicalOperator child) throws IOException {
- return formatPlugin.getWriter(child, location);
+ return formatPlugin.getWriter(child, location, partitionColumns);
+ }
+
+ @Override
+ public List<String> getPartitionColumns() {
+ return partitionColumns;
}
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrel.java
index ceecb03..513776d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrel.java
@@ -32,7 +32,8 @@ import org.apache.calcite.plan.RelTraitSet;
public class WriterPrel extends DrillWriterRelBase implements Prel {
-
+ public static final String PARTITION_COMPARATOR_FIELD = "P_A_R_T_I_T_I_O_N_C_O_M_P_A_R_A_T_O_R";
+ public static final String PARTITION_COMPARATOR_FUNC = "newPartitionValue";
public WriterPrel(RelOptCluster cluster, RelTraitSet traits, RelNode child, CreateTableEntry createTableEntry) {
super(Prel.DRILL_PHYSICAL, cluster, traits, child, createTableEntry);
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrule.java
index 5790665..e191423 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/WriterPrule.java
@@ -17,6 +17,12 @@
*/
package org.apache.drill.exec.planner.physical;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelCollationImpl;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.planner.common.DrillWriterRelBase;
import org.apache.drill.exec.planner.logical.DrillRel;
import org.apache.drill.exec.planner.logical.DrillWriterRel;
@@ -26,6 +32,8 @@ import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.RelTraitSet;
+import java.util.List;
+
public class WriterPrule extends Prule{
public static final RelOptRule INSTANCE = new WriterPrule();
@@ -36,10 +44,11 @@ public class WriterPrule extends Prule{
@Override
public void onMatch(RelOptRuleCall call) {
- final DrillWriterRelBase writer = call.rel(0);
+ final DrillWriterRel writer = call.rel(0);
final RelNode input = call.rel(1);
- final RelTraitSet traits = input.getTraitSet().plus(Prel.DRILL_PHYSICAL);
+ final RelCollation collation = getCollation(writer.getPartitionKeys());
+ final RelTraitSet traits = input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation);
final RelNode convertedInput = convert(input, traits);
if (!new WriteTraitPull(call).go(writer, convertedInput)) {
@@ -50,6 +59,15 @@ public class WriterPrule extends Prule{
}
}
+ private RelCollation getCollation(List<Integer> keys){
+ List<RelFieldCollation> fields = Lists.newArrayList();
+ for (int key : keys) {
+ fields.add(new RelFieldCollation(key));
+ }
+ return RelCollationImpl.of(fields);
+ }
+
+
private class WriteTraitPull extends SubsetTransformer<DrillWriterRelBase, RuntimeException> {
public WriteTraitPull(RelOptRuleCall call) {
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/StarColumnConverter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/StarColumnConverter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/StarColumnConverter.java
index 7a471d7..0148d47 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/StarColumnConverter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/StarColumnConverter.java
@@ -90,12 +90,15 @@ public class StarColumnConverter extends BasePrelVisitor<Prel, Void, RuntimeExce
}
}
+ // Note: the logic of handling * column for Writer is moved to ProjectForWriterVisitor.
+
@Override
public Prel visitWriter(WriterPrel prel, Void value) throws RuntimeException {
- Prel child = ((Prel) prel.getInput(0)).accept(this, null);
+ RelNode child = ((Prel) prel.getInput(0)).accept(this, null);
if (prefixedForStar) {
prefixedForWriter = true;
- return insertProjUnderScreenOrWriter(prel, prel.getInput().getRowType(), child);
+ // return insertProjUnderScreenOrWriter(prel, prel.getInput().getRowType(), child);
+ return (Prel) prel.copy(prel.getTraitSet(), Collections.singletonList(child));
} else {
return prel;
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
index 2866b8c..b867549 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
@@ -18,13 +18,32 @@
package org.apache.drill.exec.planner.sql.handlers;
import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.tools.RelConversionException;
import org.apache.calcite.tools.ValidationException;
+import org.apache.calcite.util.Pair;
import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.exec.expr.TypeHelper;
import org.apache.drill.exec.physical.PhysicalPlan;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.planner.logical.DrillRel;
@@ -32,12 +51,18 @@ import org.apache.drill.exec.planner.logical.DrillScreenRel;
import org.apache.drill.exec.planner.logical.DrillStoreRel;
import org.apache.drill.exec.planner.logical.DrillWriterRel;
import org.apache.drill.exec.planner.physical.Prel;
+import org.apache.drill.exec.planner.physical.ProjectAllowDupPrel;
+import org.apache.drill.exec.planner.physical.ProjectPrel;
+import org.apache.drill.exec.planner.physical.WriterPrel;
+import org.apache.drill.exec.planner.physical.visitor.BasePrelVisitor;
+import org.apache.drill.exec.planner.sql.DrillSqlOperator;
import org.apache.drill.exec.planner.sql.DrillSqlWorker;
import org.apache.drill.exec.planner.sql.SchemaUtilites;
import org.apache.drill.exec.planner.sql.parser.SqlCreateTable;
import org.apache.drill.exec.store.AbstractSchema;
import org.apache.drill.exec.util.Pointer;
import org.apache.drill.exec.work.foreman.ForemanSetupException;
+import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
public class CreateTableHandler extends DefaultSqlHandler {
public CreateTableHandler(SqlHandlerConfig config, Pointer<String> textPlan) {
@@ -52,6 +77,7 @@ public class CreateTableHandler extends DefaultSqlHandler {
final RelNode newTblRelNode =
SqlHandlerUtil.resolveNewTableRel(false, planner, sqlCreateTable.getFieldNames(), sqlCreateTable.getQuery());
+
final AbstractSchema drillSchema =
SchemaUtilites.resolveToMutableDrillSchema(context.getNewDefaultSchema(), sqlCreateTable.getSchemaPath());
final String schemaPath = drillSchema.getFullSchemaName();
@@ -62,12 +88,14 @@ public class CreateTableHandler extends DefaultSqlHandler {
.build();
}
- log("Optiq Logical", newTblRelNode);
+ final RelNode newTblRelNodeWithPCol = SqlHandlerUtil.qualifyPartitionCol(newTblRelNode, sqlCreateTable.getPartitionColumns());
+
+ log("Optiq Logical", newTblRelNodeWithPCol);
// Convert the query to Drill Logical plan and insert a writer operator on top.
- DrillRel drel = convertToDrel(newTblRelNode, drillSchema, newTblName);
+ DrillRel drel = convertToDrel(newTblRelNodeWithPCol, drillSchema, newTblName, sqlCreateTable.getPartitionColumns());
log("Drill Logical", drel);
- Prel prel = convertToPrel(drel);
+ Prel prel = convertToPrel(drel, newTblRelNode.getRowType(), sqlCreateTable.getPartitionColumns());
log("Drill Physical", prel);
PhysicalOperator pop = convertToPop(prel);
PhysicalPlan plan = convertToPlan(pop);
@@ -76,7 +104,8 @@ public class CreateTableHandler extends DefaultSqlHandler {
return plan;
}
- private DrillRel convertToDrel(RelNode relNode, AbstractSchema schema, String tableName) throws RelConversionException {
+ private DrillRel convertToDrel(RelNode relNode, AbstractSchema schema, String tableName, List<String> partitionColumns)
+ throws RelConversionException {
RelNode convertedRelNode = planner.transform(DrillSqlWorker.LOGICAL_RULES,
relNode.getTraitSet().plus(DrillRel.DRILL_LOGICAL), relNode);
@@ -85,8 +114,122 @@ public class CreateTableHandler extends DefaultSqlHandler {
}
DrillWriterRel writerRel = new DrillWriterRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(),
- convertedRelNode, schema.createNewTable(tableName));
+ convertedRelNode, schema.createNewTable(tableName, partitionColumns));
return new DrillScreenRel(writerRel.getCluster(), writerRel.getTraitSet(), writerRel);
}
-}
+ private Prel convertToPrel(RelNode drel, RelDataType inputRowType, List<String> partitionColumns)
+ throws RelConversionException, SqlUnsupportedException {
+ Prel prel = convertToPrel(drel);
+
+ prel = prel.accept(new ProjectForWriterVisitor(inputRowType, partitionColumns), null);
+
+ return prel;
+ }
+
+ /**
+ * A PrelVisitor which will insert a project under Writer.
+ *
+ * For CTAS : create table t1 partition by (con_A) select * from T1;
+ * A Project with Item expr will be inserted, in addition to *. We need insert another Project to remove
+ * this additional expression.
+ *
+ * In addition, to make execution's implementation easier, a special field is added to Project :
+ * PARTITION_COLUMN_IDENTIFIER = newPartitionValue(Partition_colA)
+ * || newPartitionValue(Partition_colB)
+ * || ...
+ * || newPartitionValue(Partition_colN).
+ */
+ private class ProjectForWriterVisitor extends BasePrelVisitor<Prel, Void, RuntimeException> {
+
+ private final RelDataType queryRowType;
+ private final List<String> partitionColumns;
+
+ ProjectForWriterVisitor(RelDataType queryRowType, List<String> partitionColumns) {
+ this.queryRowType = queryRowType;
+ this.partitionColumns = partitionColumns;
+ }
+
+ @Override
+ public Prel visitPrel(Prel prel, Void value) throws RuntimeException {
+ List<RelNode> children = Lists.newArrayList();
+ for(Prel child : prel){
+ child = child.accept(this, null);
+ children.add(child);
+ }
+
+ return (Prel) prel.copy(prel.getTraitSet(), children);
+
+ }
+
+ @Override
+ public Prel visitWriter(WriterPrel prel, Void value) throws RuntimeException {
+
+ final Prel child = ((Prel)prel.getInput()).accept(this, null);
+
+ final RelDataType childRowType = child.getRowType();
+
+ final RelOptCluster cluster = prel.getCluster();
+
+ final List<RexNode> exprs = Lists.newArrayListWithExpectedSize(queryRowType.getFieldCount() + 1);
+ final List<String> fieldnames = new ArrayList<String>(queryRowType.getFieldNames());
+
+ for (final RelDataTypeField field : queryRowType.getFieldList()) {
+ exprs.add(RexInputRef.of(field.getIndex(), queryRowType));
+ }
+
+ // No partition columns.
+ if (partitionColumns.size() == 0) {
+ final ProjectPrel projectUnderWriter = new ProjectAllowDupPrel(cluster,
+ cluster.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL), child, exprs, queryRowType);
+
+ return (Prel) prel.copy(projectUnderWriter.getTraitSet(),
+ Collections.singletonList( (RelNode) projectUnderWriter));
+ } else {
+ // find list of partiiton columns.
+ final List<RexNode> partitionColumnExprs = Lists.newArrayListWithExpectedSize(partitionColumns.size());
+ for (final String colName : partitionColumns) {
+ final RelDataTypeField field = childRowType.getField(colName, false, false);
+
+ if (field == null) {
+ throw UserException.validationError()
+ .message("Partition column %s is not in the SELECT list of CTAS!", colName)
+ .build();
+ }
+
+ partitionColumnExprs.add(RexInputRef.of(field.getIndex(), childRowType));
+ }
+
+ // Add partition column comparator to Project's field name list.
+ fieldnames.add(WriterPrel.PARTITION_COMPARATOR_FIELD);
+
+ // Add partition column comparator to Project's expression list.
+ final RexNode partionColComp = createPartitionColComparator(prel.getCluster().getRexBuilder(), partitionColumnExprs);
+ exprs.add(partionColComp);
+
+
+ final RelDataType rowTypeWithPCComp = RexUtil.createStructType(cluster.getTypeFactory(), exprs, fieldnames);
+
+ final ProjectPrel projectUnderWriter = new ProjectAllowDupPrel(cluster,
+ cluster.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL), child, exprs, rowTypeWithPCComp);
+
+ return (Prel) prel.copy(projectUnderWriter.getTraitSet(),
+ Collections.singletonList( (RelNode) projectUnderWriter));
+ }
+ }
+
+ }
+
+ private RexNode createPartitionColComparator(final RexBuilder rexBuilder, List<RexNode> inputs) {
+ final DrillSqlOperator op = new DrillSqlOperator(WriterPrel.PARTITION_COMPARATOR_FUNC, 1, true);
+
+ final List<RexNode> compFuncs = Lists.newArrayListWithExpectedSize(inputs.size());
+
+ for (final RexNode input : inputs) {
+ compFuncs.add(rexBuilder.makeCall(op, ImmutableList.of(input)));
+ }
+
+ return RexUtil.composeDisjunction(rexBuilder, compFuncs, false);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
index 3edcdb2..60287dc 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
@@ -17,14 +17,24 @@
*/
package org.apache.drill.exec.planner.sql.handlers;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
import org.apache.calcite.schema.Table;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlWriter;
import org.apache.calcite.sql.TypedSqlNode;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.tools.Planner;
import org.apache.calcite.tools.RelConversionException;
import org.apache.drill.common.exceptions.DrillException;
import org.apache.drill.common.exceptions.DrillRuntimeException;
import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.exec.planner.StarColumnHelper;
import org.apache.drill.exec.planner.common.DrillRelOptUtil;
import org.apache.drill.exec.planner.sql.DirectPlan;
import org.apache.drill.exec.planner.types.DrillFixedRelDataTypeImpl;
@@ -37,6 +47,7 @@ import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlNode;
import org.apache.drill.exec.store.ischema.Records;
+import java.util.AbstractList;
import java.util.HashSet;
import java.util.List;
@@ -123,6 +134,89 @@ public class SqlHandlerUtil {
}
}
+ /**
+ * Resolve the partition columns specified in "PARTITION BY" clause of CTAS statement.
+ *
+ * A partition column is resolved, either (1) the same column appear in the select list of CTAS
+ * or (2) CTAS has a * in select list.
+ *
+ * In the second case, a PROJECT with ITEM expression would be created and returned.
+ * Throw validation error if a partition column is not resolved correctly.
+ *
+ * @param input : the RelNode represents the select statement in CTAS.
+ * @param partitionColumns : the list of partition columns.
+ * @return : 1) the original RelNode input, if all partition columns are in select list of CTAS
+ * 2) a New Project, if a partition column is resolved to * column in select list
+ * 3) validation error, if partition column is not resolved.
+ */
+ public static RelNode qualifyPartitionCol(RelNode input, List<String> partitionColumns) {
+
+ final RelDataType inputRowType = input.getRowType();
+
+ final List<RexNode> colRefStarExprs = Lists.newArrayList();
+ final List<String> colRefStarNames = Lists.newArrayList();
+ final RexBuilder builder = input.getCluster().getRexBuilder();
+ final int originalFieldSize = inputRowType.getFieldCount();
+
+ for (final String col : partitionColumns) {
+ final RelDataTypeField field = inputRowType.getField(col, false, false);
+
+ if (field == null) {
+ throw UserException.validationError()
+ .message("Partition column %s is not in the SELECT list of CTAS!", col)
+ .build();
+ } else {
+ if (field.getName().startsWith(StarColumnHelper.STAR_COLUMN)) {
+ colRefStarNames.add(col);
+
+ final List<RexNode> operands = Lists.newArrayList();
+ operands.add(new RexInputRef(field.getIndex(), field.getType()));
+ operands.add(builder.makeLiteral(col));
+ final RexNode item = builder.makeCall(SqlStdOperatorTable.ITEM, operands);
+ colRefStarExprs.add(item);
+ }
+ }
+ }
+
+ if (colRefStarExprs.isEmpty()) {
+ return input;
+ } else {
+ final List<String> names =
+ new AbstractList<String>() {
+ @Override
+ public String get(int index) {
+ if (index < originalFieldSize) {
+ return inputRowType.getFieldNames().get(index);
+ } else {
+ return colRefStarNames.get(index - originalFieldSize);
+ }
+ }
+
+ @Override
+ public int size() {
+ return originalFieldSize + colRefStarExprs.size();
+ }
+ };
+
+ final List<RexNode> refs =
+ new AbstractList<RexNode>() {
+ public int size() {
+ return originalFieldSize + colRefStarExprs.size();
+ }
+
+ public RexNode get(int index) {
+ if (index < originalFieldSize) {
+ return RexInputRef.of(index, inputRowType.getFieldList());
+ } else {
+ return colRefStarExprs.get(index - originalFieldSize);
+ }
+ }
+ };
+
+ return RelOptUtil.createProject(input, refs, names, false);
+ }
+ }
+
public static Table getTableFromSchema(AbstractSchema drillSchema, String tblName) {
try {
return drillSchema.getTable(tblName);
@@ -133,4 +227,15 @@ public class SqlHandlerUtil {
"in schema [%s]: %s", tblName, drillSchema.getFullSchemaName(), e.getMessage()), e);
}
}
+
+ public static void unparseSqlNodeList(SqlWriter writer, int leftPrec, int rightPrec, SqlNodeList fieldList) {
+ writer.keyword("(");
+ fieldList.get(0).unparse(writer, leftPrec, rightPrec);
+ for (int i = 1; i<fieldList.size(); i++) {
+ writer.keyword(",");
+ fieldList.get(i).unparse(writer, leftPrec, rightPrec);
+ }
+ writer.keyword(")");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
index bfa89a5..fbc5f9b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/CompoundIdentifierConverter.java
@@ -151,7 +151,7 @@ public class CompoundIdentifierConverter extends SqlShuttle {
//SqlNode offset,
//SqlNode fetch,
rules.put(SqlSelect.class, R(D, E, D, E, E, E, D, E, D, D));
- rules.put(SqlCreateTable.class, R(D, D, E));
+ rules.put(SqlCreateTable.class, R(D, D, D, E));
rules.put(SqlCreateView.class, R(D, E, E, D));
rules.put(SqlDescribeTable.class, R(D, D, E));
rules.put(SqlDropView.class, R(D));
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateTable.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateTable.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateTable.java
index 9fd9d92..5835b10 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateTable.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateTable.java
@@ -19,8 +19,10 @@ package org.apache.drill.exec.planner.sql.parser;
import java.util.List;
+import com.google.common.base.Preconditions;
import org.apache.calcite.tools.Planner;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.ops.QueryContext;
import org.apache.drill.exec.planner.sql.handlers.AbstractSqlHandler;
import org.apache.drill.exec.planner.sql.handlers.CreateTableHandler;
@@ -39,24 +41,28 @@ import org.apache.calcite.sql.parser.SqlParserPos;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import org.apache.drill.exec.planner.sql.handlers.SqlHandlerUtil;
import org.apache.drill.exec.util.Pointer;
public class SqlCreateTable extends DrillSqlCall {
public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("CREATE_TABLE", SqlKind.OTHER) {
@Override
public SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands) {
- return new SqlCreateTable(pos, (SqlIdentifier) operands[0], (SqlNodeList) operands[1], operands[2]);
+ Preconditions.checkArgument(operands.length == 4, "SqlCreateTable.createCall() has to get 4 operands!");
+ return new SqlCreateTable(pos, (SqlIdentifier) operands[0], (SqlNodeList) operands[1], (SqlNodeList) operands[2], operands[3]);
}
};
- private SqlIdentifier tblName;
- private SqlNodeList fieldList;
- private SqlNode query;
+ private final SqlIdentifier tblName;
+ private final SqlNodeList fieldList;
+ private final SqlNodeList partitionColumns;
+ private final SqlNode query;
- public SqlCreateTable(SqlParserPos pos, SqlIdentifier tblName, SqlNodeList fieldList, SqlNode query) {
+ public SqlCreateTable(SqlParserPos pos, SqlIdentifier tblName, SqlNodeList fieldList, SqlNodeList partitionColumns, SqlNode query) {
super(pos);
this.tblName = tblName;
this.fieldList = fieldList;
+ this.partitionColumns = partitionColumns;
this.query = query;
}
@@ -70,6 +76,7 @@ public class SqlCreateTable extends DrillSqlCall {
List<SqlNode> ops = Lists.newArrayList();
ops.add(tblName);
ops.add(fieldList);
+ ops.add(partitionColumns);
ops.add(query);
return ops;
}
@@ -79,14 +86,12 @@ public class SqlCreateTable extends DrillSqlCall {
writer.keyword("CREATE");
writer.keyword("TABLE");
tblName.unparse(writer, leftPrec, rightPrec);
- if (fieldList != null && fieldList.size() > 0) {
- writer.keyword("(");
- fieldList.get(0).unparse(writer, leftPrec, rightPrec);
- for (int i=1; i<fieldList.size(); i++) {
- writer.keyword(",");
- fieldList.get(i).unparse(writer, leftPrec, rightPrec);
- }
- writer.keyword(")");
+ if (fieldList.size() > 0) {
+ SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, fieldList);
+ }
+ if (partitionColumns.size() > 0) {
+ writer.keyword("PARTITION BY");
+ SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, partitionColumns);
}
writer.keyword("AS");
query.unparse(writer, leftPrec, rightPrec);
@@ -120,16 +125,21 @@ public class SqlCreateTable extends DrillSqlCall {
}
public List<String> getFieldNames() {
- if (fieldList == null) {
- return ImmutableList.of();
+ List<String> columnNames = Lists.newArrayList();
+ for(SqlNode node : fieldList.getList()) {
+ columnNames.add(node.toString());
}
+ return columnNames;
+ }
+ public List<String> getPartitionColumns() {
List<String> columnNames = Lists.newArrayList();
- for(SqlNode node : fieldList.getList()) {
+ for(SqlNode node : partitionColumns.getList()) {
columnNames.add(node.toString());
}
return columnNames;
}
public SqlNode getQuery() { return query; }
+
}
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
index 57cfde9..a140829 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.drill.exec.planner.sql.handlers.AbstractSqlHandler;
import org.apache.drill.exec.planner.sql.handlers.SqlHandlerConfig;
+import org.apache.drill.exec.planner.sql.handlers.SqlHandlerUtil;
import org.apache.drill.exec.planner.sql.handlers.ViewHandler;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlIdentifier;
@@ -86,14 +87,8 @@ public class SqlCreateView extends DrillSqlCall {
}
writer.keyword("VIEW");
viewName.unparse(writer, leftPrec, rightPrec);
- if (fieldList != null && fieldList.size() > 0) {
- writer.keyword("(");
- fieldList.get(0).unparse(writer, leftPrec, rightPrec);
- for (int i=1; i<fieldList.size(); i++) {
- writer.keyword(",");
- fieldList.get(i).unparse(writer, leftPrec, rightPrec);
- }
- writer.keyword(")");
+ if (fieldList.size() > 0) {
+ SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, fieldList);
}
writer.keyword("AS");
query.unparse(writer, leftPrec, rightPrec);
@@ -121,10 +116,6 @@ public class SqlCreateView extends DrillSqlCall {
}
public List<String> getFieldNames() {
- if (fieldList == null) {
- return ImmutableList.of();
- }
-
List<String> fieldNames = Lists.newArrayList();
for (SqlNode node : fieldList.getList()) {
fieldNames.add(node.toString());
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractSchema.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractSchema.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractSchema.java
index 6afce1a..524fe26 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractSchema.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractSchema.java
@@ -31,6 +31,7 @@ import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.dotdrill.View;
import org.apache.drill.exec.planner.logical.CreateTableEntry;
@@ -115,7 +116,13 @@ public abstract class AbstractSchema implements Schema, SchemaPartitionExplorer
.build();
}
- public CreateTableEntry createNewTable(String tableName) {
+ /**
+ *
+ * @param tableName : new table name.
+ * @param partitionColumns : list of partition columns. Empty list if there is no partition columns.
+ * @return
+ */
+ public CreateTableEntry createNewTable(String tableName, List<String> partitionColumns) {
throw UserException.unsupportedError()
.message("Creating new tables is not supported in schema [%s]", getSchemaPath())
.build();
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/SubSchemaWrapper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/SubSchemaWrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/SubSchemaWrapper.java
index 4e50bc1..722638a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/SubSchemaWrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/SubSchemaWrapper.java
@@ -25,6 +25,7 @@ import org.apache.calcite.schema.Function;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.Table;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.planner.logical.CreateTableEntry;
import com.google.common.collect.ImmutableList;
@@ -57,8 +58,8 @@ public class SubSchemaWrapper extends AbstractSchema {
}
@Override
- public CreateTableEntry createNewTable(String tableName) {
- return innerSchema.createNewTable(tableName);
+ public CreateTableEntry createNewTable(String tableName, List<String> partitionColumns) {
+ return innerSchema.createNewTable(tableName, partitionColumns);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemSchemaFactory.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemSchemaFactory.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemSchemaFactory.java
index fa9aa89..f9445e6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemSchemaFactory.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemSchemaFactory.java
@@ -28,6 +28,7 @@ import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.ops.QueryContext;
import org.apache.drill.exec.planner.logical.CreateTableEntry;
import org.apache.drill.exec.store.AbstractSchema;
@@ -147,8 +148,8 @@ public class FileSystemSchemaFactory implements SchemaFactory{
}
@Override
- public CreateTableEntry createNewTable(String tableName) {
- return defaultSchema.createNewTable(tableName);
+ public CreateTableEntry createNewTable(String tableName, List<String> partitionColumns) {
+ return defaultSchema.createNewTable(tableName, partitionColumns);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FormatPlugin.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FormatPlugin.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FormatPlugin.java
index 5668c54..81f9f76 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FormatPlugin.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FormatPlugin.java
@@ -42,7 +42,7 @@ public interface FormatPlugin {
public FormatMatcher getMatcher();
- public AbstractWriter getWriter(PhysicalOperator child, String location) throws IOException;
+ public AbstractWriter getWriter(PhysicalOperator child, String location, List<String> partitionColumns) throws IOException;
public Set<StoragePluginOptimizerRule> getOptimizerRules();
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
index b1135d0..8e0432a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
@@ -31,6 +31,7 @@ import org.apache.calcite.schema.Table;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.ExecutionSetupException;
import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.dotdrill.DotDrillFile;
import org.apache.drill.exec.dotdrill.DotDrillType;
@@ -256,7 +257,7 @@ public class WorkspaceSchemaFactory {
}
@Override
- public CreateTableEntry createNewTable(String tableName) {
+ public CreateTableEntry createNewTable(String tableName, List<String> partitonColumns) {
String storage = schemaConfig.getOption(ExecConstants.OUTPUT_FORMAT_OPTION).string_val;
FormatPlugin formatPlugin = plugin.getFormatPlugin(storage);
if (formatPlugin == null) {
@@ -268,7 +269,8 @@ public class WorkspaceSchemaFactory {
return new FileSystemCreateTableEntry(
(FileSystemConfig) plugin.getConfig(),
formatPlugin,
- config.getLocation() + Path.SEPARATOR + tableName);
+ config.getLocation() + Path.SEPARATOR + tableName,
+ partitonColumns);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyFormatPlugin.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyFormatPlugin.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyFormatPlugin.java
index 8a18639..2918ca7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyFormatPlugin.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyFormatPlugin.java
@@ -216,8 +216,8 @@ public abstract class EasyFormatPlugin<T extends FormatPluginConfig> implements
}
@Override
- public AbstractWriter getWriter(PhysicalOperator child, String location) throws IOException {
- return new EasyWriter(child, location, this);
+ public AbstractWriter getWriter(PhysicalOperator child, String location, List<String> partitionColumns) throws IOException {
+ return new EasyWriter(child, location, partitionColumns, this);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyWriter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyWriter.java
index e12c5b3..db22568 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyWriter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/easy/EasyWriter.java
@@ -18,8 +18,10 @@
package org.apache.drill.exec.store.dfs.easy;
import java.io.IOException;
+import java.util.List;
import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.logical.FormatPluginConfig;
import org.apache.drill.common.logical.StoragePluginConfig;
import org.apache.drill.exec.physical.base.AbstractWriter;
@@ -38,12 +40,14 @@ public class EasyWriter extends AbstractWriter {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(EasyWriter.class);
private final String location;
+ private final List<String> partitionColumns;
private final EasyFormatPlugin<?> formatPlugin;
@JsonCreator
public EasyWriter(
@JsonProperty("child") PhysicalOperator child,
@JsonProperty("location") String location,
+ @JsonProperty("partitionColumns") List<String> partitionColumns,
@JsonProperty("storage") StoragePluginConfig storageConfig,
@JsonProperty("format") FormatPluginConfig formatConfig,
@JacksonInject StoragePluginRegistry engineRegistry) throws IOException, ExecutionSetupException {
@@ -52,15 +56,18 @@ public class EasyWriter extends AbstractWriter {
this.formatPlugin = (EasyFormatPlugin<?>) engineRegistry.getFormatPlugin(storageConfig, formatConfig);
Preconditions.checkNotNull(formatPlugin, "Unable to load format plugin for provided format config.");
this.location = location;
+ this.partitionColumns = partitionColumns;
}
public EasyWriter(PhysicalOperator child,
String location,
+ List<String> partitionColumns,
EasyFormatPlugin<?> formatPlugin) {
super(child);
this.formatPlugin = formatPlugin;
this.location = location;
+ this.partitionColumns = partitionColumns;
}
@JsonProperty("location")
@@ -85,7 +92,7 @@ public class EasyWriter extends AbstractWriter {
@Override
protected PhysicalOperator getNewWithChild(PhysicalOperator child) {
- return new EasyWriter(child, location, formatPlugin);
+ return new EasyWriter(child, location, partitionColumns, formatPlugin);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetFormatPlugin.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetFormatPlugin.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetFormatPlugin.java
index 322a88d..eff7872 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetFormatPlugin.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetFormatPlugin.java
@@ -119,8 +119,8 @@ public class ParquetFormatPlugin implements FormatPlugin{
}
@Override
- public AbstractWriter getWriter(PhysicalOperator child, String location) throws IOException {
- return new ParquetWriter(child, location, this);
+ public AbstractWriter getWriter(PhysicalOperator child, String location, List<String> partitionColumns) throws IOException {
+ return new ParquetWriter(child, location, partitionColumns, this);
}
public RecordWriter getRecordWriter(FragmentContext context, ParquetWriter writer) throws IOException, OutOfMemoryException {
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetWriter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetWriter.java
index 75f0e74..49c231e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetWriter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetWriter.java
@@ -18,8 +18,10 @@
package org.apache.drill.exec.store.parquet;
import java.io.IOException;
+import java.util.List;
import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.logical.FormatPluginConfig;
import org.apache.drill.common.logical.StoragePluginConfig;
import org.apache.drill.exec.physical.base.AbstractWriter;
@@ -39,12 +41,14 @@ public class ParquetWriter extends AbstractWriter {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ParquetWriter.class);
private final String location;
+ private final List<String> partitionColumns;
private final ParquetFormatPlugin formatPlugin;
@JsonCreator
public ParquetWriter(
@JsonProperty("child") PhysicalOperator child,
@JsonProperty("location") String location,
+ @JsonProperty("partitionColumns") List<String> partitionColumns,
@JsonProperty("storage") StoragePluginConfig storageConfig,
@JacksonInject StoragePluginRegistry engineRegistry) throws IOException, ExecutionSetupException {
@@ -52,15 +56,18 @@ public class ParquetWriter extends AbstractWriter {
this.formatPlugin = (ParquetFormatPlugin) engineRegistry.getFormatPlugin(storageConfig, new ParquetFormatConfig());
Preconditions.checkNotNull(formatPlugin, "Unable to load format plugin for provided format config.");
this.location = location;
+ this.partitionColumns = partitionColumns;
}
public ParquetWriter(PhysicalOperator child,
String location,
+ List<String> partitionColumns,
ParquetFormatPlugin formatPlugin) {
super(child);
this.formatPlugin = formatPlugin;
this.location = location;
+ this.partitionColumns = partitionColumns;
}
@JsonProperty("location")
@@ -73,6 +80,11 @@ public class ParquetWriter extends AbstractWriter {
return formatPlugin.getStorageConfig();
}
+ @JsonProperty("partitionColumns")
+ public List<String> getPartitionColumns() {
+ return partitionColumns;
+ }
+
@JsonIgnore
public FormatPluginConfig getFormatConfig(){
return formatPlugin.getConfig();
@@ -85,7 +97,7 @@ public class ParquetWriter extends AbstractWriter {
@Override
protected PhysicalOperator getNewWithChild(PhysicalOperator child) {
- return new ParquetWriter(child, location, formatPlugin);
+ return new ParquetWriter(child, location, partitionColumns, formatPlugin);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/4c444663/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index f0422d3..6d03d81 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -1031,4 +1031,27 @@ public class TestExampleQueries extends BaseTestQuery {
.baselineValues(1L, 1L, listOf(listOf(listOf("val1"), listOf("val2"))))
.go();
}
+
+ @Test
+ @Ignore
+ public void testPartitionCTAS() throws Exception {
+ test("use dfs_test.tmp; " +
+ "create table mytable1 partition by (r_regionkey, r_comment) as select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`");
+
+ test("use dfs_test.tmp; " +
+ "create table mytable2 partition by (r_regionkey, r_comment) as select * from cp.`tpch/region.parquet` where r_name = 'abc' ");
+
+ test("use dfs_test.tmp; " +
+ "create table mytable3 partition by (r_regionkey, n_nationkey) as " +
+ " select r.r_regionkey, r.r_name, n.n_nationkey, n.n_name from cp.`tpch/nation.parquet` n, cp.`tpch/region.parquet` r " +
+ " where n.n_regionkey = r.r_regionkey");
+
+ test("use dfs_test.tmp; " +
+ "create table mytable4 partition by (r_regionkey, r_comment) as " +
+ " select r.* from cp.`tpch/nation.parquet` n, cp.`tpch/region.parquet` r " +
+ " where n.n_regionkey = r.r_regionkey");
+
+
+ }
+
}
[2/3] drill git commit: DRILL-3316: Ensure different Sql handlers go
through same planning phases.
Posted by jn...@apache.org.
DRILL-3316: Ensure different Sql handlers go through same planning phases.
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/ffae1691
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/ffae1691
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/ffae1691
Branch: refs/heads/master
Commit: ffae1691c0cd526ed1095fbabbc0855d016790d7
Parents: 4c44466
Author: Jinfeng Ni <jn...@apache.org>
Authored: Mon Jun 15 11:57:49 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Sat Jun 20 15:42:47 2015 -0700
----------------------------------------------------------------------
.../sql/handlers/CreateTableHandler.java | 30 +--
.../planner/sql/handlers/DefaultSqlHandler.java | 266 ++++++++++---------
.../planner/sql/handlers/ExplainHandler.java | 17 +-
.../planner/sql/handlers/SqlHandlerUtil.java | 22 +-
.../exec/planner/sql/handlers/ViewHandler.java | 27 +-
.../exec/planner/sql/parser/SqlCreateView.java | 2 +-
.../exec/planner/sql/parser/SqlDropView.java | 2 +-
7 files changed, 188 insertions(+), 178 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
index b867549..920b284 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
@@ -18,8 +18,6 @@
package org.apache.drill.exec.planner.sql.handlers;
import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -27,7 +25,6 @@ import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.calcite.plan.RelOptCluster;
-import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeField;
@@ -39,16 +36,11 @@ import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.tools.RelConversionException;
import org.apache.calcite.tools.ValidationException;
-import org.apache.calcite.util.Pair;
import org.apache.drill.common.exceptions.UserException;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.exec.expr.TypeHelper;
import org.apache.drill.exec.physical.PhysicalPlan;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.planner.logical.DrillRel;
import org.apache.drill.exec.planner.logical.DrillScreenRel;
-import org.apache.drill.exec.planner.logical.DrillStoreRel;
import org.apache.drill.exec.planner.logical.DrillWriterRel;
import org.apache.drill.exec.planner.physical.Prel;
import org.apache.drill.exec.planner.physical.ProjectAllowDupPrel;
@@ -56,7 +48,6 @@ import org.apache.drill.exec.planner.physical.ProjectPrel;
import org.apache.drill.exec.planner.physical.WriterPrel;
import org.apache.drill.exec.planner.physical.visitor.BasePrelVisitor;
import org.apache.drill.exec.planner.sql.DrillSqlOperator;
-import org.apache.drill.exec.planner.sql.DrillSqlWorker;
import org.apache.drill.exec.planner.sql.SchemaUtilites;
import org.apache.drill.exec.planner.sql.parser.SqlCreateTable;
import org.apache.drill.exec.store.AbstractSchema;
@@ -72,10 +63,15 @@ public class CreateTableHandler extends DefaultSqlHandler {
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
SqlCreateTable sqlCreateTable = unwrap(sqlNode, SqlCreateTable.class);
-
final String newTblName = sqlCreateTable.getName();
+
+ final ConvertedRelNode convertedRelNode = validateAndConvert(sqlCreateTable.getQuery());
+ final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
+ final RelNode queryRelNode = convertedRelNode.getConvertedNode();
+
+
final RelNode newTblRelNode =
- SqlHandlerUtil.resolveNewTableRel(false, planner, sqlCreateTable.getFieldNames(), sqlCreateTable.getQuery());
+ SqlHandlerUtil.resolveNewTableRel(false, sqlCreateTable.getFieldNames(), validatedRowType, queryRelNode);
final AbstractSchema drillSchema =
@@ -93,7 +89,7 @@ public class CreateTableHandler extends DefaultSqlHandler {
log("Optiq Logical", newTblRelNodeWithPCol);
// Convert the query to Drill Logical plan and insert a writer operator on top.
- DrillRel drel = convertToDrel(newTblRelNodeWithPCol, drillSchema, newTblName, sqlCreateTable.getPartitionColumns());
+ DrillRel drel = convertToDrel(newTblRelNodeWithPCol, drillSchema, newTblName, sqlCreateTable.getPartitionColumns(), newTblRelNode.getRowType());
log("Drill Logical", drel);
Prel prel = convertToPrel(drel, newTblRelNode.getRowType(), sqlCreateTable.getPartitionColumns());
log("Drill Physical", prel);
@@ -104,14 +100,10 @@ public class CreateTableHandler extends DefaultSqlHandler {
return plan;
}
- private DrillRel convertToDrel(RelNode relNode, AbstractSchema schema, String tableName, List<String> partitionColumns)
- throws RelConversionException {
- RelNode convertedRelNode = planner.transform(DrillSqlWorker.LOGICAL_RULES,
- relNode.getTraitSet().plus(DrillRel.DRILL_LOGICAL), relNode);
+ private DrillRel convertToDrel(RelNode relNode, AbstractSchema schema, String tableName, List<String> partitionColumns, RelDataType queryRowType)
+ throws RelConversionException, SqlUnsupportedException {
- if (convertedRelNode instanceof DrillStoreRel) {
- throw new UnsupportedOperationException();
- }
+ final DrillRel convertedRelNode = convertToDrel(relNode);
DrillWriterRel writerRel = new DrillWriterRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(),
convertedRelNode, schema.createNewTable(tableName, partitionColumns));
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
index 5e685c8..a2858b8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
@@ -27,38 +27,21 @@ import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.plan.hep.HepPlanner;
import org.apache.calcite.rel.RelNode;
-import com.google.common.collect.ImmutableList;
-import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.hep.HepMatchOrder;
import org.apache.calcite.plan.hep.HepProgram;
import org.apache.calcite.plan.hep.HepProgramBuilder;
import org.apache.calcite.rel.RelShuttleImpl;
-import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.Join;
-import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.TableFunctionScan;
import org.apache.calcite.rel.core.TableScan;
-import org.apache.calcite.rel.logical.LogicalJoin;
-import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.logical.LogicalValues;
import org.apache.calcite.rel.metadata.CachingRelMetadataProvider;
import org.apache.calcite.rel.metadata.ChainedRelMetadataProvider;
-import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
-import org.apache.calcite.rel.rules.FilterAggregateTransposeRule;
-import org.apache.calcite.rel.rules.FilterJoinRule;
-import org.apache.calcite.rel.rules.FilterMergeRule;
-import org.apache.calcite.rel.rules.FilterProjectTransposeRule;
-import org.apache.calcite.rel.rules.JoinPushThroughJoinRule;
-import org.apache.calcite.rel.rules.JoinPushTransitivePredicatesRule;
import org.apache.calcite.rel.rules.JoinToMultiJoinRule;
import org.apache.calcite.rel.rules.LoptOptimizeJoinRule;
-import org.apache.calcite.rel.rules.ProjectMergeRule;
import org.apache.calcite.rel.rules.ProjectRemoveRule;
-import org.apache.calcite.rel.rules.SemiJoinFilterTransposeRule;
-import org.apache.calcite.rel.rules.SemiJoinJoinTransposeRule;
-import org.apache.calcite.rel.rules.SemiJoinProjectTransposeRule;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
@@ -67,7 +50,6 @@ import org.apache.calcite.sql.SqlExplainLevel;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.TypedSqlNode;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
-import org.apache.calcite.sql2rel.RelFieldTrimmer;
import org.apache.calcite.tools.Planner;
import org.apache.calcite.tools.RelConversionException;
import org.apache.calcite.tools.ValidationException;
@@ -83,12 +65,8 @@ import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
import org.apache.drill.exec.physical.base.PhysicalOperator;
import org.apache.drill.exec.physical.impl.join.JoinUtils;
import org.apache.drill.exec.planner.cost.DrillDefaultRelMetadataProvider;
-import org.apache.drill.exec.planner.logical.DrillFilterJoinRules;
import org.apache.drill.exec.planner.logical.DrillJoinRel;
-import org.apache.drill.exec.planner.logical.DrillMergeProjectRule;
import org.apache.drill.exec.planner.logical.DrillProjectRel;
-import org.apache.drill.exec.planner.logical.DrillPushFilterPastProjectRule;
-import org.apache.drill.exec.planner.logical.DrillPushProjectPastFilterRule;
import org.apache.drill.exec.planner.logical.DrillRel;
import org.apache.drill.exec.planner.logical.DrillRelFactories;
import org.apache.drill.exec.planner.logical.DrillScreenRel;
@@ -172,19 +150,15 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
}
}
+
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
- SqlNode rewrittenSqlNode = rewrite(sqlNode);
- TypedSqlNode validatedTypedSqlNode = validateNode(rewrittenSqlNode);
- SqlNode validated = validatedTypedSqlNode.getSqlNode();
- RelDataType validatedRowType = validatedTypedSqlNode.getType();
-
- RelNode rel = convertToRel(validated);
- rel = preprocessNode(rel);
-
+ final ConvertedRelNode convertedRelNode = validateAndConvert(sqlNode);
+ final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
+ final RelNode queryRelNode = convertedRelNode.getConvertedNode();
- log("Optiq Logical", rel);
- DrillRel drel = convertToDrel(rel, validatedRowType);
+ log("Optiq Logical", queryRelNode);
+ DrillRel drel = convertToDrel(queryRelNode, validatedRowType);
log("Drill Logical", drel);
Prel prel = convertToPrel(drel);
@@ -195,90 +169,45 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
return plan;
}
- protected DrillRel addRenamedProject(DrillRel rel, RelDataType validatedRowType) {
- RelDataType t = rel.getRowType();
-
- RexBuilder b = rel.getCluster().getRexBuilder();
- List<RexNode> projections = Lists.newArrayList();
- int projectCount = t.getFieldList().size();
-
- for (int i =0; i < projectCount; i++) {
- projections.add(b.makeInputRef(rel, i));
- }
-
- final List<String> fieldNames2 = SqlValidatorUtil.uniquify(validatedRowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER2);
-
- RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(), projections, fieldNames2);
-
- DrillProjectRel topProj = DrillProjectRel.create(rel.getCluster(), rel.getTraitSet(), rel, projections, newRowType);
-
- if (ProjectRemoveRule.isTrivial(topProj, true)) {
- return rel;
- } else{
- return topProj;
- }
- //return RelOptUtil.createProject(rel, projections, fieldNames2);
-
- }
-
-
- protected TypedSqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
- TypedSqlNode typedSqlNode = planner.validateAndGetType(sqlNode);
-
- SqlNode sqlNodeValidated = typedSqlNode.getSqlNode();
-
- // Check if the unsupported functionality is used
- UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(context);
- try {
- sqlNodeValidated.accept(visitor);
- } catch (UnsupportedOperationException ex) {
- // If the exception due to the unsupported functionalities
- visitor.convertException();
-
- // If it is not, let this exception move forward to higher logic
- throw ex;
- }
-
- return typedSqlNode;
- }
-
- protected RelNode convertToRel(SqlNode node) throws RelConversionException {
- RelNode convertedNode = planner.convert(node);
- hepPlanner.setRoot(convertedNode);
- RelNode rel = hepPlanner.findBestExp();
- return rel;
+ /**
+ * Rewrite the parse tree. Used before validating the parse tree. Useful if a particular statement needs to converted
+ * into another statement.
+ *
+ * @param node
+ * @return Rewritten sql parse tree
+ * @throws RelConversionException
+ */
+ protected SqlNode rewrite(SqlNode node) throws RelConversionException, ForemanSetupException {
+ return node;
}
- protected RelNode preprocessNode(RelNode rel) throws SqlUnsupportedException {
- /*
- * Traverse the tree to do the following pre-processing tasks: 1. replace the convert_from, convert_to function to
- * actual implementations Eg: convert_from(EXPR, 'JSON') be converted to convert_fromjson(EXPR); TODO: Ideally all
- * function rewrites would move here instead of DrillOptiq.
- *
- * 2. see where the tree contains unsupported functions; throw SqlUnsupportedException if there is any.
- */
+ protected ConvertedRelNode validateAndConvert(SqlNode sqlNode) throws ForemanSetupException, RelConversionException, ValidationException {
+ final SqlNode rewrittenSqlNode = rewrite(sqlNode);
+ final TypedSqlNode validatedTypedSqlNode = validateNode(rewrittenSqlNode);
+ final SqlNode validated = validatedTypedSqlNode.getSqlNode();
- PreProcessLogicalRel visitor = PreProcessLogicalRel.createVisitor(planner.getTypeFactory(),
- context.getDrillOperatorTable());
- try {
- rel = rel.accept(visitor);
- } catch (UnsupportedOperationException ex) {
- visitor.convertException();
- throw ex;
- }
+ RelNode rel = convertToRel(validated);
+ rel = preprocessNode(rel);
- return rel;
+ return new ConvertedRelNode(rel, validatedTypedSqlNode.getType());
}
- protected DrillRel convertToDrel(RelNode relNode, RelDataType validatedRowType) throws RelConversionException, SqlUnsupportedException {
+ /**
+ * Given a relNode tree for SELECT statement, convert to Drill Logical RelNode tree.
+ * @param relNode
+ * @return
+ * @throws SqlUnsupportedException
+ * @throws RelConversionException
+ */
+ protected DrillRel convertToDrel(RelNode relNode) throws SqlUnsupportedException, RelConversionException {
try {
- RelNode convertedRelNode;
+ final DrillRel convertedRelNode;
if (! context.getPlannerSettings().isHepJoinOptEnabled()) {
- convertedRelNode = logicalPlanningVolcano(relNode);
+ convertedRelNode = (DrillRel) logicalPlanningVolcano(relNode);
} else {
- convertedRelNode = logicalPlanningVolcanoAndLopt(relNode);
+ convertedRelNode = (DrillRel) logicalPlanningVolcanoAndLopt(relNode);
}
if (convertedRelNode instanceof DrillStoreRel) {
@@ -290,10 +219,7 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
context.getPlannerSettings().forceSingleMode();
}
- // Put a non-trivial topProject to ensure the final output field name is preserved, when necessary.
- DrillRel topPreservedNameProj = addRenamedProject((DrillRel) convertedRelNode, validatedRowType);
- return new DrillScreenRel(topPreservedNameProj.getCluster(), topPreservedNameProj.getTraitSet(),
- topPreservedNameProj);
+ return convertedRelNode;
}
} catch (RelOptPlanner.CannotPlanException ex) {
logger.error(ex.getMessage());
@@ -306,6 +232,24 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
}
}
+ /**
+ * Return Drill Logical RelNode tree for a SELECT statement, when it is executed / explained directly.
+ *
+ * @param relNode : root RelNode corresponds to Calcite Logical RelNode.
+ * @param validatedRowType : the rowType for the final field names. A rename project may be placed on top of the root.
+ * @return
+ * @throws RelConversionException
+ * @throws SqlUnsupportedException
+ */
+ protected DrillRel convertToDrel(RelNode relNode, RelDataType validatedRowType) throws RelConversionException, SqlUnsupportedException {
+ final DrillRel convertedRelNode = convertToDrel(relNode);
+
+ // Put a non-trivial topProject to ensure the final output field name is preserved, when necessary.
+ DrillRel topPreservedNameProj = addRenamedProject((DrillRel) convertedRelNode, validatedRowType);
+ return new DrillScreenRel(topPreservedNameProj.getCluster(), topPreservedNameProj.getTraitSet(),
+ topPreservedNameProj);
+ }
+
protected Prel convertToPrel(RelNode drel) throws RelConversionException, SqlUnsupportedException {
Preconditions.checkArgument(drel.getConvention() == DrillRel.DRILL_LOGICAL);
@@ -479,18 +423,80 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
}
- /**
- * Rewrite the parse tree. Used before validating the parse tree. Useful if a particular statement needs to converted
- * into another statement.
- *
- * @param node
- * @return Rewritten sql parse tree
- * @throws RelConversionException
- */
- public SqlNode rewrite(SqlNode node) throws RelConversionException, ForemanSetupException {
- return node;
+ private TypedSqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
+ TypedSqlNode typedSqlNode = planner.validateAndGetType(sqlNode);
+
+ SqlNode sqlNodeValidated = typedSqlNode.getSqlNode();
+
+ // Check if the unsupported functionality is used
+ UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(context);
+ try {
+ sqlNodeValidated.accept(visitor);
+ } catch (UnsupportedOperationException ex) {
+ // If the exception due to the unsupported functionalities
+ visitor.convertException();
+
+ // If it is not, let this exception move forward to higher logic
+ throw ex;
+ }
+
+ return typedSqlNode;
+ }
+
+ private RelNode convertToRel(SqlNode node) throws RelConversionException {
+ RelNode convertedNode = planner.convert(node);
+ hepPlanner.setRoot(convertedNode);
+ RelNode rel = hepPlanner.findBestExp();
+
+ return rel;
+ }
+
+ private RelNode preprocessNode(RelNode rel) throws SqlUnsupportedException {
+ /*
+ * Traverse the tree to do the following pre-processing tasks: 1. replace the convert_from, convert_to function to
+ * actual implementations Eg: convert_from(EXPR, 'JSON') be converted to convert_fromjson(EXPR); TODO: Ideally all
+ * function rewrites would move here instead of DrillOptiq.
+ *
+ * 2. see where the tree contains unsupported functions; throw SqlUnsupportedException if there is any.
+ */
+
+ PreProcessLogicalRel visitor = PreProcessLogicalRel.createVisitor(planner.getTypeFactory(),
+ context.getDrillOperatorTable());
+ try {
+ rel = rel.accept(visitor);
+ } catch (UnsupportedOperationException ex) {
+ visitor.convertException();
+ throw ex;
+ }
+
+ return rel;
+ }
+
+ private DrillRel addRenamedProject(DrillRel rel, RelDataType validatedRowType) {
+ RelDataType t = rel.getRowType();
+
+ RexBuilder b = rel.getCluster().getRexBuilder();
+ List<RexNode> projections = Lists.newArrayList();
+ int projectCount = t.getFieldList().size();
+
+ for (int i =0; i < projectCount; i++) {
+ projections.add(b.makeInputRef(rel, i));
+ }
+
+ final List<String> fieldNames2 = SqlValidatorUtil.uniquify(validatedRowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER2);
+
+ RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(), projections, fieldNames2);
+
+ DrillProjectRel topProj = DrillProjectRel.create(rel.getCluster(), rel.getTraitSet(), rel, projections, newRowType);
+
+ if (ProjectRemoveRule.isTrivial(topProj, true)) {
+ return rel;
+ } else{
+ return topProj;
+ }
}
+
private RelNode logicalPlanningVolcano(RelNode relNode) throws RelConversionException, SqlUnsupportedException {
return planner.transform(DrillSqlWorker.LOGICAL_RULES, relNode.getTraitSet().plus(DrillRel.DRILL_LOGICAL), relNode);
}
@@ -523,7 +529,7 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
/**
* Appy Join Order Optimizations using Hep Planner.
*/
- public RelNode getLoptJoinOrderTree(RelNode root,
+ private RelNode getLoptJoinOrderTree(RelNode root,
Class<? extends Join> joinClass,
RelFactories.JoinFactory joinFactory,
RelFactories.FilterFactory filterFactory,
@@ -589,4 +595,24 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
return parent;
}
}
+
+ protected class ConvertedRelNode {
+ private final RelNode relNode;
+ private final RelDataType validatedRowType;
+
+ public ConvertedRelNode(RelNode relNode, RelDataType validatedRowType) {
+ this.relNode = relNode;
+ this.validatedRowType = validatedRowType;
+ }
+
+ public RelNode getConvertedNode() {
+ return this.relNode;
+ }
+
+ public RelDataType getValidatedRowType() {
+ return this.validatedRowType;
+ }
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
index 5924c7e..efc4b36 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
@@ -20,7 +20,6 @@ package org.apache.drill.exec.planner.sql.handlers;
import java.io.IOException;
import org.apache.calcite.rel.type.RelDataType;
-import org.apache.calcite.sql.TypedSqlNode;
import org.apache.calcite.tools.RelConversionException;
import org.apache.calcite.tools.ValidationException;
@@ -53,17 +52,13 @@ public class ExplainHandler extends DefaultSqlHandler {
}
@Override
- public PhysicalPlan getPlan(SqlNode node) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
- SqlNode sqlNode = rewrite(node);
- TypedSqlNode validatedTypedSqlNode = validateNode(sqlNode);
- SqlNode validated = validatedTypedSqlNode.getSqlNode();
- RelDataType validatedRowType = validatedTypedSqlNode.getType();
+ public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
+ final ConvertedRelNode convertedRelNode = validateAndConvert(sqlNode);
+ final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
+ final RelNode queryRelNode = convertedRelNode.getConvertedNode();
- RelNode rel = convertToRel(validated);
- rel = preprocessNode(rel);
-
- log("Optiq Logical", rel);
- DrillRel drel = convertToDrel(rel, validatedRowType);
+ log("Optiq Logical", queryRelNode);
+ DrillRel drel = convertToDrel(queryRelNode, validatedRowType);
log("Drill Logical", drel);
if (mode == ResultMode.LOGICAL) {
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
index 60287dc..9e7be7f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SqlHandlerUtil.java
@@ -58,21 +58,18 @@ public class SqlHandlerUtil {
*
* @param isNewTableView Is the new table created a view? This doesn't affect the functionality, but it helps format
* better error messages.
- * @param planner Planner instance.
* @param tableFieldNames List of fields specified in new table/view field list. These are the fields given just after
* new table name.
* Ex. CREATE TABLE newTblName(col1, medianOfCol2, avgOfCol3) AS
* SELECT col1, median(col2), avg(col3) FROM sourcetbl GROUP BY col1;
- * @param newTableQueryDef Sql tree of definition of the new table or view (query after the AS keyword). This tree is
- * modified, so it is responsibility of caller's to make a copy if needed.
* @throws ValidationException If table's fields list and field list specified in table definition are not valid.
* @throws RelConversionException If failed to convert the table definition into a RelNode.
*/
- public static RelNode resolveNewTableRel(boolean isNewTableView, Planner planner, List<String> tableFieldNames,
- SqlNode newTableQueryDef) throws ValidationException, RelConversionException {
+ public static RelNode resolveNewTableRel(boolean isNewTableView, List<String> tableFieldNames,
+ RelDataType validatedRowtype, RelNode queryRelNode) throws ValidationException, RelConversionException {
- TypedSqlNode validatedSqlNodeWithType = planner.validateAndGetType(newTableQueryDef);
+// TypedSqlNode validatedSqlNodeWithType = planner.validateAndGetType(newTableQueryDef);
// Get the row type of view definition query.
// Reason for getting the row type from validated SqlNode than RelNode is because SqlNode -> RelNode involves
@@ -84,12 +81,11 @@ public class SqlHandlerUtil {
// | 0 | 0 |
// +------------+------------+
// which is not desired when creating new views or tables.
- final RelDataType queryRowType = validatedSqlNodeWithType.getType();
- final RelNode validatedQueryRelNode = planner.convert(validatedSqlNodeWithType.getSqlNode());
+// final RelDataType queryRowType = validatedRowtype;
if (tableFieldNames.size() > 0) {
// Field count should match.
- if (tableFieldNames.size() != queryRowType.getFieldCount()) {
+ if (tableFieldNames.size() != validatedRowtype.getFieldCount()) {
final String tblType = isNewTableView ? "view" : "table";
throw UserException.validationError()
.message("%s's field list and the %s's query field list have different counts.", tblType, tblType)
@@ -97,7 +93,7 @@ public class SqlHandlerUtil {
}
// CTAS's query field list shouldn't have "*" when table's field list is specified.
- for (String field : queryRowType.getFieldNames()) {
+ for (String field : validatedRowtype.getFieldNames()) {
if (field.equals("*")) {
final String tblType = isNewTableView ? "view" : "table";
throw UserException.validationError()
@@ -115,13 +111,13 @@ public class SqlHandlerUtil {
// SELECT col1, median(col2), avg(col3) FROM sourcetbl GROUP BY col1 ;
// Similary for CREATE VIEW.
- return DrillRelOptUtil.createRename(validatedQueryRelNode, tableFieldNames);
+ return DrillRelOptUtil.createRename(queryRelNode, tableFieldNames);
}
// As the column names of the view are derived from SELECT query, make sure the query has no duplicate column names
- ensureNoDuplicateColumnNames(queryRowType.getFieldNames());
+ ensureNoDuplicateColumnNames(validatedRowtype.getFieldNames());
- return validatedQueryRelNode;
+ return queryRelNode;
}
private static void ensureNoDuplicateColumnNames(List<String> fieldNames) throws ValidationException {
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
index 0a3393e..36287a4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
@@ -19,11 +19,10 @@ package org.apache.drill.exec.planner.sql.handlers;
import java.io.IOException;
+import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.schema.Schema;
-import org.apache.calcite.schema.Schema.TableType;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
-import org.apache.calcite.tools.Planner;
import org.apache.calcite.tools.RelConversionException;
import org.apache.calcite.tools.ValidationException;
@@ -40,22 +39,21 @@ import org.apache.drill.exec.work.foreman.ForemanSetupException;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.sql.SqlNode;
-public abstract class ViewHandler extends AbstractSqlHandler {
+public abstract class ViewHandler extends DefaultSqlHandler {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ViewHandler.class);
- protected Planner planner;
protected QueryContext context;
- public ViewHandler(Planner planner, QueryContext context) {
- this.planner = planner;
- this.context = context;
+ public ViewHandler(SqlHandlerConfig config) {
+ super(config);
+ this.context = config.getContext();
}
/** Handler for Create View DDL command */
public static class CreateView extends ViewHandler {
- public CreateView(Planner planner, QueryContext context) {
- super(planner, context);
+ public CreateView(SqlHandlerConfig config) {
+ super(config);
}
@Override
@@ -67,8 +65,11 @@ public abstract class ViewHandler extends AbstractSqlHandler {
// Store the viewSql as view def SqlNode is modified as part of the resolving the new table definition below.
final String viewSql = createView.getQuery().toString();
- final RelNode newViewRelNode =
- SqlHandlerUtil.resolveNewTableRel(true, planner, createView.getFieldNames(), createView.getQuery());
+ final ConvertedRelNode convertedRelNode = validateAndConvert(createView.getQuery());
+ final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
+ final RelNode queryRelNode = convertedRelNode.getConvertedNode();
+
+ final RelNode newViewRelNode = SqlHandlerUtil.resolveNewTableRel(true, createView.getFieldNames(), validatedRowType, queryRelNode);
final SchemaPlus defaultSchema = context.getNewDefaultSchema();
final AbstractSchema drillSchema = SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, createView.getSchemaPath());
@@ -107,8 +108,8 @@ public abstract class ViewHandler extends AbstractSqlHandler {
/** Handler for Drop View DDL command. */
public static class DropView extends ViewHandler {
- public DropView(QueryContext context) {
- super(null, context);
+ public DropView(SqlHandlerConfig config) {
+ super(config);
}
@Override
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
index a140829..cc6118a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlCreateView.java
@@ -96,7 +96,7 @@ public class SqlCreateView extends DrillSqlCall {
@Override
public AbstractSqlHandler getSqlHandler(SqlHandlerConfig config) {
- return new ViewHandler.CreateView(config.getPlanner(), config.getContext());
+ return new ViewHandler.CreateView(config);
}
public List<String> getSchemaPath() {
http://git-wip-us.apache.org/repos/asf/drill/blob/ffae1691/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlDropView.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlDropView.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlDropView.java
index 473dbcb..0e775b8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlDropView.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/SqlDropView.java
@@ -73,7 +73,7 @@ public class SqlDropView extends DrillSqlCall {
@Override
public AbstractSqlHandler getSqlHandler(SqlHandlerConfig config) {
- return new DropView(config.getContext());
+ return new DropView(config);
}
public List<String> getSchemaPath() {
[3/3] drill git commit: DRILL-3316(2) : Disable unit test of tinyint,
smallint and real type in DatabaseMetaDataGetColumnsTest and
TestInformationSchemaColumns until DRILL-2470 is fixed.
Posted by jn...@apache.org.
DRILL-3316(2) : Disable unit test of tinyint, smallint and real type in DatabaseMetaDataGetColumnsTest and TestInformationSchemaColumns until DRILL-2470 is fixed.
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/9c125b0d
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/9c125b0d
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/9c125b0d
Branch: refs/heads/master
Commit: 9c125b0d9f8e49c6a234fde0f284168552a781cb
Parents: ffae169
Author: Jinfeng Ni <jn...@apache.org>
Authored: Wed Jun 17 15:42:23 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Sat Jun 20 15:42:56 2015 -0700
----------------------------------------------------------------------
.../jdbc/DatabaseMetaDataGetColumnsTest.java | 47 +++++++++++++---
.../jdbc/test/TestInformationSchemaColumns.java | 56 +++++++++++++++++---
2 files changed, 90 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/9c125b0d/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
index 5e59e8c..15c9d5c 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
@@ -111,11 +111,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
private static ResultSet mdrOptBOOLEAN;
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
private static ResultSet mdrReqTINYINT;
private static ResultSet mdrOptSMALLINT;
private static ResultSet mdrReqINTEGER;
private static ResultSet mdrOptBIGINT;
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
private static ResultSet mdrOptREAL;
private static ResultSet mdrOptFLOAT;
private static ResultSet mdrReqDOUBLE;
@@ -227,17 +229,21 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertTrue( util.next() );
assertTrue( "Error setting schema for test: " + util.getString( 2 ),
util.getBoolean( 1 ) );
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
util = stmt.executeQuery(
""
+ "CREATE OR REPLACE VIEW " + VIEW_NAME + " AS SELECT "
+ "\n CAST( NULL AS BOOLEAN ) AS mdrOptBOOLEAN, "
+ "\n "
- + "\n CAST( 1 AS TINYINT ) AS mdrReqTINYINT, "
- + "\n CAST( NULL AS SMALLINT ) AS mdrOptSMALLINT, "
+ + "\n CAST( 1 AS INT ) AS mdrReqTINYINT, "
+ + "\n CAST( NULL AS INT ) AS mdrOptSMALLINT, "
+ //+ "\n CAST( 1 AS TINYINT ) AS mdrReqTINYINT, "
+ //+ "\n CAST( NULL AS SMALLINT ) AS mdrOptSMALLINT, "
+ "\n CAST( 2 AS INTEGER ) AS mdrReqINTEGER, "
+ "\n CAST( NULL AS BIGINT ) AS mdrOptBIGINT, "
+ "\n "
- + "\n CAST( NULL AS REAL ) AS mdrOptREAL, "
+ + "\n CAST( NULL AS FLOAT ) AS mdrOptREAL, "
+ //+ "\n CAST( NULL AS REAL ) AS mdrOptREAL, "
+ "\n CAST( NULL AS FLOAT ) AS mdrOptFLOAT, "
+ "\n CAST( 3.3 AS DOUBLE ) AS mdrReqDOUBLE, "
+ "\n "
@@ -280,12 +286,14 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
mdrOptBOOLEAN = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptBOOLEAN" );
- mdrReqTINYINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqTINYINT" );
- mdrOptSMALLINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptSMALLINT" );
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
+ //mdrReqTINYINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqTINYINT" );
+ //mdrOptSMALLINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptSMALLINT" );
mdrReqINTEGER = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqINTEGER" );
mdrOptBIGINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptBIGINT" );
- mdrOptREAL = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptREAL" );
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
+ //mdrOptREAL = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptREAL" );
mdrOptFLOAT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptFLOAT" );
mdrReqDOUBLE = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqDOUBLE" );
@@ -600,11 +608,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "DATA_TYPE" ), equalTo( Types.BOOLEAN ) );
}
+ @Ignore( "until tinyint is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "DATA_TYPE" ), equalTo( Types.TINYINT ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "DATA_TYPE" ), equalTo( Types.SMALLINT ) );
@@ -620,6 +630,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "DATA_TYPE" ), equalTo( Types.BIGINT ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "DATA_TYPE" ), equalTo( Types.REAL ) );
@@ -774,11 +785,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( mdrOptBOOLEAN.getString( "TYPE_NAME" ), equalTo( "BOOLEAN" ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_TYPE_NAME_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( mdrReqTINYINT.getString( "TYPE_NAME" ), equalTo( "TINYINT" ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_TYPE_NAME_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( mdrOptSMALLINT.getString( "TYPE_NAME" ), equalTo( "SMALLINT" ) );
@@ -794,6 +807,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( mdrOptBIGINT.getString( "TYPE_NAME" ), equalTo( "BIGINT" ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_TYPE_NAME_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( mdrOptREAL.getString( "TYPE_NAME" ), equalTo( "REAL" ) );
@@ -954,12 +968,14 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "COLUMN_SIZE" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_COLUMN_SIZE_hasRightValue_mdrReqTINYINT() throws SQLException {
// 8 bits
assertThat( getIntOrNull( mdrReqTINYINT, "COLUMN_SIZE" ), equalTo( 8 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_COLUMN_SIZE_hasRightValue_mdrOptSMALLINT() throws SQLException {
// 16 bits
@@ -978,6 +994,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "COLUMN_SIZE" ), equalTo( 64 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_COLUMN_SIZE_hasRightValue_mdrOptREAL() throws SQLException {
// 24 bits of precision
@@ -1264,11 +1281,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "DECIMAL_DIGITS" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_DECIMAL_DIGITS_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "DECIMAL_DIGITS" ), equalTo( 0 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_DECIMAL_DIGITS_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "DECIMAL_DIGITS" ), equalTo( 0 ) );
@@ -1284,6 +1303,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "DECIMAL_DIGITS" ), equalTo( 0 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_DECIMAL_DIGITS_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "DECIMAL_DIGITS" ), equalTo( 7 ) );
@@ -1561,11 +1581,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "NUM_PREC_RADIX" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_NUM_PREC_RADIX_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "NUM_PREC_RADIX" ), equalTo( 2 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_NUM_PREC_RADIX_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "NUM_PREC_RADIX" ), equalTo( 2 ) );
@@ -1581,6 +1603,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "NUM_PREC_RADIX" ), equalTo( 2 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_NUM_PREC_RADIX_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "NUM_PREC_RADIX" ), equalTo( 2 ) );
@@ -1731,6 +1754,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
getIntOrNull( mdrOptBOOLEAN, "NULLABLE" ), equalTo( columnNoNulls ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_NULLABLE_hasRightValue_mdrReqTINYINT() throws SQLException {
// To-do: CHECK: Why columnNullableUnknown, when seemingly known non-nullable?
@@ -1738,6 +1762,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
getIntOrNull( mdrReqTINYINT, "NULLABLE" ), equalTo( columnNoNulls ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_NULLABLE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( "ResultSetMetaData.column...Null... nullability code:",
@@ -1750,6 +1775,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
getIntOrNull( mdrOptBIGINT, "NULLABLE" ), equalTo( columnNullable ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_NULLABLE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( "ResultSetMetaData.column...Null... nullability code:",
@@ -2115,11 +2141,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "CHAR_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_CHAR_OCTET_LENGTH_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "CHAR_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_CHAR_OCTET_LENGTH_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "CHAR_OCTET_LENGTH" ), nullValue() );
@@ -2130,6 +2158,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrReqINTEGER, "CHAR_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_CHAR_OCTET_LENGTH_hasRightValue_mdrOptBIGINT() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "CHAR_OCTET_LENGTH" ), nullValue() );
@@ -2281,11 +2310,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "ORDINAL_POSITION" ), equalTo( 1 ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "ORDINAL_POSITION" ), equalTo( 2 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "ORDINAL_POSITION" ), equalTo( 3 ) );
@@ -2301,6 +2332,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "ORDINAL_POSITION" ), equalTo( 5 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "ORDINAL_POSITION" ), equalTo( 6 ) );
@@ -2371,11 +2403,13 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( mdrOptBOOLEAN.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( mdrReqTINYINT.getString( "IS_NULLABLE" ), equalTo( "NO" ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( mdrOptSMALLINT.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
@@ -2391,6 +2425,7 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTestBase {
assertThat( mdrOptBIGINT.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( mdrOptREAL.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
http://git-wip-us.apache.org/repos/asf/drill/blob/9c125b0d/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestInformationSchemaColumns.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestInformationSchemaColumns.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestInformationSchemaColumns.java
index 3f820f5..8fb521e 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestInformationSchemaColumns.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestInformationSchemaColumns.java
@@ -78,11 +78,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
private static ResultSet mdrOptBOOLEAN;
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
private static ResultSet mdrReqTINYINT;
private static ResultSet mdrOptSMALLINT;
private static ResultSet mdrReqINTEGER;
private static ResultSet mdrOptBIGINT;
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
private static ResultSet mdrOptREAL;
private static ResultSet mdrOptFLOAT;
private static ResultSet mdrReqDOUBLE;
@@ -205,17 +207,22 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
util = stmt.executeQuery( "USE dfs_test.tmp" );
assertTrue( util.next() );
assertTrue( "Error setting schema for test: " + util.getString( 2 ), util.getBoolean( 1 ) );
+
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
util = stmt.executeQuery(
""
+ "CREATE OR REPLACE VIEW " + VIEW_NAME + " AS SELECT "
+ "\n CAST( NULL AS BOOLEAN ) AS mdrOptBOOLEAN, "
+ "\n "
- + "\n CAST( 1 AS TINYINT ) AS mdrReqTINYINT, "
- + "\n CAST( NULL AS SMALLINT ) AS mdrOptSMALLINT, "
+ + "\n CAST( 1 AS INT ) AS mdrReqTINYINT, "
+ + "\n CAST( NULL AS INT ) AS mdrOptSMALLINT, "
+ //+ "\n CAST( 1 AS TINYINT ) AS mdrReqTINYINT, "
+ //+ "\n CAST( NULL AS SMALLINT ) AS mdrOptSMALLINT, "
+ "\n CAST( 2 AS INTEGER ) AS mdrReqINTEGER, "
+ "\n CAST( NULL AS BIGINT ) AS mdrOptBIGINT, "
+ "\n "
- + "\n CAST( NULL AS REAL ) AS mdrOptREAL, "
+ + "\n CAST( NULL AS FLOAT ) AS mdrOptREAL, "
+ //+ "\n CAST( NULL AS REAL ) AS mdrOptREAL, "
+ "\n CAST( NULL AS FLOAT ) AS mdrOptFLOAT, "
+ "\n CAST( 3.3 AS DOUBLE ) AS mdrReqDOUBLE, "
+ "\n "
@@ -258,12 +265,14 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
mdrOptBOOLEAN = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptBOOLEAN" );
- mdrReqTINYINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqTINYINT" );
- mdrOptSMALLINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptSMALLINT" );
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
+ //mdrReqTINYINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqTINYINT" );
+ //mdrOptSMALLINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptSMALLINT" );
mdrReqINTEGER = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqINTEGER" );
mdrOptBIGINT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptBIGINT" );
- mdrOptREAL = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptREAL" );
+ // TODO(DRILL-2470): re-enable TINYINT, SMALLINT, and REAL.
+ //mdrOptREAL = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptREAL" );
mdrOptFLOAT = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrOptFLOAT" );
mdrReqDOUBLE = setUpRow( VIEW_SCHEMA, VIEW_NAME, "mdrReqDOUBLE" );
@@ -599,11 +608,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBOOLEAN.getInt( "ORDINAL_POSITION" ), equalTo( 1 ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( mdrReqTINYINT.getInt( "ORDINAL_POSITION" ), equalTo( 2 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( mdrOptSMALLINT.getInt( "ORDINAL_POSITION" ), equalTo( 3 ) );
@@ -619,6 +630,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBIGINT.getInt( "ORDINAL_POSITION" ), equalTo( 5 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_ORDINAL_POSITION_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( mdrOptREAL.getInt( "ORDINAL_POSITION" ), equalTo( 6 ) );
@@ -729,12 +741,14 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
mdrOptBOOLEAN.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( "ResultSetMetaData.column...Null... nullability code:",
mdrReqTINYINT.getString( "IS_NULLABLE" ), equalTo( "NO" ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( "ResultSetMetaData.column...Null... nullability code:",
@@ -753,6 +767,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
mdrOptBIGINT.getString( "IS_NULLABLE" ), equalTo( "YES" ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_IS_NULLABLE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( "ResultSetMetaData.column...Null... nullability code:",
@@ -914,11 +929,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBOOLEAN.getString( "DATA_TYPE" ), equalTo( "BOOLEAN" ) );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( mdrReqTINYINT.getString( "DATA_TYPE" ), equalTo( "TINYINT" ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( mdrOptSMALLINT.getString( "DATA_TYPE" ), equalTo( "SMALLINT" ) );
@@ -934,6 +951,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBIGINT.getString( "DATA_TYPE" ), equalTo( "BIGINT" ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_DATA_TYPE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( mdrOptREAL.getString( "DATA_TYPE" ), equalTo( "REAL" ) );
@@ -1077,11 +1095,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "CHARACTER_MAXIMUM_LENGTH" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_MAXIMUM_LENGTH_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "CHARACTER_MAXIMUM_LENGTH" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_MAXIMUM_LENGTH_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "CHARACTER_MAXIMUM_LENGTH" ), nullValue() );
@@ -1097,6 +1117,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "CHARACTER_MAXIMUM_LENGTH" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_MAXIMUM_LENGTH_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "CHARACTER_MAXIMUM_LENGTH" ), nullValue() );
@@ -1234,16 +1255,19 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "CHARACTER_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_OCTET_LENGTH_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "CHARACTER_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_OCTET_LENGTH_hasRightValue_mdrOptBIGINT() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "CHARACTER_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_OCTET_LENGTH_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "CHARACTER_OCTET_LENGTH" ), nullValue() );
@@ -1254,6 +1278,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrReqINTEGER, "CHARACTER_OCTET_LENGTH" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_CHARACTER_OCTET_LENGTH_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "CHARACTER_OCTET_LENGTH" ), nullValue() );
@@ -1397,11 +1422,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "NUMERIC_PRECISION" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "NUMERIC_PRECISION" ), equalTo( 8 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "NUMERIC_PRECISION" ), equalTo( 16 ) );
@@ -1417,6 +1444,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "NUMERIC_PRECISION" ), equalTo( 64 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "NUMERIC_PRECISION" ), equalTo( 24 ) );
@@ -1554,11 +1582,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "NUMERIC_PRECISION_RADIX" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_RADIX_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "NUMERIC_PRECISION_RADIX" ), equalTo( 2 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_RADIX_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "NUMERIC_PRECISION_RADIX" ), equalTo( 2 ) );
@@ -1574,6 +1604,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "NUMERIC_PRECISION_RADIX" ), equalTo( 2 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_PRECISION_RADIX_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "NUMERIC_PRECISION_RADIX" ), equalTo( 2 ) );
@@ -1711,12 +1742,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "NUMERIC_SCALE" ), nullValue() );
}
-
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_SCALE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "NUMERIC_SCALE" ), equalTo( 0 ) );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_SCALE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "NUMERIC_SCALE" ), equalTo( 0 ) );
@@ -1732,6 +1764,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "NUMERIC_SCALE" ), equalTo( 0 ) );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_NUMERIC_SCALE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "NUMERIC_SCALE" ), nullValue() );
@@ -1869,11 +1902,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "DATETIME_PRECISION" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_DATETIME_PRECISION_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "DATETIME_PRECISION" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_DATETIME_PRECISION_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "DATETIME_PRECISION" ), nullValue() );
@@ -1889,6 +1924,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "DATETIME_PRECISION" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_DATETIME_PRECISION_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "DATETIME_PRECISION" ), nullValue() );
@@ -2145,11 +2181,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBOOLEAN.getString( "INTERVAL_TYPE" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_TYPE_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( mdrReqTINYINT.getString( "INTERVAL_TYPE" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_TYPE_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( mdrOptSMALLINT.getString( "INTERVAL_TYPE" ), nullValue() );
@@ -2165,6 +2203,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( mdrOptBIGINT.getString( "INTERVAL_TYPE" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_TYPE_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( mdrOptREAL.getString( "INTERVAL_TYPE" ), nullValue() );
@@ -2374,11 +2413,13 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBOOLEAN, "INTERVAL_PRECISION" ), nullValue() );
}
+ @Ignore( "until TINYINT is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_PRECISION_hasRightValue_mdrReqTINYINT() throws SQLException {
assertThat( getIntOrNull( mdrReqTINYINT, "INTERVAL_PRECISION" ), nullValue() );
}
+ @Ignore( "until SMALLINT is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_PRECISION_hasRightValue_mdrOptSMALLINT() throws SQLException {
assertThat( getIntOrNull( mdrOptSMALLINT, "INTERVAL_PRECISION" ), nullValue() );
@@ -2394,6 +2435,7 @@ public class TestInformationSchemaColumns extends JdbcTestBase {
assertThat( getIntOrNull( mdrOptBIGINT, "INTERVAL_PRECISION" ), nullValue() );
}
+ @Ignore( "until REAL is implemented. (DRILL-2470)" )
@Test
public void test_INTERVAL_PRECISION_hasRightValue_mdrOptREAL() throws SQLException {
assertThat( getIntOrNull( mdrOptREAL, "INTERVAL_PRECISION" ), nullValue() );