implement function to cast from long to date, timestamp
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/255d528e Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/255d528e Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/255d528e Branch: refs/heads/master Commit: 255d528ef93c2fe34c6c5fa4051b711daa4b8271 Parents: 2faf6ef Author: Steven Phillips <[email protected]> Authored: Mon Mar 31 16:20:19 2014 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Sat Apr 19 18:07:09 2014 -0700 ---------------------------------------------------------------------- .../drill/exec/expr/fn/impl/CastBigIntDate.java | 46 ++++++++++++++++++++ .../exec/expr/fn/impl/CastBigIntTimeStamp.java | 46 ++++++++++++++++++++ 2 files changed, 92 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/255d528e/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntDate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntDate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntDate.java new file mode 100644 index 0000000..e2586d8 --- /dev/null +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntDate.java @@ -0,0 +1,46 @@ +/** + * 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 + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import org.apache.drill.exec.expr.DrillSimpleFunc; +import org.apache.drill.exec.expr.annotations.FunctionTemplate; +import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling; +import org.apache.drill.exec.expr.annotations.Output; +import org.apache.drill.exec.expr.annotations.Param; +import org.apache.drill.exec.expr.holders.BigIntHolder; +import org.apache.drill.exec.expr.holders.DateHolder; +import org.apache.drill.exec.record.RecordBatch; + +@SuppressWarnings("unused") +@FunctionTemplate(name = "castDATE", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls= NullHandling.NULL_IF_NULL) +public class CastBigIntDate implements DrillSimpleFunc { + + @Param + BigIntHolder in; + @Output + DateHolder out; + + @Override + public void setup(RecordBatch incoming) { + } + + @Override + public void eval() { + out.value = in.value; + } +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/255d528e/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStamp.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStamp.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStamp.java new file mode 100644 index 0000000..ea92f3c --- /dev/null +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStamp.java @@ -0,0 +1,46 @@ +/** + * 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 + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import org.apache.drill.exec.expr.DrillSimpleFunc; +import org.apache.drill.exec.expr.annotations.FunctionTemplate; +import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling; +import org.apache.drill.exec.expr.annotations.Output; +import org.apache.drill.exec.expr.annotations.Param; +import org.apache.drill.exec.expr.holders.BigIntHolder; +import org.apache.drill.exec.expr.holders.TimeStampHolder; +import org.apache.drill.exec.record.RecordBatch; + +@SuppressWarnings("unused") +@FunctionTemplate(name = "castTIMESTAMP", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls= NullHandling.NULL_IF_NULL) +public class CastBigIntTimeStamp implements DrillSimpleFunc { + + @Param + BigIntHolder in; + @Output + TimeStampHolder out; + + @Override + public void setup(RecordBatch incoming) { + } + + @Override + public void eval() { + out.value = in.value; + } +}
