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

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


      keys.add(now.getKeyCols());
    }
    // implicit type conversion hierarchy
    for (int k = 0; k < keyLength; k++) {
      // Find the common class for type conversion
      TypeInfo commonType = keys.get(0).get(k).getTypeInfo();
      for (int i = 1; i < right.length; i++) {
        TypeInfo a = commonType;
        TypeInfo b = keys.get(i).get(k).getTypeInfo();
        commonType = FunctionRegistry.getCommonClassForComparison(a, b);
        if (commonType == null) {
          throw new SemanticException(
              "Cannot do equality join on different types: " + a.getTypeName()
                  + " and " + b.getTypeName());
        }
      }
      // Add implicit type conversion if necessary
      for (int i = 0; i < right.length; i++) {
        if (TypeInfoUtils.isConversionRequiredForComparison(
View Full Code Here


                + ", and on the right side of the UNION at column position: " +
                getPositionFromInternalName(rInfo.getInternalName())
                + ". Column positions should match for a UNION"));
      }
      // try widening coversion, otherwise fail union
      TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(lInfo.getType(),
          rInfo.getType());
      if (commonTypeInfo == null) {
        throw new SemanticException(generateErrorMessage(tabref,
            "Schema of both sides of union should match: Column " + field
                + " is of type " + lInfo.getType().getTypeName()
View Full Code Here

    implicit(TypeInfoFactory.timestampTypeInfo, TypeInfoFactory.decimalTypeInfo, false);
    implicit(varchar10, TypeInfoFactory.stringTypeInfo, true);
    implicit(TypeInfoFactory.stringTypeInfo, varchar10, true);

    // Try with parameterized varchar types
    TypeInfo varchar10 = TypeInfoFactory.getPrimitiveTypeInfo("varchar(10)");
    TypeInfo varchar20 = TypeInfoFactory.getPrimitiveTypeInfo("varchar(20)");

    implicit(varchar10, TypeInfoFactory.stringTypeInfo, true);
    implicit(varchar20, TypeInfoFactory.stringTypeInfo, true);
    implicit(TypeInfoFactory.stringTypeInfo, varchar10, true);
    implicit(TypeInfoFactory.stringTypeInfo, varchar20, true);
View Full Code Here

    String[] typeStrings = {
        "void", "boolean", "tinyint", "smallint", "int", "bigint", "float", "double",
        "string", "timestamp", "date", "binary", "decimal", "varchar(10)", "varchar(5)",
    };
    for (String cat1 : typeStrings) {
      TypeInfo ti1 = null;
      try {
        ti1 = TypeInfoUtils.getTypeInfoFromTypeString(cat1);
      } catch (Exception err) {
        System.out.println(err);
        System.out.println("Unable to get TypeInfo for " + cat1 + ", skipping ...");
        continue;
      }

      for (String cat2 : typeStrings) {
        TypeInfo commonClass = null;
        boolean implicitConvertable = false;
        try {
          TypeInfo ti2 = TypeInfoUtils.getTypeInfoFromTypeString(cat2);
          try {
            commonClass = FunctionRegistry.getCommonClassForComparison(ti1, ti2);
            //implicitConvertable = FunctionRegistry.implicitConvertable(ti1, ti2);
          } catch (Exception err) {
            System.out.println("Failed to get common class for " + ti1 + ", " + ti2 + ": " + err);
View Full Code Here

  @Test
  public void testOrcs() {
    String mapValueTypeStr = "struct<a:string,b:int>";
    String typeStr = "struct<a:int,b:string,c:float,d:varchar(64)"
        + ",e:map<string," + mapValueTypeStr + ">>";
    TypeInfo mapValueTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(mapValueTypeStr);
    TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeStr);
    PType<OrcStruct> ptype = Orcs.orcs(typeInfo);
   
    HiveVarchar varchar = new HiveVarchar("Hello World", 32);
    Map<Text, OrcStruct> map = new HashMap<Text, OrcStruct>();
    OrcStruct value = OrcUtils.createOrcStruct(mapValueTypeInfo, new Text("age"), new IntWritable(24));
View Full Code Here

   
    TupleN t = new TupleN(1, "John Smith", new Person("Alice", 23, Arrays.asList("666-677-9999")),
        new Pair<String, Person>("Bob", new Person("Bob", 26, Arrays.asList("999-888-1132", "000-222-9934"))));
   
    String typeStr = "struct<a:int,b:string,c:" + Person.TYPE_STR + ",d:struct<d1:string,d2:" + Person.TYPE_STR + ">>";
    TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeStr);
    String tableTypeStr = "struct<a:string,b:" + Person.TYPE_STR + ">";
    TypeInfo tableTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(tableTypeStr);
   
    OrcStruct s = OrcUtils.createOrcStruct(typeInfo, new IntWritable(1), new Text("John Smith"),
        OrcUtils.createOrcStruct(Person.TYPE_INFO, new Text("Alice"), new IntWritable(23),
            Arrays.asList(new Text("666-677-9999"))
        ),
View Full Code Here

   *
   * @param clazz
   * @return
   */
  public static final <T> PType<T> reflects(Class<T> clazz) {
    TypeInfo reflectInfo = createReflectTypeInfo(clazz);
    return Writables.derived(clazz, new ReflectInFn<T>(clazz),
        new ReflectOutFn<T>(clazz), orcs(reflectInfo));
  }
View Full Code Here

   *
   * @param ptypes
   * @return
   */
  public static final PType<TupleN> tuples(PType... ptypes) {
    TypeInfo tupleInfo = createTupleTypeInfo(ptypes);
    return derived(TupleN.class, new TupleInFn<TupleN>(TupleFactory.TUPLEN, ptypes),
        new TupleOutFn<TupleN>(ptypes), orcs(tupleInfo), ptypes);
  }
View Full Code Here

    }
   
    @Override
    public void initialize() {
      tupleOi = new TupleObjectInspector<T>(tupleFactory, ptypes);
      TypeInfo info = TypeInfoUtils.getTypeInfoFromObjectInspector(tupleOi);
      orcOi = OrcStruct.createObjectInspector(info);
    }
View Full Code Here

    }
   
    @Override
    public void initialize() {
      tupleOi = new TupleObjectInspector<T>(null, ptypes);
      TypeInfo info = TypeInfoUtils.getTypeInfoFromObjectInspector(tupleOi);
      orcOi = OrcStruct.createObjectInspector(info);
    }
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.