Repository: phoenix
Updated Branches:
  refs/heads/master 80a50c964 -> 2bbbcfdbe


fix for unescaping the columns


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2bbbcfdb
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2bbbcfdb
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2bbbcfdb

Branch: refs/heads/master
Commit: 2bbbcfdbe873e12e3d89a8187f9ad7837e59eddd
Parents: 55f64ea
Author: ravimagham <[email protected]>
Authored: Wed Mar 11 12:48:35 2015 -0700
Committer: ravimagham <[email protected]>
Committed: Wed Mar 11 20:41:36 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/phoenix/util/ColumnInfo.java    |  7 ++++---
 .../main/java/org/apache/phoenix/util/SchemaUtil.java    | 11 +++++++++++
 .../phoenix/pig/util/PhoenixPigSchemaUtilTest.java       |  4 ++--
 3 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2bbbcfdb/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
index 46350be..3f94b92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
@@ -56,11 +56,12 @@ public class ColumnInfo {
      * @return
      */
     public String getDisplayName() {
-        int index = columnName.indexOf(QueryConstants.NAME_SEPARATOR);
+       final String unescapedColumnName = 
SchemaUtil.getUnEscapedFullColumnName(columnName);
+        int index = unescapedColumnName.indexOf(QueryConstants.NAME_SEPARATOR);
         if (index < 0) {
-            return columnName; 
+            return unescapedColumnName; 
         }
-        return columnName.substring(index+1);
+        return unescapedColumnName.substring(index+1).trim();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2bbbcfdb/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
index 1d986c6..2a1d3ff 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
@@ -681,4 +681,15 @@ public class SchemaUtil {
         checkArgument(!isNullOrEmpty(columnName), "Column name cannot be null 
or empty");
         return columnFamilyName == null ? ("\"" + columnName + "\"") : ("\"" + 
columnFamilyName + "\"" + QueryConstants.NAME_SEPARATOR + "\"" + columnName + 
"\"");
     }
+    
+    /**
+     * Replaces all occurrences of {@link #ESCAPE_CHARACTER} with an empty 
character. 
+     * @param fullColumnName
+     * @return 
+     */
+    public static String getUnEscapedFullColumnName(String fullColumnName) {
+        checkArgument(!isNullOrEmpty(fullColumnName), "Column name cannot be 
null or empty");
+        fullColumnName = fullColumnName.replaceAll(ESCAPE_CHARACTER, "");
+               return fullColumnName.trim();
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2bbbcfdb/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
index abfb442..24d27b1 100644
--- 
a/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
+++ 
b/phoenix-pig/src/test/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtilTest.java
@@ -66,10 +66,10 @@ public class PhoenixPigSchemaUtilTest {
         
         // expected schema.
         final ResourceFieldSchema[] fields = new ResourceFieldSchema[2];
-        fields[0] = new 
ResourceFieldSchema().setName(SchemaUtil.getEscapedFullColumnName("ID"))
+        fields[0] = new ResourceFieldSchema().setName("ID")
                                                 .setType(DataType.LONG);
 
-        fields[1] = new 
ResourceFieldSchema().setName(SchemaUtil.getEscapedFullColumnName("NAME"))
+        fields[1] = new ResourceFieldSchema().setName("NAME")
                                                 .setType(DataType.CHARARRAY);
         final ResourceSchema expected = new ResourceSchema().setFields(fields);
         

Reply via email to