diff options
author | vkorukanti <venki.korukanti@gmail.com> | 2014-07-23 09:33:15 -0700 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2014-07-25 14:34:36 -0700 |
commit | 1e9930fbae8279afe3eed9e7f18392fb1a08688a (patch) | |
tree | 18bd43c2a1a82e35511afe9fae8d1662809c2459 /exec/java-exec/src/main | |
parent | 9b2eae24a1b667e7e23c1a490803565722083882 (diff) |
DRILL-1192: Hive Scalar UDFs: Add Date, TimeStamp and Decimal type support
Also following refactoring:
+ Minimize the number of variables in HiveTypes.tdd
+ Make use of Hive TypeEntries and Hive AbstractPrimitiveObjectInspector to simplify Drill ObjectInspectors implementations.
Test:
+ Add Hive UDF test implementations and testcases to cover all supported types (passing data into Hive UDF and reading data returned from Hive UDF).
Diffstat (limited to 'exec/java-exec/src/main')
-rw-r--r-- | exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java index 98585c4fe..81fce5dd9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java @@ -19,6 +19,7 @@ package org.apache.drill.exec.util; import java.util.List; +import com.google.common.base.Joiner; import org.apache.commons.lang.StringUtils; import org.apache.drill.common.util.DrillStringUtils; import org.apache.drill.exec.record.MaterializedField; @@ -69,6 +70,40 @@ public class VectorUtil { } } + public static void appendVectorAccessibleContent(VectorAccessible va, StringBuilder formattedResults, + final String delimiter, boolean includeHeader) { + if (includeHeader) { + List<String> columns = Lists.newArrayList(); + for (VectorWrapper<?> vw : va) { + columns.add(vw.getValueVector().getField().getPath().getAsUnescapedPath()); + } + + formattedResults.append(Joiner.on(delimiter).join(columns)); + formattedResults.append("\n"); + } + + int rows = va.getRecordCount(); + for (int row = 0; row < rows; row++) { + List<String> rowValues = Lists.newArrayList(); + for (VectorWrapper<?> vw : va) { + Object o = vw.getValueVector().getAccessor().getObject(row); + if (o == null) { + rowValues.add("null"); + } else if (o instanceof byte[]) { + rowValues.add(new String((byte[]) o)); + } else { + rowValues.add(o.toString()); + } + } + formattedResults.append(Joiner.on(delimiter).join(rowValues)); + formattedResults.append("\n"); + } + + for (VectorWrapper<?> vw : va) { + vw.clear(); + } + } + public static void showVectorAccessibleContent(VectorAccessible va) { showVectorAccessibleContent(va, DEFAULT_COLUMN_WIDTH); } |