hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sansanichfb <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-703. Serialize HCatalog Complex ...
Date Mon, 09 May 2016 20:59:17 GMT
Github user sansanichfb commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/633#discussion_r62571923
  
    --- Diff: pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java
---
    @@ -102,80 +103,49 @@ public static Table getHiveTable(HiveMetaStoreClient client, Metadata.Item
itemN
          * <li>{@code decimal(precision, scale) -> numeric(precision, scale)}</li>
          * <li>{@code varchar(size) -> varchar(size)}</li>
          * <li>{@code char(size) -> bpchar(size)}</li>
    +     * <li>{@code array<dataType> -> text}</li>
    +     * <li>{@code map<keyDataType, valueDataType> -> text}</li>
    +     * <li>{@code struct<field1:dataType,...,fieldN:dataType> -> text}</li>
    +     * <li>{@code uniontype<...> -> text}</li>
          * </ul>
          *
    -     * @param hiveColumn hive column schema
    +     * @param hiveColumn
    +     *            hive column schema
          * @return field with mapped HAWQ type and modifiers
    -     * @throws UnsupportedTypeException if the column type is not supported
    +     * @throws UnsupportedTypeException
    +     *             if the column type is not supported
    +     * @see EnumHiveToHawqType
          */
         public static Metadata.Field mapHiveType(FieldSchema hiveColumn) throws UnsupportedTypeException
{
             String fieldName = hiveColumn.getName();
    -        String hiveType = hiveColumn.getType();
    -        String mappedType;
    -        String[] modifiers = null;
    +        String hiveType = hiveColumn.getType(); // Type name and modifiers if any
    +        String hiveTypeName; // Type name
    +        String[] modifiers = null; // Modifiers
    +        EnumHiveToHawqType hiveToHawqType = EnumHiveToHawqType.getHiveToHawqType(hiveType);
    +        EnumHawqType hawqType = hiveToHawqType.getHawqType();
     
    -        // check parameterized types:
    -        if (hiveType.startsWith("varchar(") ||
    -                hiveType.startsWith("char(")) {
    -            String[] toks = hiveType.split("[(,)]");
    -            if (toks.length != 2) {
    -                throw new UnsupportedTypeException( "HAWQ does not support type " + hiveType
+ " (Field " + fieldName + "), " +
    -                        "expected type of the form <type name>(<parameter>)");
    -            }
    -            mappedType = toks[0];
    -            if (mappedType.equals("char")) {
    -                mappedType = "bpchar";
    -            }
    -            modifiers = new String[] {toks[1]};
    -        } else if (hiveType.startsWith("decimal(")) {
    -            String[] toks = hiveType.split("[(,)]");
    -            if (toks.length != 3) {
    -                throw new UnsupportedTypeException( "HAWQ does not support type " + hiveType
+ " (Field " + fieldName + "), " +
    -                        "expected type of the form <type name>(<parameter>,<parameter>)");
    +        if (hiveToHawqType.getSplitExpression() != null) {
    +            String[] tokens = hiveType.split(hiveToHawqType.getSplitExpression());
    +            hiveTypeName = tokens[0];
    --- End diff --
    
    EnumHiveToHawqType stores Hive type name, corresponding Hawq type and parse expression(if
any), and there is one-to-many relation between "raw" Hive type and EnumHiveToHawqType instance.
For example, Hive "raw" types ARRAY<INT>, ARRAY<FLOAT>, ARRAY<STRING> correspond
to one enum instance EnumHiveToHawqType.ArrayType. So we cannot tie up tokens to one enum
instance on creation stage.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message