Package org.apache.hadoop.hive.serde2.typeinfo

Examples of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo


    assertEquals(st1, st2);
  }

  @Test
  public void testInspectorFromTypeInfo() throws Exception {
    TypeInfo typeInfo =
        TypeInfoUtils.getTypeInfoFromTypeString("struct<c1:boolean,c2:tinyint" +
            ",c3:smallint,c4:int,c5:bigint,c6:float,c7:double,c8:binary," +
            "c9:string,c10:struct<c1:int>,c11:map<int,int>,c12:uniontype<int>" +
            ",c13:array<timestamp>>");
    StructObjectInspector inspector = (StructObjectInspector)
View Full Code Here


    public void verify(DmdlSemantics environment, ModelDeclaration declaration, AstAttribute attribute) {
        for (PropertyDeclaration property : declaration.getDeclaredProperties()) {
            if (HiveFieldTrait.get(property).isColumnPresent() == false) {
                continue;
            }
            TypeInfo typeInfo = HiveFieldTrait.getTypeInfo(property);
            if ((typeInfo instanceof PrimitiveTypeInfo) == false) {
                environment.report(new Diagnostic(Diagnostic.Level.ERROR,
                        property.getOriginalAst(),
                        Messages.getString("OrcFileDriver.diagnosticUnsupportedPropertyType"), //$NON-NLS-1$
                        typeInfo.getQualifiedName(),
                        property.getName().identifier,
                        property.getType()));
            }
        }
    }
View Full Code Here

        }
        if (model.getTrait(HiveDataModelTrait.class) == null) {
            return Collections.emptyList();
        }
        String name = HiveFieldTrait.getColumnName(property);
        TypeInfo type = HiveFieldTrait.getTypeInfo(property);
        boolean present = HiveFieldTrait.get(property).isColumnPresent();
        ModelFactory f = context.getModelFactory();
        return new AttributeBuilder(f)
            .annotation(context.resolve(HiveField.class),
                    "name", Models.toLiteral(f, name), //$NON-NLS-1$
                    "type", Models.toLiteral(f, type.getQualifiedName()), //$NON-NLS-1$
                    "ignore", Models.toLiteral(f, present == false)) //$NON-NLS-1$
            .toAnnotations();
    }
View Full Code Here

        for (PropertyDeclaration property : declaration.getDeclaredProperties()) {
            if (HiveFieldTrait.get(property).isColumnPresent() == false) {
                continue;
            }
            Class<?> valueClass = EmitContext.getFieldTypeAsClass(property);
            TypeInfo typeInfo = HiveFieldTrait.getTypeInfo(property);
            ParquetValueDriver driver = ParquetValueDrivers.find(typeInfo, valueClass);
            if (driver == null) {
                environment.report(new Diagnostic(Diagnostic.Level.ERROR,
                        property.getOriginalAst(),
                        Messages.getString("ParquetFileDriver.diagnosticUnsupportedPropertyType"), //$NON-NLS-1$
                        typeInfo.getQualifiedName(),
                        property.getName().identifier,
                        property.getType()));
            }
        }
    }
View Full Code Here

            + "contact:struct<phno:string,email:string>,"
            + "currently_registered_courses:array<string>,"
            + "current_grades:map<string,string>,"
            + "phnos:array<struct<phno:string,type:string>>,blah:array<int>>";

        TypeInfo ti = TypeInfoUtils.getTypeInfoFromTypeString(typeString);

        HowlSchema hsch = HowlSchemaUtils.getHowlSchemaFromTypeString(typeString);
        System.out.println(ti.getTypeName());
        System.out.println(hsch.toString());
        assertEquals(ti.getTypeName(),hsch.toString());
        assertEquals(hsch.toString(),typeString);
    }
View Full Code Here

      List<ExprNodeDesc> newValueExpr = new ArrayList<ExprNodeDesc>();
      List<ExprNodeDesc> newKeyExpr = new ArrayList<ExprNodeDesc>();

      boolean first = true;
      for (int k = 0; k < columnSize; k++) {
        TypeInfo type = valueCols.get(k).getTypeInfo();
        String newColName = i + "_VALUE_" + k; // any name, it does not matter.
        newValueExpr
            .add(new ExprNodeColumnDesc(type, newColName, "" + i, false));
        if (!first) {
          colNames = colNames + ",";
View Full Code Here

     * @return HowlFieldSchema representation of FieldSchema
     * @throws HowlException
     */
    public static HowlFieldSchema getHowlFieldSchema(FieldSchema fs) throws HowlException {
        String fieldName = fs.getName();
        TypeInfo baseTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(fs.getType());
        return getHowlFieldSchema(fieldName, baseTypeInfo);
    }
View Full Code Here

      if( tableField == null ) {
        //field present in partition but not in table
        newFields.add(field);
      } else {
        //field present in both. validate type has not changed
        TypeInfo partitionType = TypeInfoUtils.getTypeInfoFromTypeString(field.getType());
        TypeInfo tableType = TypeInfoUtils.getTypeInfoFromTypeString(tableField.getType());

        if( ! partitionType.equals(tableType) ) {
          throw new HowlException(ErrorType.ERROR_SCHEMA_TYPE_MISMATCH, "Column <" + field.getName() + ">, expected <" +
              tableType.getTypeName() + ">, got <" + partitionType.getTypeName() + ">");
        }
      }
    }

    return newFields;
View Full Code Here

    List<ObjectInspector> fieldInspectors = new ArrayList<ObjectInspector>();
    List<String> fieldNames = new ArrayList<String>();

    for(HowlFieldSchema howlFieldSchema : outputSchema.getFields()) {
      TypeInfo type = TypeInfoUtils.getTypeInfoFromTypeString(howlFieldSchema.getTypeString());

      fieldNames.add(howlFieldSchema.getName());
      fieldInspectors.add(getObjectInspector(type));
    }
View Full Code Here

      // Put partial aggregation results in reduceValues
      int inputField = reduceKeys.size();

      for (Map.Entry<String, ASTNode> entry : aggregationTrees.entrySet()) {

        TypeInfo type = reduceSinkInputRowResolver.getColumnInfos().get(
            inputField).getType();
        reduceValues.add(new ExprNodeColumnDesc(type,
            getColumnInternalName(inputField), "", false));
        inputField++;
        outputValueColumnNames.add(getColumnInternalName(reduceValues.size() - 1));
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.serde2.typeinfo.TypeInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.