Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [2/4] git commit: Update VectorUtil to print out unescaped schema paths.


Copy link to this message
-
[2/4] git commit: Update VectorUtil to print out unescaped schema paths.
Update VectorUtil to print out unescaped schema paths.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/6d26f23c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/6d26f23c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/6d26f23c

Branch: refs/heads/master
Commit: 6d26f23ce0b9840b28b38a5ee4a343607811761b
Parents: 58d33c8
Author: Jacques Nadeau <[EMAIL PROTECTED]>
Authored: Mon Apr 21 09:22:32 2014 -0700
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Mon Apr 21 09:22:32 2014 -0700

 .../drill/common/expression/SchemaPath.java      | 19 +++++++++++++++++++
 .../org/apache/drill/exec/util/VectorUtil.java   |  4 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6d26f23c/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
diff --git a/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
index a3f93a3..659639a 100644
+++ b/common/src/main/java/org/apache/drill/common/expression/SchemaPath.java
@@ -152,6 +152,25 @@ public class SchemaPath extends LogicalExpressionBase {
     return ExpressionStringBuilder.toString(this);
   }
 
+  public String getAsUnescapedPath(){
+    StringBuilder sb = new StringBuilder();
+    PathSegment seg = getRootSegment();
+    if(seg.isArray()) throw new IllegalStateException("Drill doesn't currently support top level arrays");
+    sb.append(seg.getNameSegment().getPath());
+
+    while( (seg = seg.getChild()) != null){
+      if(seg.isNamed()){
+        sb.append('.');
+        sb.append(seg.getNameSegment().getPath());
+      }else{
+        sb.append('[');
+        sb.append(seg.getArraySegment().getIndex());
+        sb.append(']');
+      }
+    }
+    return sb.toString();
+  }
+
 
   public static class De extends StdDeserializer<SchemaPath> {
     DrillConfig config;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6d26f23c/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java
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 c301ccb..1942f62 100644
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/util/VectorUtil.java
@@ -36,7 +36,7 @@ public class VectorUtil {
     int rows = va.getRecordCount();
     List<String> columns = Lists.newArrayList();
     for (VectorWrapper<?> vw : va) {
-      columns.add(vw.getValueVector().getField().getAsSchemaPath().toExpr());
+      columns.add(vw.getValueVector().getField().getAsSchemaPath().getAsUnescapedPath());
     }
 
     int width = columns.size();
@@ -77,7 +77,7 @@ public class VectorUtil {
     int rows = va.getRecordCount();
     List<String> columns = Lists.newArrayList();
     for (VectorWrapper<?> vw : va) {
-      columns.add(vw.getValueVector().getField().getAsSchemaPath().toExpr());
+      columns.add(vw.getValueVector().getField().getAsSchemaPath().getAsUnescapedPath());
     }
 
     int width = columns.size() * (columnWidth + 2);