Repository: incubator-hawq Updated Branches: refs/heads/HAWQ-992 546e5b8c8 -> c43b07858
HAWQ-975. Added validation for other types. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/c43b0785 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/c43b0785 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/c43b0785 Branch: refs/heads/HAWQ-992 Commit: c43b07858573fe70deacce0486f28f6855dd5601 Parents: 546e5b8 Author: Oleksandr Diachenko <[email protected]> Authored: Tue Aug 30 14:21:23 2016 -0700 Committer: Oleksandr Diachenko <[email protected]> Committed: Tue Aug 30 14:21:23 2016 -0700 ---------------------------------------------------------------------- .../hive/utilities/EnumHiveToHawqType.java | 2 +- .../plugins/hive/utilities/HiveUtilities.java | 26 +++++++++++--------- .../hive/utilities/HiveUtilitiesTest.java | 6 ++--- 3 files changed, 19 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c43b0785/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/EnumHiveToHawqType.java ---------------------------------------------------------------------- diff --git a/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/EnumHiveToHawqType.java b/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/EnumHiveToHawqType.java index af7f0ef..f90f39a 100644 --- a/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/EnumHiveToHawqType.java +++ b/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/EnumHiveToHawqType.java @@ -48,7 +48,7 @@ public enum EnumHiveToHawqType { DateType("date", EnumHawqType.DateType), DecimalType("decimal", EnumHawqType.NumericType, "[(,)]"), VarcharType("varchar", EnumHawqType.VarcharType, "[(,)]"), - CharType("char", EnumHawqType.CharType, "[(,)]"), + CharType("char", EnumHawqType.BpcharType, "[(,)]"), ArrayType("array", EnumHawqType.TextType, "[<,>]"), MapType("map", EnumHawqType.TextType, "[<,>]"), StructType("struct", EnumHawqType.TextType, "[<,>]"), http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c43b0785/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java ---------------------------------------------------------------------- diff --git a/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java b/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java index d046662..b9e73b3 100644 --- a/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java +++ b/pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java @@ -296,17 +296,21 @@ public class HiveUtilities { throw new UnsupportedTypeException("Invalid definition for column " + hawqColumnName + ": modifiers are mandatory for type " + expectedHawqType.getTypeName()); switch (hawqDataType) { - case NUMERIC: - Integer[] hiveTypeModifiers = EnumHiveToHawqType.extractModifiers(hiveType); - for (int i = 0; hawqTypeMods != null && i < hawqTypeMods.length; i++) { - if (hawqTypeMods[i] < hiveTypeModifiers[i]) - throw new UnsupportedTypeException( - "Invalid definition for column " + hawqColumnName - + ": modifiers are not compatible, " - + Arrays.toString(hiveTypeModifiers) + ", " - + Arrays.toString(hawqTypeMods)); - } - break; + case NUMERIC: + case VARCHAR: + case BPCHAR: + case CHAR: + Integer[] hiveTypeModifiers = EnumHiveToHawqType + .extractModifiers(hiveType); + for (int i = 0; hawqTypeMods != null && i < hawqTypeMods.length; i++) { + if (hawqTypeMods[i] < hiveTypeModifiers[i]) + throw new UnsupportedTypeException( + "Invalid definition for column " + hawqColumnName + + ": modifiers are not compatible, " + + Arrays.toString(hiveTypeModifiers) + ", " + + Arrays.toString(hawqTypeMods)); + } + break; } if (!expectedHawqType.getDataType().equals(hawqDataType)) { http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c43b0785/pxf/pxf-hive/src/test/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilitiesTest.java ---------------------------------------------------------------------- diff --git a/pxf/pxf-hive/src/test/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilitiesTest.java b/pxf/pxf-hive/src/test/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilitiesTest.java index 92e439e..d3fffc3 100644 --- a/pxf/pxf-hive/src/test/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilitiesTest.java +++ b/pxf/pxf-hive/src/test/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilitiesTest.java @@ -56,7 +56,7 @@ public class HiveUtilitiesTest { static String[][] typesWithModifiers = { {"decimal(19,84)", "numeric", "19,84"}, {"varchar(13)", "varchar", "13"}, - {"char(40)", "char", "40"}, + {"char(40)", "bpchar", "40"}, }; static String[][] complexTypes = { @@ -110,7 +110,7 @@ public class HiveUtilitiesTest { /* * decimal -> numeric * varchar -> varchar - * char -> char + * char -> bpchar */ for (String[] line: typesWithModifiers) { String hiveType = line[0]; @@ -134,7 +134,7 @@ public class HiveUtilitiesTest { compatibleTypeName = HiveUtilities.toCompatibleHiveType(DataType.BYTEA); assertEquals(compatibleTypeName, EnumHiveToHawqType.BinaryType.getTypeName()); - compatibleTypeName = HiveUtilities.toCompatibleHiveType(DataType.CHAR); + compatibleTypeName = HiveUtilities.toCompatibleHiveType(DataType.BPCHAR); assertEquals(compatibleTypeName, EnumHiveToHawqType.CharType.getTypeName()); compatibleTypeName = HiveUtilities.toCompatibleHiveType(DataType.BIGINT);
