From a44bed88966e57415c1fa5e95acc6a638e9afcaf Mon Sep 17 00:00:00 2001 From: Ben Eddy Date: Tue, 14 Mar 2017 17:38:57 -0700 Subject: [PATCH] Revert ClassWriter aliasing ClassWriter prefixes columns with names that correspond to Java reserved words with '_'. For example, 'public' becomes '_public'. Later, when we attempt to look up the column in the Hive schema via HCatalog, the aliased column doesn't exist (assuming we've created a Hive schema that exactly mirrors the schema of the source DB). This patch coarsely removes prefixed underscores. A potential improvement would be to check that the column name indeed is a Java reserved word. --- .../org/apache/sqoop/mapreduce/hcat/SqoopHCatImportHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/org/apache/sqoop/mapreduce/hcat/SqoopHCatImportHelper.java b/src/java/org/apache/sqoop/mapreduce/hcat/SqoopHCatImportHelper.java index 878f765c..1ce29ab6 100644 --- a/src/java/org/apache/sqoop/mapreduce/hcat/SqoopHCatImportHelper.java +++ b/src/java/org/apache/sqoop/mapreduce/hcat/SqoopHCatImportHelper.java @@ -166,7 +166,7 @@ public class SqoopHCatImportHelper { for (Map.Entry entry : fieldMap.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); - String hfn = key.toLowerCase(); + String hfn = key.toLowerCase().replaceFirst("^_", ""); boolean skip = false; if (staticPartitionKeys != null && staticPartitionKeys.length > 0) { for (int i = 0; i < staticPartitionKeys.length; ++i) {