DRILL-6049: Misc. hygiene and code cleanup changes close apache/drill#1085
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/e791ed62 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/e791ed62 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/e791ed62 Branch: refs/heads/master Commit: e791ed62b1c91c39676c4adef438c689fd84fd4b Parents: d803f0c Author: Paul Rogers <prog...@maprtech.com> Authored: Wed Dec 20 23:59:06 2017 -0800 Committer: Aman Sinha <asi...@maprtech.com> Committed: Wed Jan 24 10:06:03 2018 -0800 ---------------------------------------------------------------------- .../drill/common/exceptions/UserException.java | 69 +++- .../org/apache/drill/common/types/Types.java | 68 +++- .../java/org/apache/drill/test/DrillTest.java | 5 +- .../mapr/db/json/MaprDBJsonRecordReader.java | 4 +- .../exec/store/kafka/KafkaRecordReader.java | 2 +- .../exec/store/mongo/MongoRecordReader.java | 3 +- .../main/codegen/templates/CastDateDate.java | 1 - .../codegen/templates/CastIntervalInterval.java | 2 - .../codegen/templates/CastIntervalVarChar.java | 35 +- .../main/codegen/templates/CastVarCharDate.java | 7 +- .../codegen/templates/CastVarCharInterval.java | 17 +- .../templates/DateIntervalAggrFunctions1.java | 24 +- .../DateDateArithmeticFunctions.java | 6 +- .../DateIntervalArithmeticFunctions.java | 4 +- .../DateTruncFunctions.java | 24 +- .../DateIntervalFunctionTemplates/Extract.java | 28 +- .../IntervalIntervalArithmetic.java | 1 - .../IntervalNumericArithmetic.java | 5 +- .../templates/IntervalAggrFunctions2.java | 18 +- .../org/apache/drill/exec/ExecConstants.java | 11 +- .../exec/expr/fn/impl/DateTypeFunctions.java | 112 ++++-- .../drill/exec/expr/fn/impl/MappifyUtility.java | 7 +- .../drill/exec/ops/BaseOperatorContext.java | 2 +- .../apache/drill/exec/ops/FragmentContext.java | 10 +- .../exec/ops/FragmentContextInterface.java | 16 +- .../apache/drill/exec/ops/OperatorContext.java | 12 +- .../drill/exec/ops/OperatorContextImpl.java | 5 - .../apache/drill/exec/ops/OperatorStats.java | 64 +++- .../drill/exec/physical/base/GroupScan.java | 2 +- .../drill/exec/physical/impl/ImplCreator.java | 2 +- .../drill/exec/physical/impl/ScanBatch.java | 12 +- .../exec/physical/impl/TopN/TopNBatch.java | 2 +- .../impl/project/ProjectRecordBatch.java | 12 +- .../IteratorValidatorBatchIterator.java | 8 +- .../impl/validate/IteratorValidatorCreator.java | 2 +- .../impl/xsort/managed/ExternalSortBatch.java | 27 +- .../impl/xsort/managed/MergeSortWrapper.java | 2 +- .../managed/PriorityQueueCopierWrapper.java | 2 +- .../physical/impl/xsort/managed/SortImpl.java | 13 +- .../impl/xsort/managed/SortMetrics.java | 6 +- .../impl/xsort/managed/SorterWrapper.java | 2 +- .../drill/exec/planner/StarColumnHelper.java | 12 +- .../planner/logical/DrillConstExecutor.java | 4 +- .../planner/logical/PreProcessLogicalRel.java | 4 +- .../visitor/SplitUpComplexExpressions.java | 4 +- .../planner/sql/handlers/SqlHandlerUtil.java | 6 +- .../exec/record/ExpandableHyperContainer.java | 18 +- .../drill/exec/record/RecordBatchLoader.java | 17 +- .../apache/drill/exec/record/SchemaUtil.java | 20 +- .../drill/exec/record/VectorContainer.java | 44 ++- .../apache/drill/exec/record/WritableBatch.java | 3 +- .../exec/record/selection/SelectionVector2.java | 10 +- .../exec/record/selection/SelectionVector4.java | 26 +- .../apache/drill/exec/store/ColumnExplorer.java | 33 +- .../drill/exec/store/ResourceInputStream.java | 1 - .../exec/store/dfs/DrillFSDataInputStream.java | 14 +- .../drill/exec/store/dfs/DrillFileSystem.java | 6 +- .../drill/exec/store/dfs/easy/FileWork.java | 11 +- .../easy/text/compliant/HeaderBuilder.java | 27 +- .../store/easy/text/compliant/TextReader.java | 7 +- .../drill/exec/store/parquet/Metadata.java | 3 +- .../parquet/columnreaders/ParquetSchema.java | 3 +- .../org/apache/drill/exec/util/Utilities.java | 3 +- .../vector/accessor/sql/TimePrintMillis.java | 6 +- .../exec/vector/complex/fn/VectorOutput.java | 16 +- .../java/org/apache/drill/TestStarQueries.java | 16 +- .../drill/exec/DrillSeparatePlanningTest.java | 305 +++++----------- .../java/org/apache/drill/exec/ExecTest.java | 6 + .../exec/compile/TestEvaluationVisitor.java | 2 +- .../fn/interp/ExpressionInterpreterTest.java | 4 +- .../exec/physical/impl/TopN/TopNBatchTest.java | 2 +- .../physical/impl/agg/TestHashAggrSpill.java | 3 +- .../physical/impl/window/TestWindowFrame.java | 1 - .../physical/impl/xsort/TestExternalSort.java | 43 ++- .../impl/xsort/TestSimpleExternalSort.java | 1 + .../impl/xsort/managed/SortTestUtilities.java | 46 +-- .../physical/impl/xsort/managed/TestCopier.java | 10 +- .../managed/TestExternalSortInternals.java | 40 +-- .../impl/xsort/managed/TestSortImpl.java | 17 +- .../physical/impl/xsort/managed/TestSorter.java | 105 ++++-- .../physical/unit/PhysicalOpUnitTestBase.java | 3 +- .../exec/store/easy/text/compliant/TestCsv.java | 6 - .../easy/text/compliant/TestHeaderBuilder.java | 6 +- .../org/apache/drill/test/BaseTestQuery.java | 5 - .../org/apache/drill/test/ClientFixture.java | 27 ++ .../org/apache/drill/test/ClusterFixture.java | 17 + .../java/org/apache/drill/test/ClusterTest.java | 35 ++ .../org/apache/drill/test/DrillTestWrapper.java | 2 +- .../org/apache/drill/test/OperatorFixture.java | 111 ++---- .../org/apache/drill/test/QueryBuilder.java | 47 ++- .../org/apache/drill/test/QueryResultSet.java | 110 ++++++ .../drill/test/rowSet/HyperRowSetImpl.java | 10 + .../drill/test/rowSet/test/PerformanceTool.java | 18 - .../codegen/templates/FixedValueVectors.java | 181 ++++------ .../src/main/codegen/templates/ListWriters.java | 56 +-- .../codegen/templates/NullableValueVectors.java | 34 +- .../main/codegen/templates/UnionListWriter.java | 23 +- .../src/main/codegen/templates/UnionVector.java | 355 ++++++++++++++----- .../src/main/codegen/templates/UnionWriter.java | 12 +- .../templates/VariableLengthVectors.java | 10 +- .../drill/exec/expr/fn/impl/DateUtility.java | 108 +++--- .../drill/exec/record/MaterializedField.java | 147 +++++++- .../drill/exec/vector/BaseDataValueVector.java | 3 + .../drill/exec/vector/BaseValueVector.java | 10 +- .../apache/drill/exec/vector/DateUtilities.java | 191 ++++++++++ .../drill/exec/vector/NullableVector.java | 8 +- .../apache/drill/exec/vector/ValueVector.java | 7 +- .../drill/exec/vector/VariableWidthVector.java | 24 +- .../exec/vector/complex/AbstractMapVector.java | 33 +- .../vector/complex/BaseRepeatedValueVector.java | 1 - .../drill/exec/vector/complex/MapVector.java | 42 ++- .../exec/vector/complex/RepeatedMapVector.java | 21 +- .../vector/complex/RepeatedValueVector.java | 3 +- .../drill/exec/vector/complex/StateTool.java | 8 +- .../vector/complex/impl/PromotableWriter.java | 2 + .../expression/LogicalExpressionBase.java | 11 +- .../drill/common/expression/PathSegment.java | 27 +- .../drill/common/expression/SchemaPath.java | 99 +++++- .../common/logical/FormatPluginConfigBase.java | 6 +- pom.xml | 2 +- .../apache/drill/exec/proto/UserBitShared.java | 295 +++++++++------ .../drill/exec/proto/beans/DrillPBError.java | 8 +- protocol/src/main/protobuf/GeneralRPC.proto | 6 +- protocol/src/main/protobuf/UserBitShared.proto | 16 +- 124 files changed, 2322 insertions(+), 1377 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/common/src/main/java/org/apache/drill/common/exceptions/UserException.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java index 4ea97e5..19a1f91 100644 --- a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java +++ b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java @@ -83,14 +83,6 @@ public class UserException extends DrillRuntimeException { * <p>The cause message will be used unless {@link Builder#message(String, Object...)} is called. * <p>If the wrapped exception is, or wraps, a user exception it will be returned by {@link Builder#build(Logger)} * instead of creating a new exception. Any added context will be added to the user exception as well. - * <p> - * This exception, previously deprecated, has been repurposed to indicate unspecified - * errors. In particular, the case in which a lower level bit of code throws an - * exception other than UserException. The catching code then only knows "something went - * wrong", but not enough information to categorize the error. - * <p> - * System errors also indicate illegal internal states, missing functionality, and other - * code-related errors -- all of which "should never occur." * * @see org.apache.drill.exec.proto.UserBitShared.DrillPBError.ErrorType#SYSTEM * @@ -98,6 +90,8 @@ public class UserException extends DrillRuntimeException { * returned by the builder instead of creating a new user exception * @return user exception builder * + * @deprecated This method should never need to be used explicitly, unless you are passing the exception to the + * Rpc layer or UserResultListener.submitFailed() */ public static Builder systemError(final Throwable cause) { @@ -365,6 +359,47 @@ public class UserException extends DrillRuntimeException { } /** + * Wraps an error that arises from execution due to issues in the query, in + * the environment and so on -- anything other than "this should never occur" + * type checks. + * @param cause exception we want the user exception to wrap. If cause is, or wrap, a user exception it will be + * returned by the builder instead of creating a new user exception + * @return user exception builder + */ + + public static Builder executionError(final Throwable cause) { + return new Builder(DrillPBError.ErrorType.EXECUTION_ERROR, cause); + } + + /** + * Indicates an internal validation failed or similar unexpected error. Indicates + * the problem is likely within Drill itself rather than due to the environment, + * query, etc. + * @param cause exception we want the user exception to wrap. If cause is, or wrap, a user exception it will be + * returned by the builder instead of creating a new user exception + * @return user exception builder + */ + + public static Builder internalError(final Throwable cause) { + return new Builder(DrillPBError.ErrorType.INTERNAL_ERROR, cause); + } + + /** + * Indicates an unspecified error: code caught the exception, but does not have + * visibility into the cause well enough to pick one of the more specific + * error types. In practice, using this exception indicates that error handling + * should be moved closer to the source of the exception so we can provide the + * user with a better explanation than "something went wrong." + * @param cause exception we want the user exception to wrap. If cause is, or wrap, a user exception it will be + * returned by the builder instead of creating a new user exception + * @return user exception builder + */ + public static Builder unspecifiedError(final Throwable cause) { + return new Builder(DrillPBError.ErrorType.UNSPECIFIED_ERROR, cause); + } + + + /** * Builder class for DrillUserException. You can wrap an existing exception, in this case it will first check if * this exception is, or wraps, a DrillUserException. If it does then the builder will use the user exception as it is * (it will ignore the message passed to the constructor) and will add any additional context information to the @@ -402,6 +437,14 @@ public class UserException extends DrillRuntimeException { } } + private Builder(UserException uex) { + this.uex = uex; + cause = uex.getCause(); + errorType = uex.errorType; + context = uex.context; + message = uex.getOriginalMessage(); + } + /** * sets or replaces the error message. * <p>This will be ignored if this builder is wrapping a user exception @@ -415,7 +458,11 @@ public class UserException extends DrillRuntimeException { public Builder message(final String format, final Object... args) { // we can't replace the message of a user exception if (uex == null && format != null) { - this.message = String.format(format, args); + if (args.length == 0) { + message = format; + } else { + message = String.format(format, args); + } } return this; } @@ -636,6 +683,10 @@ public class UserException extends DrillRuntimeException { this.context = builder.context; } + public Builder rebuild() { + return new Builder(this); + } + /** * generates the message that will be displayed to the client without the stack trace. * http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/common/src/main/java/org/apache/drill/common/types/Types.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java index 7c7026b..8f5d1f9 100644 --- a/common/src/main/java/org/apache/drill/common/types/Types.java +++ b/common/src/main/java/org/apache/drill/common/types/Types.java @@ -20,6 +20,9 @@ package org.apache.drill.common.types; import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED; import java.sql.ResultSetMetaData; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.apache.drill.common.exceptions.DrillRuntimeException; import org.apache.drill.common.types.TypeProtos.DataMode; @@ -54,9 +57,9 @@ public class Types { case LIST: case MAP: return true; + default: + return false; } - - return false; } public static boolean isRepeated(final MajorType type) { @@ -460,9 +463,9 @@ public class Types { public static boolean softEquals(final MajorType a, final MajorType b, final boolean allowNullSwap) { if (a.getMinorType() != b.getMinorType()) { - return false; + return false; } - if(allowNullSwap) { + if (allowNullSwap) { switch (a.getMode()) { case OPTIONAL: case REQUIRED: @@ -470,7 +473,9 @@ public class Types { case OPTIONAL: case REQUIRED: return true; + default: } + default: } } return a.getMode() == b.getMode(); @@ -728,4 +733,59 @@ public class Types { return type.getMinorType() == MinorType.LATE; } + public static boolean isEquivalent(MajorType type1, MajorType type2) { + + // Requires full type equality, including fields such as precision and scale. + // But, unset fields are equivalent to 0. Can't use the protobuf-provided + // isEquals() which treats set and unset fields as different. + + if (type1.getMinorType() != type2.getMinorType() || + type1.getMode() != type2.getMode() || + type1.getScale() != type2.getScale() || + type1.getPrecision() != type2.getPrecision()) { + return false; + } + + // Subtypes are only for unions and are seldom used. + + if (type1.getMinorType() != MinorType.UNION) { + return true; + } + + List<MinorType> subtypes1 = type1.getSubTypeList(); + List<MinorType> subtypes2 = type2.getSubTypeList(); + if (subtypes1 == subtypes2) { // Only occurs if both are null + return true; + } + if (subtypes1 == null || subtypes2 == null) { + return false; + } + if (subtypes1.size() != subtypes2.size()) { + return false; + } + + // Now it gets slow because subtype lists are not ordered. + + List<MinorType> copy1 = new ArrayList<>(); + List<MinorType> copy2 = new ArrayList<>(); + copy1.addAll(subtypes1); + copy2.addAll(subtypes2); + Collections.sort(copy1); + Collections.sort(copy2); + return copy1.equals(copy2); + } + + /** + * The union vector is a map of types. The following method provides + * the standard name to use in the type map. It replaces the many + * ad-hoc appearances of this code in each reference to the map. + * + * @param type Drill data type + * @return string key to use for this type in a union vector type + * map + */ + + public static String typeKey(MinorType type) { + return type.name().toLowerCase(); + } } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/common/src/test/java/org/apache/drill/test/DrillTest.java ---------------------------------------------------------------------- diff --git a/common/src/test/java/org/apache/drill/test/DrillTest.java b/common/src/test/java/org/apache/drill/test/DrillTest.java index d949d97..24ec381 100644 --- a/common/src/test/java/org/apache/drill/test/DrillTest.java +++ b/common/src/test/java/org/apache/drill/test/DrillTest.java @@ -29,6 +29,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; +import org.junit.rules.DisableOnDebug; import org.junit.rules.ExpectedException; import org.junit.rules.TestName; import org.junit.rules.TestRule; @@ -40,6 +41,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class DrillTest { + protected static final ObjectMapper objectMapper; static { System.setProperty("line.separator", "\n"); @@ -54,8 +56,7 @@ public class DrillTest { static MemWatcher memWatcher; static String className; - @Rule public final TestRule TIMEOUT = TestTools.getTimeoutRule(100_000); - + @Rule public final TestRule TIMEOUT = new DisableOnDebug(TestTools.getTimeoutRule(100_000)); @Rule public final TestLogReporter logOutcome = LOG_OUTCOME; @Rule public final TestRule REPEAT_RULE = TestTools.getRepeatRule(false); http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java ---------------------------------------------------------------------- diff --git a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java index 113b3ad..1327541 100644 --- a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java +++ b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java @@ -129,13 +129,13 @@ public class MaprDBJsonRecordReader extends AbstractRecordReader { protected Collection<SchemaPath> transformColumns(Collection<SchemaPath> columns) { Set<SchemaPath> transformed = Sets.newLinkedHashSet(); if (disablePushdown) { - transformed.add(Utilities.STAR_COLUMN); + transformed.add(SchemaPath.STAR_COLUMN); includeId = true; return transformed; } if (isStarQuery()) { - transformed.add(Utilities.STAR_COLUMN); + transformed.add(SchemaPath.STAR_COLUMN); includeId = true; if (isSkipQuery()) { // `SELECT COUNT(*)` query http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaRecordReader.java ---------------------------------------------------------------------- diff --git a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaRecordReader.java b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaRecordReader.java index f034a8a..c08c86e 100644 --- a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaRecordReader.java +++ b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/KafkaRecordReader.java @@ -85,7 +85,7 @@ public class KafkaRecordReader extends AbstractRecordReader { transformed.add(column); } } else { - transformed.add(Utilities.STAR_COLUMN); + transformed.add(SchemaPath.STAR_COLUMN); } return transformed; } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java ---------------------------------------------------------------------- diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java index cacb318..da516dd 100644 --- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java +++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoRecordReader.java @@ -35,7 +35,6 @@ import org.apache.drill.exec.ops.OperatorContext; import org.apache.drill.exec.physical.impl.OutputMutator; import org.apache.drill.exec.store.AbstractRecordReader; import org.apache.drill.exec.store.bson.BsonRecordReader; -import org.apache.drill.exec.util.Utilities; import org.apache.drill.exec.vector.BaseValueVector; import org.apache.drill.exec.vector.complex.fn.JsonReader; import org.apache.drill.exec.vector.complex.impl.VectorContainerWriter; @@ -113,7 +112,7 @@ public class MongoRecordReader extends AbstractRecordReader { } else { // Tale all the fields including the _id this.fields.remove(DrillMongoConstants.ID); - transformed.add(Utilities.STAR_COLUMN); + transformed.add(SchemaPath.STAR_COLUMN); } return transformed; } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/CastDateDate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/CastDateDate.java b/exec/java-exec/src/main/codegen/templates/CastDateDate.java index 21e9c21..f4ba51d 100644 --- a/exec/java-exec/src/main/codegen/templates/CastDateDate.java +++ b/exec/java-exec/src/main/codegen/templates/CastDateDate.java @@ -39,7 +39,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/CastIntervalInterval.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/CastIntervalInterval.java b/exec/java-exec/src/main/codegen/templates/CastIntervalInterval.java index ab3e378..f1659ad 100644 --- a/exec/java-exec/src/main/codegen/templates/CastIntervalInterval.java +++ b/exec/java-exec/src/main/codegen/templates/CastIntervalInterval.java @@ -41,7 +41,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. @@ -83,7 +82,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; @SuppressWarnings("unused") @FunctionTemplate(name = "cast${type.to?upper_case}", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls=NullHandling.NULL_IF_NULL) http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java b/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java index 43f9303..eb36263 100644 --- a/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java +++ b/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java @@ -44,7 +44,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. @@ -67,19 +66,19 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { public void eval() { - int years = (in.months / org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); - int months = (in.months % org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + int years = (in.months / org.apache.drill.exec.vector.DateUtilities.yearsToMonths); + int months = (in.months % org.apache.drill.exec.vector.DateUtilities.yearsToMonths); long millis = in.milliseconds; - long hours = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + long hours = millis / (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); - long minutes = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + long minutes = millis / (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); - long seconds = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + long seconds = millis / (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); String yearString = (Math.abs(years) == 1) ? " year " : " years "; String monthString = (Math.abs(months) == 1) ? " month " : " months "; @@ -124,7 +123,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; @SuppressWarnings("unused") @FunctionTemplate(name = "cast${type.to?upper_case}", @@ -143,8 +141,8 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { } public void eval() { - int years = (in.value / org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); - int months = (in.value % org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + int years = (in.value / org.apache.drill.exec.vector.DateUtilities.yearsToMonths); + int months = (in.value % org.apache.drill.exec.vector.DateUtilities.yearsToMonths); String yearString = (Math.abs(years) == 1) ? " year " : " years "; String monthString = (Math.abs(months) == 1) ? " month " : " months "; @@ -184,7 +182,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; import javax.inject.Inject; import io.netty.buffer.DrillBuf; @@ -208,14 +205,14 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { public void eval() { long millis = in.milliseconds; - long hours = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + long hours = millis / (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); - long minutes = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + long minutes = millis / (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); - long seconds = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); - millis = millis % (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + long seconds = millis / (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); + millis = millis % (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); String dayString = (Math.abs(in.days) == 1) ? " day " : " days "; http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java index 4c51ba8..d035a99 100644 --- a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java +++ b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -39,7 +39,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; import javax.inject.Inject; import io.netty.buffer.DrillBuf; @@ -54,8 +53,7 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { @Param ${type.from}Holder in; @Output ${type.to}Holder out; - public void setup() { - } + public void setup() { } public void eval() { @@ -76,7 +74,6 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeFormatter(); out.value = (int) ((f.parseDateTime(input)).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis()); </#if> - } } </#if> <#-- type.major --> http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/CastVarCharInterval.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/CastVarCharInterval.java b/exec/java-exec/src/main/codegen/templates/CastVarCharInterval.java index d8b2024..8f68ff6 100644 --- a/exec/java-exec/src/main/codegen/templates/CastVarCharInterval.java +++ b/exec/java-exec/src/main/codegen/templates/CastVarCharInterval.java @@ -39,7 +39,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; import javax.inject.Inject; import io.netty.buffer.DrillBuf; @@ -66,24 +65,24 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc { org.joda.time.Period period = org.joda.time.Period.parse(input); <#if type.to == "Interval"> - out.months = (period.getYears() * org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths) + period.getMonths(); + out.months = (period.getYears() * org.apache.drill.exec.vector.DateUtilities.yearsToMonths) + period.getMonths(); out.days = period.getDays(); - out.milliseconds = (period.getHours() * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (period.getMinutes() * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (period.getSeconds() * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + + out.milliseconds = (period.getHours() * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (period.getMinutes() * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (period.getSeconds() * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + (period.getMillis()); <#elseif type.to == "IntervalDay"> out.days = period.getDays(); - out.milliseconds = (period.getHours() * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (period.getMinutes() * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (period.getSeconds() * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + + out.milliseconds = (period.getHours() * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (period.getMinutes() * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (period.getSeconds() * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + (period.getMillis()); <#elseif type.to == "IntervalYear"> - out.value = (period.getYears() * org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths) + period.getMonths(); + out.value = (period.getYears() * org.apache.drill.exec.vector.DateUtilities.yearsToMonths) + period.getMonths(); </#if> } } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java b/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java index b2a0525..18be0b7 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java @@ -86,14 +86,14 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu <#if type.outputType?ends_with("Interval")> - long inMS = (long) in.months * org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis+ - in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + long inMS = (long) in.months * org.apache.drill.exec.vector.DateUtilities.monthsToMillis+ + in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; value.value = Math.min(value.value, inMS); <#elseif type.outputType?ends_with("IntervalDay")> - long inMS = (long) in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + long inMS = (long) in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; value.value = Math.min(value.value, inMS); @@ -104,13 +104,13 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu </#if> <#elseif aggrtype.funcName == "max"> <#if type.outputType?ends_with("Interval")> - long inMS = (long) in.months * org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis+ - in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + long inMS = (long) in.months * org.apache.drill.exec.vector.DateUtilities.monthsToMillis+ + in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; value.value = Math.max(value.value, inMS); <#elseif type.outputType?ends_with("IntervalDay")> - long inMS = (long) in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + long inMS = (long) in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; value.value = Math.max(value.value, inMS); @@ -145,13 +145,13 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu out.isSet = 1; <#if aggrtype.funcName == "max" || aggrtype.funcName == "min"> <#if type.outputType?ends_with("Interval")> - out.months = (int) (value.value / org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis); - value.value = value.value % org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis; - out.days = (int) (value.value / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); - out.milliseconds = (int) (value.value % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.months = (int) (value.value / org.apache.drill.exec.vector.DateUtilities.monthsToMillis); + value.value = value.value % org.apache.drill.exec.vector.DateUtilities.monthsToMillis; + out.days = (int) (value.value / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); + out.milliseconds = (int) (value.value % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); <#elseif type.outputType?ends_with("IntervalDay")> - out.days = (int) (value.value / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); - out.milliseconds = (int) (value.value % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.days = (int) (value.value / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); + out.milliseconds = (int) (value.value % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); <#else> out.value = value.value; </#if> http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java index 04eb327..03db5e6 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java @@ -61,11 +61,11 @@ public static class G${type}Difference implements DrillSimpleFunc { <#if type == "Time"> out.milliseconds = left.value - right.value; <#elseif type == "Date"> - out.days = (int) ((left.value - right.value) / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.days = (int) ((left.value - right.value) / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); <#elseif type == "TimeStamp"> long difference = (left.value - right.value); - out.milliseconds = (int) (difference % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); - out.days = (int) (difference / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.milliseconds = (int) (difference % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); + out.days = (int) (difference / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); </#if> } } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java index 57e7f68..5c9f5de 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java @@ -41,7 +41,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. @@ -160,7 +159,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. @@ -178,7 +176,7 @@ public class ${datetype}${intervaltype}Functions { <#else> ${output} = ${left}.value ${op} ${right}.milliseconds; // Wrap around 24 hour clock if we exceeded it while adding the time component - ${output} = ${output} % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; + ${output} = ${output} % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; </#if> </#macro> http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java index 702f717..480d501 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java @@ -213,19 +213,19 @@ public class GDateTimeTruncateFunctions { <#if toUnit == "Second"> <#-- Start UnitType --> out.months = right.months; out.days = right.days; - out.milliseconds = (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + out.milliseconds = (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.secondsToMillis))* + (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); <#elseif toUnit == "Minute"> out.months = right.months; out.days = right.days; - out.milliseconds = (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + out.milliseconds = (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.minutesToMillis))* + (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); <#elseif toUnit == "Hour"> out.months = right.months; out.days = right.days; out.milliseconds = - (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.hoursToMillis))* + (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); <#elseif toUnit == "Day"> out.months = right.months; out.days = right.days; @@ -258,17 +258,17 @@ public class GDateTimeTruncateFunctions { <#elseif type == "IntervalDay"> <#if toUnit == "Second"> <#-- Start UnitType --> out.days = right.days; - out.milliseconds = (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + out.milliseconds = (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.secondsToMillis))* + (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); <#elseif toUnit == "Minute"> out.days = right.days; - out.milliseconds = (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + out.milliseconds = (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.minutesToMillis))* + (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); <#elseif toUnit == "Hour"> out.days = right.days; out.milliseconds = - (right.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis))* - (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + (right.milliseconds/(org.apache.drill.exec.vector.DateUtilities.hoursToMillis))* + (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); <#elseif toUnit == "Day"> out.days = right.days; out.milliseconds = 0; http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java index a64d655..2442672 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java @@ -92,19 +92,19 @@ public class ${className} { public void eval() { <#if fromUnit == "Interval"> <#if toUnit == "Year"> - out.value = (in.months / org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + out.value = (in.months / org.apache.drill.exec.vector.DateUtilities.yearsToMonths); <#elseif toUnit == "Month"> - out.value = (in.months % org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + out.value = (in.months % org.apache.drill.exec.vector.DateUtilities.yearsToMonths); <#elseif toUnit == "Day"> out.value = in.days; <#elseif toUnit == "Hour"> - out.value = in.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + out.value = in.milliseconds/(org.apache.drill.exec.vector.DateUtilities.hoursToMillis); <#elseif toUnit == "Minute"> - int millis = in.milliseconds % (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); - out.value = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + int millis = in.milliseconds % (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); + out.value = millis / (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); <#elseif toUnit == "Second"> - long millis = in.milliseconds % org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis; - out.value = (double) millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + long millis = in.milliseconds % org.apache.drill.exec.vector.DateUtilities.minutesToMillis; + out.value = (double) millis / (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); </#if> <#elseif fromUnit == "IntervalDay"> <#if toUnit == "Year" || toUnit == "Month"> @@ -112,19 +112,19 @@ public class ${className} { <#elseif toUnit == "Day"> out.value = in.days; <#elseif toUnit == "Hour"> - out.value = in.milliseconds/(org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); + out.value = in.milliseconds/(org.apache.drill.exec.vector.DateUtilities.hoursToMillis); <#elseif toUnit == "Minute"> - int millis = in.milliseconds % (org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis); - out.value = millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis); + int millis = in.milliseconds % (org.apache.drill.exec.vector.DateUtilities.hoursToMillis); + out.value = millis / (org.apache.drill.exec.vector.DateUtilities.minutesToMillis); <#elseif toUnit == "Second"> - long millis = in.milliseconds % org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis; - out.value = (double) millis / (org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis); + long millis = in.milliseconds % org.apache.drill.exec.vector.DateUtilities.minutesToMillis; + out.value = (double) millis / (org.apache.drill.exec.vector.DateUtilities.secondsToMillis); </#if> <#else> <#-- IntervalYear type --> <#if toUnit == "Year"> - out.value = (in.value / org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + out.value = (in.value / org.apache.drill.exec.vector.DateUtilities.yearsToMonths); <#elseif toUnit == "Month"> - out.value = (in.value % org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths); + out.value = (in.value % org.apache.drill.exec.vector.DateUtilities.yearsToMonths); <#else> out.value = 0; </#if> http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java index b248c35..41af7eb 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalIntervalArithmetic.java @@ -39,7 +39,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalNumericArithmetic.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalNumericArithmetic.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalNumericArithmetic.java index 8a8e966..6e06c0c 100644 --- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalNumericArithmetic.java +++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/IntervalNumericArithmetic.java @@ -39,7 +39,6 @@ import org.apache.drill.exec.record.RecordBatch; import org.joda.time.MutableDateTime; import org.joda.time.DateTimeZone; import org.joda.time.DateMidnight; -import org.apache.drill.exec.expr.fn.impl.DateUtility; /* * This class is generated using freemarker and the ${.template_name} template. @@ -82,12 +81,12 @@ public class ${intervaltype}${numerictype}Functions { // Transfer fractional part to days fractionalMonths = fractionalMonths - (long) fractionalMonths; - fractionalDays += fractionalMonths * org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays; + fractionalDays += fractionalMonths * org.apache.drill.exec.vector.DateUtilities.monthToStandardDays; ${out}.days = (int) fractionalDays; // Transfer fractional part to millis fractionalDays = fractionalDays - (long) fractionalDays; - fractionalMillis += fractionalDays * org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; + fractionalMillis += fractionalDays * org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; ${out}.milliseconds = (int) fractionalMillis; </#macro> http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/codegen/templates/IntervalAggrFunctions2.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/IntervalAggrFunctions2.java b/exec/java-exec/src/main/codegen/templates/IntervalAggrFunctions2.java index 8e7fed5..7973629 100644 --- a/exec/java-exec/src/main/codegen/templates/IntervalAggrFunctions2.java +++ b/exec/java-exec/src/main/codegen/templates/IntervalAggrFunctions2.java @@ -82,11 +82,11 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu nonNullCount.value = 1; <#if aggrtype.funcName == "avg"> <#if type.inputType.endsWith("Interval")> - sum.value += (long) in.months * org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays + - in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + sum.value += (long) in.months * org.apache.drill.exec.vector.DateUtilities.monthToStandardDays + + in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; <#elseif type.inputType.endsWith("IntervalDay")> - sum.value += (long) in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) + + sum.value += (long) in.days * (org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis) + in.milliseconds; <#else> sum.value += in.value; @@ -107,14 +107,14 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu out.isSet = 1; double millis = sum.value / ((double) count.value); <#if type.inputType.endsWith("Interval") || type.inputType.endsWith("IntervalYear")> - out.months = (int) (millis / org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis); - millis = millis % org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis; - out.days =(int) (millis / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); - out.milliseconds = (int) (millis % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.months = (int) (millis / org.apache.drill.exec.vector.DateUtilities.monthsToMillis); + millis = millis % org.apache.drill.exec.vector.DateUtilities.monthsToMillis; + out.days =(int) (millis / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); + out.milliseconds = (int) (millis % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); <#elseif type.inputType.endsWith("IntervalDay")> out.months = 0; - out.days = (int) (millis / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); - out.milliseconds = (int) (millis % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.days = (int) (millis / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); + out.milliseconds = (int) (millis % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); </#if> } else { out.isSet = 0; http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java index c3e9d46..25f6135 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java @@ -252,7 +252,7 @@ public final class ExecConstants { public static final String PARQUET_COLUMNREADER_ASYNC = "store.parquet.reader.columnreader.async"; public static final OptionValidator PARQUET_COLUMNREADER_ASYNC_VALIDATOR = new BooleanValidator(PARQUET_COLUMNREADER_ASYNC); - // Use a buffering reader for parquet page reader + // Use a buffering reader for Parquet page reader public static final String PARQUET_PAGEREADER_USE_BUFFERED_READ = "store.parquet.reader.pagereader.bufferedread"; public static final OptionValidator PARQUET_PAGEREADER_USE_BUFFERED_READ_VALIDATOR = new BooleanValidator(PARQUET_PAGEREADER_USE_BUFFERED_READ); @@ -289,13 +289,13 @@ public final class ExecConstants { public static final BooleanValidator JSON_READER_NAN_INF_NUMBERS_VALIDATOR = new BooleanValidator(JSON_READER_NAN_INF_NUMBERS); /** * The column label (for directory levels) in results when querying files in a directory - * E.g. labels: dir0 dir1 + * E.g. labels: dir0 dir1<pre> * structure: foo * |- bar - a.parquet - * |- baz - b.parquet + * |- baz - b.parquet</pre> */ public static final String FILESYSTEM_PARTITION_COLUMN_LABEL = "drill.exec.storage.file.partition.column.label"; - public static final OptionValidator FILESYSTEM_PARTITION_COLUMN_LABEL_VALIDATOR = new StringValidator(FILESYSTEM_PARTITION_COLUMN_LABEL); + public static final StringValidator FILESYSTEM_PARTITION_COLUMN_LABEL_VALIDATOR = new StringValidator(FILESYSTEM_PARTITION_COLUMN_LABEL); /** * Implicit file columns @@ -319,7 +319,8 @@ public final class ExecConstants { public static final String MONGO_BSON_RECORD_READER = "store.mongo.bson.record.reader"; public static final OptionValidator MONGO_BSON_RECORD_READER_VALIDATOR = new BooleanValidator(MONGO_BSON_RECORD_READER); - public static final BooleanValidator ENABLE_UNION_TYPE = new BooleanValidator("exec.enable_union_type"); + public static final String ENABLE_UNION_TYPE_KEY = "exec.enable_union_type"; + public static final BooleanValidator ENABLE_UNION_TYPE = new BooleanValidator(ENABLE_UNION_TYPE_KEY); // Kafka plugin related options. public static final String KAFKA_ALL_TEXT_MODE = "store.kafka.all_text_mode"; http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java index e136d15..a719ec0 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java @@ -65,8 +65,10 @@ public class DateTypeFunctions { @Param NullableVarCharHolder in; @Output BitHolder out; + @Override public void setup() { } + @Override public void eval() { // for a null input return false if (in.isSet == 0) { @@ -86,8 +88,10 @@ public class DateTypeFunctions { @Param VarCharHolder in; @Output BitHolder out; + @Override public void setup() { } + @Override public void eval() { // for a null input return false out.value = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.isReadableAsDate(in.buffer, in.start, in.end) ? 1 : 0; @@ -106,17 +110,19 @@ public class DateTypeFunctions { @Param BigIntHolder inputMilliSeconds; @Output IntervalHolder out; + @Override public void setup() { } + @Override public void eval() { - out.months = (int) ((inputYears.value * org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths) + + out.months = (int) ((inputYears.value * org.apache.drill.exec.vector.DateUtilities.yearsToMonths) + (inputMonths.value)); out.days = (int) inputDays.value; - out.milliseconds = (int) ((inputHours.value * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (inputMinutes.value * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (inputSeconds.value * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + + out.milliseconds = (int) ((inputHours.value * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (inputMinutes.value * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (inputSeconds.value * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + (inputMilliSeconds.value)); } } @@ -128,12 +134,14 @@ public class DateTypeFunctions { @Param BigIntHolder inputMonths; @Output IntervalYearHolder out; + @Override public void setup() { } + @Override public void eval() { - out.value = (int) ((inputYears.value * org.apache.drill.exec.expr.fn.impl.DateUtility.yearsToMonths) + + out.value = (int) ((inputYears.value * org.apache.drill.exec.vector.DateUtilities.yearsToMonths) + (inputMonths.value)); } } @@ -148,15 +156,17 @@ public class DateTypeFunctions { @Param BigIntHolder inputMillis; @Output IntervalDayHolder out; + @Override public void setup() { } + @Override public void eval() { out.days = (int) inputDays.value; - out.milliseconds = (int) ((inputHours.value * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (inputMinutes.value * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (inputSeconds.value * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + + out.milliseconds = (int) ((inputHours.value * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (inputMinutes.value * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (inputSeconds.value * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + (inputMillis.value)); } } @@ -169,9 +179,11 @@ public class DateTypeFunctions { @Param BigIntHolder inputDays; @Output DateHolder out; + @Override public void setup() { } + @Override public void eval() { out.value = ((new org.joda.time.MutableDateTime((int) inputYears.value, (int) inputMonths.value, @@ -196,9 +208,11 @@ public class DateTypeFunctions { @Param BigIntHolder inputMilliSeconds; @Output TimeStampHolder out; + @Override public void setup() { } + @Override public void eval() { out.value = ((new org.joda.time.MutableDateTime((int)inputYears.value, (int)inputMonths.value, @@ -220,13 +234,15 @@ public class DateTypeFunctions { @Param BigIntHolder inputMilliSeconds; @Output TimeHolder out; + @Override public void setup() { } + @Override public void eval() { - out.value = (int) ((inputHours.value * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (inputMinutes.value * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (inputSeconds.value * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + + out.value = (int) ((inputHours.value * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (inputMinutes.value * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (inputSeconds.value * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + inputMilliSeconds.value); } } @@ -237,6 +253,7 @@ public class DateTypeFunctions { @Output DateHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); @@ -246,6 +263,7 @@ public class DateTypeFunctions { withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); } + @Override public void eval() { out.value = queryStartDate; } @@ -257,9 +275,11 @@ public class DateTypeFunctions { @Inject DrillBuf buffer; @Output VarCharHolder out; + @Override public void setup() { } + @Override public void eval() { org.joda.time.DateTime temp = new org.joda.time.DateTime(); String str = org.apache.drill.exec.expr.fn.impl.DateUtility.formatTimeStampTZ.print(temp); @@ -287,10 +307,12 @@ public class DateTypeFunctions { @Output TimeStampHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { queryStartDate = org.apache.drill.exec.expr.fn.impl.DateTypeFunctions.getQueryStartDate(contextInfo); } + @Override public void eval() { out.value = queryStartDate; } @@ -305,10 +327,12 @@ public class DateTypeFunctions { @Output TimeStampHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { queryStartDate = org.apache.drill.exec.expr.fn.impl.DateTypeFunctions.getQueryStartDate(contextInfo); } + @Override public void eval() { out.value = queryStartDate; } @@ -320,17 +344,19 @@ public class DateTypeFunctions { @Output TimeHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex)); org.joda.time.DateTime now = new org.joda.time.DateTime(contextInfo.getQueryStartTime(), timeZone); - queryStartTime= (int) ((now.getHourOfDay() * org.apache.drill.exec.expr.fn.impl.DateUtility.hoursToMillis) + - (now.getMinuteOfHour() * org.apache.drill.exec.expr.fn.impl.DateUtility.minutesToMillis) + - (now.getSecondOfMinute() * org.apache.drill.exec.expr.fn.impl.DateUtility.secondsToMillis) + - (now.getMillisOfSecond())); + queryStartTime= (now.getHourOfDay() * org.apache.drill.exec.vector.DateUtilities.hoursToMillis) + + (now.getMinuteOfHour() * org.apache.drill.exec.vector.DateUtilities.minutesToMillis) + + (now.getSecondOfMinute() * org.apache.drill.exec.vector.DateUtilities.secondsToMillis) + + (now.getMillisOfSecond()); } + @Override public void eval() { out.value = queryStartTime; } @@ -343,9 +369,11 @@ public class DateTypeFunctions { @Param TimeHolder right; @Output TimeStampHolder out; + @Override public void setup() { } + @Override public void eval() { out.value = left.value + right.value; } @@ -358,9 +386,11 @@ public class DateTypeFunctions { @Param DateHolder left; @Output TimeStampHolder out; + @Override public void setup() { } + @Override public void eval() { out.value = left.value + right.value; } @@ -377,9 +407,11 @@ public class DateTypeFunctions { @Param DateHolder right; @Output BigIntHolder out; + @Override public void setup() { } + @Override public void eval() { if (1 == 1) { throw new UnsupportedOperationException("date_part function should be rewritten as extract() functions"); @@ -387,26 +419,26 @@ public class DateTypeFunctions { } } - @SuppressWarnings("unused") @FunctionTemplate(name = "age", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) public static class AgeTimeStampFunction implements DrillSimpleFunc { @Param TimeStampHolder left; @Param TimeStampHolder right; @Output IntervalHolder out; + @Override public void setup() { } + @Override public void eval() { long diff = left.value - right.value; - long days = diff / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; - out.months = (int) (days / org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.days = (int) (days % org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.milliseconds = (int) (diff % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + long days = diff / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; + out.months = (int) (days / org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.days = (int) (days % org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.milliseconds = (int) (diff % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); } } - @SuppressWarnings("unused") @FunctionTemplate(name = "age", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) public static class AgeTimeStamp2Function implements DrillSimpleFunc { @Param TimeStampHolder right; @@ -414,6 +446,7 @@ public class DateTypeFunctions { @Output IntervalHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex)); @@ -421,35 +454,36 @@ public class DateTypeFunctions { queryStartDate = (new org.joda.time.DateMidnight(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), timeZone)).getMillis(); } + @Override public void eval() { long diff = queryStartDate - right.value; - long days = diff / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; - out.months = (int) (days / org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.days = (int) (days % org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.milliseconds = (int) (diff % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + long days = diff / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; + out.months = (int) (days / org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.days = (int) (days % org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.milliseconds = (int) (diff % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); } } - @SuppressWarnings("unused") @FunctionTemplate(name = "age", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) public static class AgeDateFunction implements DrillSimpleFunc { @Param DateHolder left; @Param DateHolder right; @Output IntervalHolder out; + @Override public void setup() { } + @Override public void eval() { long diff = left.value - right.value; - long days = diff / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; - out.months = (int) (days / org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.days = (int) (days % org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.milliseconds = (int) (diff % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + long days = diff / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; + out.months = (int) (days / org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.days = (int) (days % org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.milliseconds = (int) (diff % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); } } - @SuppressWarnings("unused") @FunctionTemplate(name = "age", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) public static class AgeDate2Function implements DrillSimpleFunc { @Param DateHolder right; @@ -457,6 +491,7 @@ public class DateTypeFunctions { @Output IntervalHolder out; @Inject ContextInformation contextInfo; + @Override public void setup() { int timeZoneIndex = contextInfo.getRootFragmentTimeZone(); org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex)); @@ -464,12 +499,13 @@ public class DateTypeFunctions { queryStartDate = (new org.joda.time.DateMidnight(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), timeZone)).getMillis(); } + @Override public void eval() { long diff = queryStartDate - right.value; - long days = diff / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis; - out.months = (int) (days / org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.days = (int) (days % org.apache.drill.exec.expr.fn.impl.DateUtility.monthToStandardDays); - out.milliseconds = (int) (diff % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + long days = diff / org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis; + out.months = (int) (days / org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.days = (int) (days % org.apache.drill.exec.vector.DateUtilities.monthToStandardDays); + out.milliseconds = (int) (diff % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); } } @@ -484,7 +520,7 @@ public class DateTypeFunctions { @Override public void eval() { - out.value = (int) (in.value % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis); + out.value = (int) (in.value % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis); } } @@ -520,7 +556,7 @@ public class DateTypeFunctions { @Override public void eval() { String inputDate = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(inputDateValue.start, inputDateValue.end, inputDateValue.buffer); - date = (org.joda.time.DateTime) formatter.parseDateTime(inputDate); + date = formatter.parseDateTime(inputDate); out.value = date.getMillis() / 1000; } } @@ -542,7 +578,7 @@ public class DateTypeFunctions { @Override public void eval() { String inputDate = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(inputDateValue.start, inputDateValue.end, inputDateValue.buffer); - date = (org.joda.time.DateTime) formatter.parseDateTime(inputDate); + date = formatter.parseDateTime(inputDate); out.value = date.getMillis() / 1000; } } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java index b7877df..97e0099 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java @@ -17,22 +17,23 @@ */ package org.apache.drill.exec.expr.fn.impl; -import com.google.common.base.Charsets; +import java.util.Iterator; import org.apache.drill.common.exceptions.DrillRuntimeException; import org.apache.drill.common.types.TypeProtos.DataMode; //import org.apache.drill.common.types.DataMode; import org.apache.drill.common.types.MinorType; import org.apache.drill.common.types.TypeProtos; +import org.apache.drill.common.types.TypeProtos.DataMode; import org.apache.drill.exec.expr.holders.VarCharHolder; import org.apache.drill.exec.vector.complex.MapUtility; import org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl; import org.apache.drill.exec.vector.complex.reader.FieldReader; import org.apache.drill.exec.vector.complex.writer.BaseWriter; -import io.netty.buffer.DrillBuf; +import com.google.common.base.Charsets; -import java.util.Iterator; +import io.netty.buffer.DrillBuf; public class MappifyUtility { http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/ops/BaseOperatorContext.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/BaseOperatorContext.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/BaseOperatorContext.java index 123f8fa..7c87570 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/BaseOperatorContext.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/BaseOperatorContext.java @@ -180,7 +180,7 @@ public abstract class BaseOperatorContext implements OperatorContext { @Override public DrillFileSystem newFileSystem(Configuration conf) throws IOException { Preconditions.checkState(fs == null, "Tried to create a second FileSystem. Can only be called once per OperatorContext"); - fs = new DrillFileSystem(conf, getStatsWriter()); + fs = new DrillFileSystem(conf, getStats()); return fs; } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/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 210d0d4..d77d0b8 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 @@ -48,7 +48,6 @@ import org.apache.drill.exec.server.DrillbitContext; import org.apache.drill.exec.server.options.FragmentOptionManager; import org.apache.drill.exec.server.options.OptionList; import org.apache.drill.exec.server.options.OptionManager; -import org.apache.drill.exec.server.options.OptionSet; import org.apache.drill.exec.store.PartitionExplorer; import org.apache.drill.exec.store.SchemaConfig; import org.apache.drill.exec.testing.ExecutionControls; @@ -190,12 +189,8 @@ public class FragmentContext extends BaseFragmentContext implements AutoCloseabl this(dbContext, fragment, null, connection, funcRegistry); } - public OptionManager getOptions() { - return fragmentOptions; - } - @Override - public OptionSet getOptionSet() { + public OptionManager getOptions() { return fragmentOptions; } @@ -345,6 +340,7 @@ public class FragmentContext extends BaseFragmentContext implements AutoCloseabl return buffers; } + @Override public OperatorContext newOperatorContext(PhysicalOperator popConfig, OperatorStats stats) throws OutOfMemoryException { OperatorContextImpl context = new OperatorContextImpl(popConfig, this, stats); @@ -352,6 +348,7 @@ public class FragmentContext extends BaseFragmentContext implements AutoCloseabl return context; } + @Override public OperatorContext newOperatorContext(PhysicalOperator popConfig) throws OutOfMemoryException { OperatorContextImpl context = new OperatorContextImpl(popConfig, this); @@ -385,6 +382,7 @@ public class FragmentContext extends BaseFragmentContext implements AutoCloseabl return executionControls; } + @Override public String getQueryUserName() { return fragment.getCredentials().getUserName(); } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextInterface.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextInterface.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextInterface.java index 7d4ba18..9dbc411 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextInterface.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContextInterface.java @@ -22,11 +22,13 @@ import java.util.List; import org.apache.drill.common.config.DrillConfig; import org.apache.drill.exec.exception.ClassTransformationException; +import org.apache.drill.exec.exception.OutOfMemoryException; import org.apache.drill.exec.expr.ClassGenerator; import org.apache.drill.exec.expr.CodeGenerator; import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; +import org.apache.drill.exec.physical.base.PhysicalOperator; import org.apache.drill.exec.server.DrillbitContext; -import org.apache.drill.exec.server.options.OptionSet; +import org.apache.drill.exec.server.options.OptionManager; import org.apache.drill.exec.testing.ExecutionControls; import io.netty.buffer.DrillBuf; @@ -57,10 +59,10 @@ public interface FragmentContextInterface { */ FunctionImplementationRegistry getFunctionRegistry(); /** - * Returns a read-only version of the session options. + * Returns the session options. * @return the session options */ - OptionSet getOptionSet(); + OptionManager getOptions(); /** * Generates code for a class given a {@link ClassGenerator}, @@ -146,4 +148,12 @@ public interface FragmentContextInterface { DrillBuf getManagedBuffer(); DrillBuf getManagedBuffer(int size); + + OperatorContext newOperatorContext(PhysicalOperator popConfig, OperatorStats stats) + throws OutOfMemoryException; + OperatorContext newOperatorContext(PhysicalOperator popConfig) + throws OutOfMemoryException; + + String getQueryUserName(); + } http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContext.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContext.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContext.java index 37653e0..3d2fdd8 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContext.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContext.java @@ -71,21 +71,11 @@ public interface OperatorContext { ExecutionControls getExecutionControls(); /** - * A write-only interface to the Drill statistics mechanism. Allows + * Drill statistics mechanism. Allows * operators to update statistics. * @return operator statistics */ - OperatorStatReceiver getStatsWriter(); - - /** - * Full operator stats (for legacy code). Prefer - * <tt>getStatsWriter()</tt> to allow code to easily run in a - * test environment. - * - * @return operator statistics - */ - OperatorStats getStats(); ExecutorService getExecutor(); http://git-wip-us.apache.org/repos/asf/drill/blob/e791ed62/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContextImpl.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContextImpl.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContextImpl.java index bc85c39..e4c7dd9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContextImpl.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/OperatorContextImpl.java @@ -88,11 +88,6 @@ class OperatorContextImpl extends BaseOperatorContext implements AutoCloseable { } @Override - public OperatorStatReceiver getStatsWriter() { - return stats; - } - - @Override public <RESULT> ListenableFuture<RESULT> runCallableAs(final UserGroupInformation proxyUgi, final Callable<RESULT> callable) { synchronized (this) {