Github user shivzone commented on a diff in the pull request:
https://github.com/apache/incubator-hawq/pull/895#discussion_r78205210
--- Diff:
pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/HiveInputFormatFragmenter.java
---
@@ -160,6 +166,89 @@ void verifySchema(Table tbl) throws Exception {
}
+ private void compareTypes(DataType type, String hiveType, String
fieldName) {
+ String convertedHive = toHiveType(type, fieldName, null);
+ if (!convertedHive.equals(hiveType)
+ && !(convertedHive.equals("smallint") &&
hiveType.equals("tinyint"))
+ && !hiveType.startsWith(convertedHive)) {
+ throw new UnsupportedTypeException(
+ "Schema mismatch definition: Field " + fieldName
+ + " (Hive type " + hiveType + ", HAWQ type "
+ + type.toString() + ")");
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Field " + fieldName + ": Hive type " + hiveType
+ + ", HAWQ type " + type.toString());
+ }
+ }
+
+ /**
+ * Converts HAWQ type to hive type. The supported mappings are:<ul>
+ * <li>{@code BOOLEAN -> boolean}</li>
+ * <li>{@code SMALLINT -> smallint (tinyint is converted to
smallint)}</li>
+ * <li>{@code BIGINT -> bigint}</li>
+ * <li>{@code TIMESTAMP, TIME -> timestamp}</li>
+ * <li>{@code NUMERIC -> decimal}</li>
+ * <li>{@code BYTEA -> binary}</li>
+ * <li>{@code INTERGER -> int}</li>
+ * <li>{@code TEXT -> string}</li>
+ * <li>{@code REAL -> float}</li>
+ * <li>{@code FLOAT8 -> double}</li>
+ * </ul>
+ * All other types (both in HAWQ and in HIVE) are not supported.
+ * For varchar and char types, typeMod will have the length info along
with type.
+ *
+ * @param type HAWQ data type
+ * @param name field name
+ * @return Hive type
+ * @throws UnsupportedTypeException if type is not supported
+ */
+ public static String toHiveType(DataType type, String name, String
typeMod) {
--- End diff --
Yes. Will remove this function as well. Can you make sure the mappings you
have configured are the same as here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---