Package org.apache.hadoop.hive.metastore.api

Examples of org.apache.hadoop.hive.metastore.api.FieldSchema


  }

  private HowlSchema buildHiveSchema() throws HowlException{

    List<FieldSchema> fields = new ArrayList<FieldSchema>(8);
    fields.add(new FieldSchema("atinyint", "tinyint", ""));
    fields.add(new FieldSchema("asmallint", "smallint", ""));
    fields.add(new FieldSchema("aint", "int", ""));
    fields.add(new FieldSchema("along", "bigint", ""));
    fields.add(new FieldSchema("adouble", "double", ""));
    fields.add(new FieldSchema("astring", "string", ""));
    fields.add(new FieldSchema("anullint", "int", ""));
    fields.add(new FieldSchema("anullstring", "string", ""));

    return new HowlSchema(HowlUtil.getHowlFieldSchemaList(fields));
  }
View Full Code Here


  }

  private HowlSchema buildPrunedSchema() throws HowlException{

    List<FieldSchema> fields = new ArrayList<FieldSchema>(5);
    fields.add(new FieldSchema("atinyint", "tinyint", ""));
    fields.add(new FieldSchema("aint", "int", ""));
    fields.add(new FieldSchema("adouble", "double", ""));
    fields.add(new FieldSchema("astring", "string", ""));
    fields.add(new FieldSchema("anullint", "int", ""));

    return new HowlSchema(HowlUtil.getHowlFieldSchemaList(fields));
  }
View Full Code Here

  private HowlSchema buildReorderedSchema() throws HowlException{

    List<FieldSchema> fields = new ArrayList<FieldSchema>(7);

    fields.add(new FieldSchema("aint", "int", ""));
    fields.add(new FieldSchema("part1", "string", ""));
    fields.add(new FieldSchema("adouble", "double", ""));
    fields.add(new FieldSchema("newCol", "tinyint", ""));
    fields.add(new FieldSchema("astring", "string", ""));
    fields.add(new FieldSchema("atinyint", "tinyint", ""));
    fields.add(new FieldSchema("anullint", "int", ""));


    return new HowlSchema(HowlUtil.getHowlFieldSchemaList(fields));
  }
View Full Code Here

    } catch(Exception e) {}
    client.createDatabase(new Database(dbName, "", null,null));
    assertNotNull((client.getDatabase(dbName).getLocationUri()));

    List<FieldSchema> fields = new ArrayList<FieldSchema>();
    fields.add(new FieldSchema("colname", Constants.STRING_TYPE_NAME, ""));

    Table tbl = new Table();
    tbl.setDbName(dbName);
    tbl.setTableName(tblName);
    StorageDescriptor sd = new StorageDescriptor();
View Full Code Here

        HowlSchema outerSchema = getHowlSchemaFromTypeString("struct<"+schemaString+">");
        return outerSchema.get(0).getStructSubSchema();
    }

    public static FieldSchema getFieldSchema(HowlFieldSchema howlFieldSchema){
        return new FieldSchema(howlFieldSchema.getName(),howlFieldSchema.getTypeString(),howlFieldSchema.getComment());
    }
View Full Code Here

    Table tbl = new Table(getCurrentDatabase(), tableName);
    tbl.setInputFormatClass(fileInputFormat.getName());
    tbl.setOutputFormatClass(fileOutputFormat.getName());

    for (String col : columns) {
      FieldSchema field = new FieldSchema(col, STRING_TYPE_NAME, "default");
      tbl.getCols().add(field);
    }

    if (partCols != null) {
      for (String partCol : partCols) {
        FieldSchema part = new FieldSchema();
        part.setName(partCol);
        part.setType(STRING_TYPE_NAME); // default partition key
        tbl.getPartCols().add(part);
      }
    }
    tbl.setSerializationLib(LazySimpleSerDe.class.getName());
    tbl.setNumBuckets(bucketCount);
View Full Code Here

      List<FieldSchema> indexTblCols = new ArrayList<FieldSchema>();
      List<Order> sortCols = new ArrayList<Order>();
      storageDescriptor.setBucketCols(null);
      int k = 0;
      for (int i = 0; i < storageDescriptor.getCols().size(); i++) {
        FieldSchema col = storageDescriptor.getCols().get(i);
        if (indexedCols.contains(col.getName())) {
          indexTblCols.add(col);
          sortCols.add(new Order(col.getName(), 1));
          k++;
        }
      }
      if (k != indexedCols.size()) {
        throw new RuntimeException(
View Full Code Here

   */
  public static List<FieldSchema> getColumns(ASTNode ast, boolean lowerCase) throws SemanticException {
    List<FieldSchema> colList = new ArrayList<FieldSchema>();
    int numCh = ast.getChildCount();
    for (int i = 0; i < numCh; i++) {
      FieldSchema col = new FieldSchema();
      ASTNode child = (ASTNode) ast.getChild(i);

      String name = child.getChild(0).getText();
      if(lowerCase) {
        name = name.toLowerCase();
      }
      // child 0 is the name of the column
      col.setName(unescapeIdentifier(name));
      // child 1 is the type of the column
      ASTNode typeChild = (ASTNode) (child.getChild(1));
      col.setType(getTypeStringFromAST(typeChild));

      // child 2 is the optional comment of the column
      if (child.getChildCount() == 3) {
        col.setComment(unescapeSQLString(child.getChild(2).getText()));
      }
      colList.add(col);
    }
    return colList;
  }
View Full Code Here

    List<FieldSchema> tableCols = table.getSd().getCols();
    List<FieldSchema> newFields = new ArrayList<FieldSchema>();

    for(int i = 0;i <  partitionSchema.getFields().size();i++) {

      FieldSchema field = HowlSchemaUtils.getFieldSchema(partitionSchema.getFields().get(i));

      FieldSchema tableField;
      if( i < tableCols.size() ) {
        tableField = tableCols.get(i);

        if( ! tableField.getName().equalsIgnoreCase(field.getName())) {
          throw new HowlException(ErrorType.ERROR_SCHEMA_COLUMN_MISMATCH, "Expected column <" + tableField.getName() +
              "> at position " + (i + 1) + ", found column <" + field.getName() + ">");
        }
      } else {
        tableField = partitionKeyMap.get(field.getName().toLowerCase());

        if( tableField != null ) {
          throw new HowlException(ErrorType.ERROR_SCHEMA_PARTITION_KEY, "Key <" +  field.getName() + ">");
        }
      }

      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() + ">");
        }
View Full Code Here

    List<String> values = new ArrayList<String>();
    values.add(PARTITION_VALUE);
    tp.setValues(values);

    List<FieldSchema> partCols = new ArrayList<FieldSchema>();
    partCols.add(new FieldSchema(PARTITION_COL, "string", ""));

    Table tbl = new Table("default", TABLENAME);
    tbl.setDataLocation(new URI("tmplocation"));
    tbl.setPartCols(partCols);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.metastore.api.FieldSchema

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.