Repository: incubator-drill
Updated Branches:
refs/heads/master caa8b78c5 -> cfa0b639b
move to optiq 0.9
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/e52d2b66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/e52d2b66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/e52d2b66
Branch: refs/heads/master
Commit: e52d2b66bdd2750dc2bb3c98fa937e8984b93c12
Parents: caa8b78
Author: Jacques Nadeau <jacques@apache.org>
Authored: Sat Jul 5 08:57:59 2014 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sat Jul 26 21:40:33 2014 -0700
----------------------------------------------------------------------
.../apache/drill/exec/ops/FragmentContext.java | 4 +-
.../org/apache/drill/exec/ops/QueryContext.java | 4 +-
.../exec/planner/logical/DrillJoinRel.java | 4 +-
.../drill/exec/planner/logical/DrillOptiq.java | 7 +-
.../exec/planner/physical/HashJoinPrel.java | 2 +-
.../exec/planner/physical/MergeJoinPrel.java | 2 +-
.../exec/planner/physical/PlannerSettings.java | 7 +-
.../drill/exec/planner/physical/PrelUtil.java | 6 +-
.../exec/planner/physical/StreamAggPrule.java | 66 +++++++-------
.../drill/exec/planner/sql/DrillSqlWorker.java | 4 +-
.../apache/drill/exec/store/AbstractSchema.java | 7 ++
.../drill/exec/store/SubSchemaWrapper.java | 1 +
.../java/org/apache/drill/PlanningBase.java | 3 +-
.../exec/sql/TestSqlBracketlessSyntax.java | 7 +-
.../drill/jdbc/DrillColumnMetaDataList.java | 91 +++++++++++++++++++-
.../java/org/apache/drill/jdbc/DrillCursor.java | 26 +++---
pom.xml | 2 +-
17 files changed, 171 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
index 3401bc7..0b8b88a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
@@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map;
import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.tools.Frameworks;
+import net.hydromatic.optiq.jdbc.SimpleOptiqSchema;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.ExecutionSetupException;
@@ -132,7 +132,7 @@ public class FragmentContext implements Closeable {
"This is a non-root fragment."));
return null;
} else {
- SchemaPlus root = Frameworks.createRootSchema(false);
+ SchemaPlus root = SimpleOptiqSchema.createRootSchema(false);
context.getStorage().getSchemaFactory().registerSchemas(connection.getSession(), root);
return root;
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java
index e6c6fa7..78e98fb 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java
@@ -20,7 +20,7 @@ package org.apache.drill.exec.ops;
import java.util.Collection;
import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.tools.Frameworks;
+import net.hydromatic.optiq.jdbc.SimpleOptiqSchema;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.exec.cache.DistributedCache;
@@ -84,7 +84,7 @@ public class QueryContext{
}
public SchemaPlus getRootSchema(){
- SchemaPlus rootSchema = Frameworks.createRootSchema(false);
+ SchemaPlus rootSchema = SimpleOptiqSchema.createRootSchema(false);
drillbitContext.getSchemaFactory().registerSchemas(session, rootSchema);
return rootSchema;
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java
index e687f5a..151318e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java
@@ -30,6 +30,7 @@ import org.apache.drill.common.logical.data.Project;
import org.apache.drill.exec.planner.common.DrillJoinRelBase;
import org.apache.drill.exec.planner.torel.ConversionContext;
import org.eigenbase.rel.InvalidRelException;
+import org.eigenbase.rel.JoinRelBase;
import org.eigenbase.rel.JoinRelType;
import org.eigenbase.rel.RelNode;
import org.eigenbase.relopt.RelOptCluster;
@@ -78,8 +79,9 @@ public class DrillJoinRel extends DrillJoinRelBase implements DrillRel {
this.rightKeys = rightKeys;
}
+
@Override
- public DrillJoinRel copy(RelTraitSet traitSet, RexNode condition, RelNode left, RelNode
right, JoinRelType joinType) {
+ public DrillJoinRel copy(RelTraitSet traitSet, RexNode condition, RelNode left, RelNode
right, JoinRelType joinType, boolean semiJoinDone) {
try {
return new DrillJoinRel(getCluster(), traitSet, left, right, condition, joinType);
} catch (InvalidRelException e) {
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
index 633084f..aa88310 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
@@ -102,13 +102,13 @@ public class DrillOptiq {
if (FunctionCallFactory.isBooleanOperator(funcName)) {
LogicalExpression func = FunctionCallFactory.createBooleanOperator(funcName, args);
return func;
- } else {
+ } else {
args = Lists.reverse(args);
LogicalExpression lastArg = args.get(0);
for(int i = 1; i < args.size(); i++){
lastArg = FunctionCallFactory.createExpression(funcName, Lists.newArrayList(args.get(i),
lastArg));
}
-
+
return lastArg;
}
case FUNCTION:
@@ -118,6 +118,9 @@ public class DrillOptiq {
case POSTFIX:
logger.debug("Postfix");
switch(call.getKind()){
+ case IS_NOT_NULL:
+ case IS_NOT_TRUE:
+ case IS_NOT_FALSE:
case IS_NULL:
case IS_TRUE:
case IS_FALSE:
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/HashJoinPrel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/HashJoinPrel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/HashJoinPrel.java
index 3af1bf4..136eb4c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/HashJoinPrel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/HashJoinPrel.java
@@ -53,7 +53,7 @@ public class HashJoinPrel extends JoinPrel {
@Override
- public JoinRelBase copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode
right, JoinRelType joinType) {
+ public JoinRelBase copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode
right, JoinRelType joinType, boolean semiJoinDone) {
try {
return new HashJoinPrel(this.getCluster(), traitSet, left, right, conditionExpr, joinType);
}catch (InvalidRelException e) {
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/MergeJoinPrel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/MergeJoinPrel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/MergeJoinPrel.java
index ee7d76c..f6b7ef6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/MergeJoinPrel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/MergeJoinPrel.java
@@ -61,7 +61,7 @@ public class MergeJoinPrel extends JoinPrel {
@Override
- public JoinRelBase copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode
right, JoinRelType joinType) {
+ public JoinRelBase copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode
right, JoinRelType joinType, boolean semiJoinDone) {
try {
return new MergeJoinPrel(this.getCluster(), traitSet, left, right, conditionExpr, joinType);
}catch (InvalidRelException e) {
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PlannerSettings.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PlannerSettings.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PlannerSettings.java
index 9313018..998ecc0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PlannerSettings.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PlannerSettings.java
@@ -17,8 +17,6 @@
*/
package org.apache.drill.exec.planner.physical;
-import net.hydromatic.optiq.tools.FrameworkContext;
-
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.server.options.OptionManager;
import org.apache.drill.exec.server.options.OptionValidator;
@@ -26,8 +24,9 @@ import org.apache.drill.exec.server.options.TypeValidators.BooleanValidator;
import org.apache.drill.exec.server.options.TypeValidators.LongValidator;
import org.apache.drill.exec.server.options.TypeValidators.PositiveLongValidator;
import org.apache.drill.exec.server.options.TypeValidators.RangeDoubleValidator;
+import org.eigenbase.relopt.Context;
-public class PlannerSettings implements FrameworkContext{
+public class PlannerSettings implements Context{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PlannerSettings.class);
private int numEndPoints = 0;
@@ -101,7 +100,7 @@ public class PlannerSettings implements FrameworkContext{
public boolean isBroadcastJoinEnabled() {
return options.getOption(BROADCAST.getOptionName()).bool_val;
}
-
+
public boolean isHashSingleKey() {
return options.getOption(HASH_SINGLE_KEY.getOptionName()).bool_val;
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
index c66ff5d..3d44760 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
@@ -95,17 +95,17 @@ public class PrelUtil {
public static Iterator<Prel> iter(RelNode... nodes){
return (Iterator<Prel>) (Object) Arrays.asList(nodes).iterator();
}
-
+
public static Iterator<Prel> iter(List<RelNode> nodes) {
return (Iterator<Prel>) (Object) nodes.iterator();
}
public static PlannerSettings getSettings(RelOptCluster cluster){
- return cluster.getPlanner().getFrameworkContext().unwrap(PlannerSettings.class);
+ return cluster.getPlanner().getContext().unwrap(PlannerSettings.class);
}
public static PlannerSettings getPlannerSettings(RelOptPlanner planner) {
- return planner.getFrameworkContext().unwrap(PlannerSettings.class);
+ return planner.getContext().unwrap(PlannerSettings.class);
}
public static Prel removeSvIfRequired(Prel prel, SelectionVectorMode... allowed){
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/StreamAggPrule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/StreamAggPrule.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/StreamAggPrule.java
index 47a56b8..0375161 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/StreamAggPrule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/StreamAggPrule.java
@@ -51,14 +51,14 @@ public class StreamAggPrule extends AggPruleBase {
public boolean matches(RelOptRuleCall call) {
return PrelUtil.getPlannerSettings(call.getPlanner()).isStreamAggEnabled();
}
-
+
@Override
public void onMatch(RelOptRuleCall call) {
final DrillAggregateRel aggregate = (DrillAggregateRel) call.rel(0);
final RelNode input = aggregate.getChild();
RelCollation collation = getCollation(aggregate);
RelTraitSet traits = null;
-
+
if (aggregate.containsDistinctCall()) {
// currently, don't use StreamingAggregate if any of the logical aggrs contains DISTINCT
return;
@@ -68,78 +68,78 @@ public class StreamAggPrule extends AggPruleBase {
if (aggregate.getGroupSet().isEmpty()) {
DrillDistributionTrait singleDist = DrillDistributionTrait.SINGLETON;
RelTraitSet singleDistTrait = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(singleDist);
-
+
if (create2PhasePlan(call, aggregate)) {
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL) ;
- RelNode convertedInput = convert(input, traits);
+ RelNode convertedInput = convert(input, traits);
if (convertedInput instanceof RelSubset) {
RelSubset subset = (RelSubset) convertedInput;
for (RelNode rel : subset.getRelList()) {
if (!rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE).equals(DrillDistributionTrait.DEFAULT))
{
- DrillDistributionTrait toDist = rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE);
+ DrillDistributionTrait toDist = rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE);
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(toDist);
RelNode newInput = convert(input, traits);
StreamAggPrel phase1Agg = new StreamAggPrel(aggregate.getCluster(), traits,
newInput,
aggregate.getGroupSet(),
- aggregate.getAggCallList(),
+ aggregate.getAggCallList(),
OperatorPhase.PHASE_1of2);
- UnionExchangePrel exch =
+ UnionExchangePrel exch =
new UnionExchangePrel(phase1Agg.getCluster(), singleDistTrait, phase1Agg);
-
+
StreamAggPrel phase2Agg = new StreamAggPrel(aggregate.getCluster(), singleDistTrait,
exch,
aggregate.getGroupSet(),
phase1Agg.getPhase2AggCalls(),
OperatorPhase.PHASE_2of2);
- call.transformTo(phase2Agg);
+ call.transformTo(phase2Agg);
}
}
}
- } else {
+ } else {
createTransformRequest(call, aggregate, input, singleDistTrait);
}
} else {
// hash distribute on all grouping keys
- DrillDistributionTrait distOnAllKeys =
- new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED,
+ DrillDistributionTrait distOnAllKeys =
+ new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED,
ImmutableList.copyOf(getDistributionField(aggregate,
true)));
-
+
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation).plus(distOnAllKeys);
createTransformRequest(call, aggregate, input, traits);
// hash distribute on one grouping key
- DrillDistributionTrait distOnOneKey =
- new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED,
+ DrillDistributionTrait distOnOneKey =
+ new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED,
ImmutableList.copyOf(getDistributionField(aggregate,
false)));
-
+
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation).plus(distOnOneKey);
// Temporarily commenting out the single distkey plan since a few tpch queries (e.g
01.sql) get stuck
// in VolcanoPlanner.canonize() method. Note that the corresponding single distkey
plan for HashAggr works
- // ok. One possibility is that here we have dist on single key but collation on
all keys, so that
- // might be causing some problem.
- /// TODO: re-enable this plan after resolving the issue.
+ // ok. One possibility is that here we have dist on single key but collation on
all keys, so that
+ // might be causing some problem.
+ /// TODO: re-enable this plan after resolving the issue.
// createTransformRequest(call, aggregate, input, traits);
-
+
if (create2PhasePlan(call, aggregate)) {
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL) ;
- RelNode convertedInput = convert(input, traits);
+ RelNode convertedInput = convert(input, traits);
if (convertedInput instanceof RelSubset) {
RelSubset subset = (RelSubset) convertedInput;
for (RelNode rel : subset.getRelList()) {
if (!rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE).equals(DrillDistributionTrait.DEFAULT))
{
- DrillDistributionTrait toDist = rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE);
+ DrillDistributionTrait toDist = rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE);
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation).plus(toDist);
RelNode newInput = convert(input, traits);
StreamAggPrel phase1Agg = new StreamAggPrel(aggregate.getCluster(), traits,
newInput,
aggregate.getGroupSet(),
- aggregate.getAggCallList(),
+ aggregate.getAggCallList(),
OperatorPhase.PHASE_1of2);
int numEndPoints = PrelUtil.getSettings(phase1Agg.getCluster()).numEndPoints();
@@ -152,34 +152,34 @@ public class StreamAggPrule extends AggPruleBase {
StreamAggPrel phase2Agg = new StreamAggPrel(aggregate.getCluster(), traits,
exch,
aggregate.getGroupSet(),
- phase1Agg.getPhase2AggCalls(),
+ phase1Agg.getPhase2AggCalls(),
OperatorPhase.PHASE_2of2);
- call.transformTo(phase2Agg);
+ call.transformTo(phase2Agg);
}
}
- }
+ }
}
- }
+ }
} catch (InvalidRelException e) {
tracer.warning(e.toString());
}
}
- private void createTransformRequest(RelOptRuleCall call, DrillAggregateRel aggregate,
+ private void createTransformRequest(RelOptRuleCall call, DrillAggregateRel aggregate,
RelNode input, RelTraitSet traits) throws InvalidRelException
{
final RelNode convertedInput = convert(input, traits);
-
+
StreamAggPrel newAgg = new StreamAggPrel(aggregate.getCluster(), traits, convertedInput,
aggregate.getGroupSet(),
aggregate.getAggCallList(), OperatorPhase.PHASE_1of1);
-
+
call.transformTo(newAgg);
}
-
-
+
+
private RelCollation getCollation(DrillAggregateRel rel){
-
+
List<RelFieldCollation> fields = Lists.newArrayList();
for (int group : BitSets.toIter(rel.getGroupSet())) {
fields.add(new RelFieldCollation(group));
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
index a48070f..321d79d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
@@ -22,11 +22,11 @@ import java.util.ArrayList;
import java.util.List;
import net.hydromatic.optiq.config.Lex;
+import net.hydromatic.optiq.tools.FrameworkConfig;
import net.hydromatic.optiq.tools.Frameworks;
import net.hydromatic.optiq.tools.Planner;
import net.hydromatic.optiq.tools.RelConversionException;
import net.hydromatic.optiq.tools.RuleSet;
-import net.hydromatic.optiq.tools.StdFrameworkConfig;
import net.hydromatic.optiq.tools.ValidationException;
import org.apache.drill.exec.ops.QueryContext;
@@ -68,7 +68,7 @@ public class DrillSqlWorker {
this.context = context;
RelOptCostFactory costFactory = (context.getPlannerSettings().useDefaultCosting()) ?
null : new DrillCostBase.DrillCostFactory() ;
- StdFrameworkConfig config = StdFrameworkConfig.newBuilder() //
+ FrameworkConfig config = Frameworks.newConfigBuilder() //
.lex(Lex.MYSQL) //
.parserFactory(DrillParserWithCompoundIdConverter.FACTORY) //
.defaultSchema(context.getNewDefaultSchema()) //
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/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 f98d661..f34b1e3 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
@@ -125,4 +125,11 @@ public abstract class AbstractSchema implements Schema{
public Expression getExpression(SchemaPlus parentSchema, String name) {
return EXPRESSION;
}
+
+ @Override
+ public boolean contentsHaveChangedSince(long lastCheck, long now) {
+ return true;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/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 dbfe93f..2d8dee8 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
@@ -89,4 +89,5 @@ public class SubSchemaWrapper extends AbstractSchema {
public String getTypeName() {
return innerSchema.getTypeName();
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java b/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java
index 3e0dc25..e438ec2 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java
@@ -23,6 +23,7 @@ import java.net.URL;
import mockit.Mocked;
import mockit.NonStrictExpectations;
import net.hydromatic.optiq.SchemaPlus;
+import net.hydromatic.optiq.jdbc.SimpleOptiqSchema;
import net.hydromatic.optiq.tools.Frameworks;
import org.apache.drill.common.config.DrillConfig;
@@ -101,7 +102,7 @@ public class PlanningBase extends ExecTest{
registry.init();
final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
final DrillOperatorTable table = new DrillOperatorTable(functionRegistry);
- final SchemaPlus root = Frameworks.createRootSchema(false);
+ final SchemaPlus root = SimpleOptiqSchema.createRootSchema(false);
registry.getSchemaFactory().registerSchemas(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build(),
root);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSqlBracketlessSyntax.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSqlBracketlessSyntax.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSqlBracketlessSyntax.java
index ca1efab..f0ef709 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSqlBracketlessSyntax.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSqlBracketlessSyntax.java
@@ -18,9 +18,10 @@
package org.apache.drill.exec.sql;
import net.hydromatic.optiq.config.Lex;
+import net.hydromatic.optiq.jdbc.SimpleOptiqSchema;
+import net.hydromatic.optiq.tools.FrameworkConfig;
import net.hydromatic.optiq.tools.Frameworks;
import net.hydromatic.optiq.tools.Planner;
-import net.hydromatic.optiq.tools.StdFrameworkConfig;
import org.apache.drill.exec.planner.sql.DrillConvertletTable;
import org.apache.drill.exec.planner.sql.parser.CompoundIdentifierConverter;
@@ -34,10 +35,10 @@ public class TestSqlBracketlessSyntax {
@Test
public void checkComplexExpressionParsing() throws Exception{
- StdFrameworkConfig config = StdFrameworkConfig.newBuilder() //
+ FrameworkConfig config = Frameworks.newConfigBuilder() //
.lex(Lex.MYSQL) //
.parserFactory(DrillParserImpl.FACTORY) //
- .defaultSchema(Frameworks.createRootSchema(false)) //
+ .defaultSchema(SimpleOptiqSchema.createRootSchema(false)) //
.convertletTable(new DrillConvertletTable()) //
.build();
Planner planner = Frameworks.getPlanner(config);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillColumnMetaDataList.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillColumnMetaDataList.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillColumnMetaDataList.java
index 25d6226..51722ea 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillColumnMetaDataList.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillColumnMetaDataList.java
@@ -28,6 +28,8 @@ import org.apache.drill.exec.record.BatchSchema;
import org.apache.drill.exec.record.MaterializedField;
import net.hydromatic.avatica.ColumnMetaData;
+import net.hydromatic.avatica.ColumnMetaData.AvaticaType;
+import net.hydromatic.avatica.ColumnMetaData.Rep;
public class DrillColumnMetaDataList extends BasicList<ColumnMetaData>{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillColumnMetaDataList.class);
@@ -66,16 +68,97 @@ public class DrillColumnMetaDataList extends BasicList<ColumnMetaData>{
t.hasScale() ? t.getScale() : 0, // scale
null, // tablename is null so sqlline doesn't try to retrieve primary keys.
catalogName, // catalogname
- Types.getSqlType(t), // sql type
- t.getMinorType().name()+":" + t.getMode().name(), // typename
+ getAvaticaType(t), // sql type
true, // readonly
false, // writable
false, // definitely writable
- "none", // column class name
- ColumnMetaData.Rep.BOOLEAN // Dummy value for representation as it doesn't apply
in drill's case.
+ "none" // column class name
);
columns[i] =col;
}
}
+ private static AvaticaType getAvaticaType(MajorType t){
+ int sqlTypeId = Types.getSqlType(t);
+ return ColumnMetaData.scalar(sqlTypeId, getSqlTypeName(sqlTypeId), Rep.BOOLEAN /* dummy
value, unused */);
+ }
+
+ private static String getSqlTypeName(int type) {
+ switch (type) {
+ case java.sql.Types.BIT:
+ return "BIT";
+ case java.sql.Types.TINYINT:
+ return "TINYINT";
+ case java.sql.Types.SMALLINT:
+ return "SMALLINT";
+ case java.sql.Types.INTEGER:
+ return "INTEGER";
+ case java.sql.Types.BIGINT:
+ return "BIGINT";
+ case java.sql.Types.FLOAT:
+ return "FLOAT";
+ case java.sql.Types.REAL:
+ return "REAL";
+ case java.sql.Types.DOUBLE:
+ return "DOUBLE";
+ case java.sql.Types.NUMERIC:
+ return "NUMERIC";
+ case java.sql.Types.DECIMAL:
+ return "DECIMAL";
+ case java.sql.Types.CHAR:
+ return "CHAR";
+ case java.sql.Types.VARCHAR:
+ return "VARCHAR";
+ case java.sql.Types.LONGVARCHAR:
+ return "LONGVARCHAR";
+ case java.sql.Types.DATE:
+ return "DATE";
+ case java.sql.Types.TIME:
+ return "TIME";
+ case java.sql.Types.TIMESTAMP:
+ return "TIMESTAMP";
+ case java.sql.Types.BINARY:
+ return "BINARY";
+ case java.sql.Types.VARBINARY:
+ return "VARBINARY";
+ case java.sql.Types.LONGVARBINARY:
+ return "LONGVARBINARY";
+ case java.sql.Types.NULL:
+ return "NULL";
+ case java.sql.Types.OTHER:
+ return "OTHER";
+ case java.sql.Types.JAVA_OBJECT:
+ return "JAVA_OBJECT";
+ case java.sql.Types.DISTINCT:
+ return "DISTINCT";
+ case java.sql.Types.STRUCT:
+ return "STRUCT";
+ case java.sql.Types.ARRAY:
+ return "ARRAY";
+ case java.sql.Types.BLOB:
+ return "BLOB";
+ case java.sql.Types.CLOB:
+ return "CLOB";
+ case java.sql.Types.REF:
+ return "REF";
+ case java.sql.Types.DATALINK:
+ return "DATALINK";
+ case java.sql.Types.BOOLEAN:
+ return "BOOLEAN";
+ case java.sql.Types.ROWID:
+ return "ROWID";
+ case java.sql.Types.NCHAR:
+ return "NCHAR";
+ case java.sql.Types.NVARCHAR:
+ return "NVARCHAR";
+ case java.sql.Types.LONGNVARCHAR:
+ return "LONGNVARCHAR";
+ case java.sql.Types.NCLOB:
+ return "NCLOB";
+ case java.sql.Types.SQLXML:
+ return "SQLXML";
+ }
+
+ return "?";
+}
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
index c2c9dd8..380ee99 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
@@ -21,8 +21,10 @@ import java.sql.SQLException;
import java.util.Calendar;
import java.util.List;
+import net.hydromatic.avatica.ArrayImpl.Factory;
import net.hydromatic.avatica.ColumnMetaData;
import net.hydromatic.avatica.Cursor;
+import net.hydromatic.avatica.Cursor.Accessor;
import org.apache.drill.exec.exception.SchemaChangeException;
import org.apache.drill.exec.record.BatchSchema;
@@ -34,23 +36,23 @@ public class DrillCursor implements Cursor{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillCursor.class);
private static final String UNKNOWN = "--UNKNOWN--";
-
+
private boolean started = false;
private boolean finished = false;
private final RecordBatchLoader currentBatch;
private final DrillResultSet.Listener listener;
private boolean redoFirstNext = false;
private boolean first = true;
-
+
private DrillColumnMetaDataList columnMetaDataList;
private BatchSchema schema;
-
+
final DrillResultSet results;
int currentRecord = 0;
private long recordBatchCount;
private final DrillAccessorList accessors = new DrillAccessorList();
-
+
public DrillCursor(DrillResultSet results) {
super();
this.results = results;
@@ -59,7 +61,7 @@ public class DrillCursor implements Cursor{
}
@Override
- public List<Accessor> createAccessors(List<ColumnMetaData> types, Calendar
localCalendar) {
+ public List<Accessor> createAccessors(List<ColumnMetaData> types, Calendar
localCalendar, Factory factory) {
columnMetaDataList = (DrillColumnMetaDataList) types;
return accessors;
}
@@ -73,9 +75,9 @@ public class DrillCursor implements Cursor{
redoFirstNext = false;
return true;
}
-
+
if(finished) return false;
-
+
if(currentRecord+1 < currentBatch.getRecordCount()){
currentRecord++;
return true;
@@ -90,7 +92,7 @@ public class DrillCursor implements Cursor{
}
first = false;
-
+
if(qrb == null){
finished = true;
return false;
@@ -107,16 +109,16 @@ public class DrillCursor implements Cursor{
} catch (RpcException | InterruptedException | SchemaChangeException e) {
throw new SQLException("Failure while trying to get next result batch.", e);
}
-
+
}
}
-
+
void updateColumns(){
accessors.generateAccessors(this, currentBatch);
columnMetaDataList.updateColumnMetaData(UNKNOWN, UNKNOWN, UNKNOWN, schema);
if(results.changeListener != null) results.changeListener.schemaChanged(schema);
}
-
+
public long getRecordBatchCount(){
return recordBatchCount;
}
@@ -130,5 +132,5 @@ public class DrillCursor implements Cursor{
public boolean wasNull() throws SQLException {
return accessors.wasNull();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/e52d2b66/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2ce0db2..2940f12 100644
--- a/pom.xml
+++ b/pom.xml
@@ -658,7 +658,7 @@
<dependency>
<groupId>net.hydromatic</groupId>
<artifactId>optiq-core</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.9-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.jgrapht</groupId>
|