You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by od...@apache.org on 2016/08/31 01:38:24 UTC
incubator-hawq git commit: HAWQ-992. Updated validation for text
types.
Repository: incubator-hawq
Updated Branches:
refs/heads/HAWQ-992 c43b07858 -> 8847c4713
HAWQ-992. Updated validation for text 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/8847c471
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/8847c471
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/8847c471
Branch: refs/heads/HAWQ-992
Commit: 8847c4713b4a83b423568fb48ac514d29222b19f
Parents: c43b078
Author: Oleksandr Diachenko <od...@pivotal.io>
Authored: Tue Aug 30 18:38:15 2016 -0700
Committer: Oleksandr Diachenko <od...@pivotal.io>
Committed: Tue Aug 30 18:38:15 2016 -0700
----------------------------------------------------------------------
.../org/apache/hawq/pxf/api/io/DataType.java | 9 ++++++
.../hawq/pxf/api/utilities/EnumHawqType.java | 6 ++--
.../plugins/hive/utilities/HiveUtilities.java | 32 +++++++++++---------
.../hive/utilities/HiveUtilitiesTest.java | 12 --------
4 files changed, 29 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8847c471/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/io/DataType.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/io/DataType.java b/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/io/DataType.java
index 9b8b869..af17301 100644
--- a/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/io/DataType.java
+++ b/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/io/DataType.java
@@ -31,6 +31,9 @@ import java.util.Map;
public enum DataType {
BOOLEAN(16),
BYTEA(17),
+ /**
+ * single character
+ */
CHAR(18),
BIGINT(20),
SMALLINT(21),
@@ -38,7 +41,13 @@ public enum DataType {
TEXT(25),
REAL(700),
FLOAT8(701),
+ /**
+ * char(length), blank-padded string, fixed storage length
+ */
BPCHAR(1042),
+ /**
+ * varchar(length), non-blank-padded string, variable storage length
+ */
VARCHAR(1043),
DATE(1082),
TIME(1083),
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8847c471/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/utilities/EnumHawqType.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/utilities/EnumHawqType.java b/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/utilities/EnumHawqType.java
index d9f7d28..df5c54f 100644
--- a/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/utilities/EnumHawqType.java
+++ b/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/utilities/EnumHawqType.java
@@ -51,14 +51,14 @@ public enum EnumHawqType {
Float4Type("float4", DataType.REAL),
Float8Type("float8", DataType.FLOAT8),
TextType("text", DataType.TEXT),
- VarcharType("varchar", DataType.VARCHAR, (byte) 1, true),
+ VarcharType("varchar", DataType.VARCHAR, (byte) 1, false),
ByteaType("bytea", DataType.BYTEA),
DateType("date", DataType.DATE),
TimestampType("timestamp", DataType.TIMESTAMP),
BoolType("bool", DataType.BOOLEAN),
NumericType("numeric", DataType.NUMERIC, (byte) 2, false),
- BpcharType("bpchar", DataType.BPCHAR, (byte) 1, true),
- CharType("char", DataType.CHAR, (byte) 1, false);
+ BpcharType("bpchar", DataType.BPCHAR, (byte) 1, false),
+ CharType("char", DataType.CHAR, (byte) 1, true);
private DataType dataType;
private String typeName;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8847c471/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 b9e73b3..66cfb3b 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
@@ -292,6 +292,12 @@ public class HiveUtilities {
EnumHiveToHawqType hiveToHawqType = EnumHiveToHawqType.getHiveToHawqType(hiveType);
EnumHawqType expectedHawqType = hiveToHawqType.getHawqType();
+ if (!expectedHawqType.getDataType().equals(hawqDataType)) {
+ throw new UnsupportedTypeException("Invalid definition for column " + hawqColumnName
+ + ": expected HAWQ type " + expectedHawqType.getDataType() +
+ ", actual HAWQ type " + hawqDataType);
+ }
+
if ((hawqTypeMods == null || hawqTypeMods.length == 0) && expectedHawqType.isMandatoryModifiers())
throw new UnsupportedTypeException("Invalid definition for column " + hawqColumnName + ": modifiers are mandatory for type " + expectedHawqType.getTypeName());
@@ -300,23 +306,19 @@ public class HiveUtilities {
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));
+ if (hawqTypeMods != null && hawqTypeMods.length > 0) {
+ Integer[] hiveTypeModifiers = EnumHiveToHawqType
+ .extractModifiers(hiveType);
+ for (int i = 0; i < hiveTypeModifiers.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)) {
- throw new UnsupportedTypeException("Invalid definition for column " + hawqColumnName
- + ": expected HAWQ type " + expectedHawqType.getDataType() +
- ", actual HAWQ type " + hawqDataType);
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8847c471/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 d3fffc3..8c4d6b6 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
@@ -199,18 +199,6 @@ public class HiveUtilitiesTest {
hawqModifiers = null;
HiveUtilities.validateTypeCompatible(DataType.NUMERIC, hawqModifiers, "decimal(38,18)", columnName);
- //HAWQ datatype requires modifiers but they aren't provided
- //Types aren't compatible
- try {
- hawqModifiers = new Integer[]{};
- HiveUtilities.validateTypeCompatible(DataType.VARCHAR, hawqModifiers, "varchar", columnName);
- fail("should fail with incompatible modifiers message");
- }
- catch (UnsupportedTypeException e) {
- String errorMsg = "Invalid definition for column " + columnName + ": modifiers are mandatory for type " + EnumHawqType.VarcharType.getTypeName();
- assertEquals(errorMsg, e.getMessage());
- }
-
//HAWQ has wider modifiers than Hive, types are compatible
hawqModifiers = new Integer[]{11, 3};
HiveUtilities.validateTypeCompatible(DataType.NUMERIC, hawqModifiers, "decimal(10,2)", columnName);