Examples of MTable


Examples of org.apache.hadoop.hive.metastore.model.MTable

      mdb = this.getMDatabase(tbl.getDbName());
    } catch (NoSuchObjectException e) {
      LOG.error(StringUtils.stringifyException(e));
      throw new InvalidObjectException("Database " + tbl.getDbName() + " doesn't exsit.");
    }
    return new MTable(tbl.getTableName().toLowerCase(),
        mdb,
        convertToMStorageDescriptor(tbl.getSd()),
        tbl.getOwner(),
        tbl.getCreateTime(),
        tbl.getLastAccessTime(),
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

    boolean commited = false;
    try {
      openTransaction();
      dbName = dbName.toLowerCase();
      tableName = tableName.toLowerCase();
      MTable mtbl = this.getMTable(dbName, tableName);
      if(mtbl == null) {
        commited = commitTransaction();
        return null;
      }
      // Change the query to use part_vals instead of the name which is redundant
      String name = Warehouse.makePartName(convertToFieldSchemas(mtbl.getPartitionKeys()), part_vals);
      Query query = pm.newQuery(MPartition.class, "table.tableName == t1 && table.database.name == t2 && partitionName == t3");
      query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3");
      query.setUnique(true);
      mpart = (MPartition) query.execute(tableName.trim(), dbName.trim(), name);
      pm.retrieve(mpart);
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

 
  private MPartition convertToMPart(Partition part) throws InvalidObjectException, MetaException {
    if(part == null) {
      return null;
    }
    MTable mt = getMTable(part.getDbName(), part.getTableName());
    if(mt == null) {
      throw new InvalidObjectException("Partition doesn't have a valid table or database name");
    }
    return new MPartition(
        Warehouse.makePartName(convertToFieldSchemas(mt.getPartitionKeys()), part.getValues()),
        mt,
        part.getValues(),
        part.getCreateTime(),
        part.getLastAccessTime(),
        convertToMStorageDescriptor(part.getSd()),
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

    boolean success = false;
    try {
      openTransaction();
      name = name.toLowerCase();
      dbname = dbname.toLowerCase();
      MTable newt = this.getMTable(newTable.getDbName(), newTable.getTableName());
      if(newt != null) {
        if(!newTable.getTableName().equals(name) || !newTable.getDbName().equals(dbname)) {
          // if the old table and new table aren't the same
          throw new InvalidObjectException("new table " + newTable.getDbName() +" already exists");
        }
      }
      newt = convertToMTable(newTable);
      if(newt == null) {
        throw new InvalidObjectException("new table is invalid");
      }
     
      MTable oldt = this.getMTable(dbname, name);
      if(oldt == null) {
        throw new MetaException("table " + name + " doesn't exist");
      }
     
      // For now only alter name, owner, paramters, cols, bucketcols are allowed
      oldt.setTableName(newt.getTableName().toLowerCase());
      oldt.setParameters(newt.getParameters());
      oldt.setOwner(newt.getOwner());
      oldt.setSd(newt.getSd());
      oldt.setDatabase(newt.getDatabase());
      oldt.setRetention(newt.getRetention());
      //oldt.setPartitionKeys(newt.getPartitionKeys()); //this should never be changed for hive
     
      // commit the changes
      success = commitTransaction();
    } finally {
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

  public void createTable(Table tbl) throws InvalidObjectException, MetaException {
    boolean commited = false;
    try {
      openTransaction();
      MTable mtbl = convertToMTable(tbl);
      pm.makePersistent(mtbl);
      PrincipalPrivilegeSet principalPrivs = tbl.getPrivileges();
      List<Object> toPersistPrivObjs = new ArrayList<Object>();
      if (principalPrivs != null) {
        int now = (int)(System.currentTimeMillis()/1000);
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

  public boolean dropTable(String dbName, String tableName) throws MetaException,
    NoSuchObjectException, InvalidObjectException, InvalidInputException {
    boolean success = false;
    try {
      openTransaction();
      MTable tbl = getMTable(dbName, tableName);
      pm.retrieve(tbl);
      if (tbl != null) {
        // first remove all the grants
        List<MTablePrivilege> tabGrants = listAllTableGrants(dbName, tableName);
        if (tabGrants != null && tabGrants.size() > 0) {
          pm.deletePersistentAll(tabGrants);
        }
        List<MTableColumnPrivilege> tblColGrants = listTableAllColumnGrants(dbName,
            tableName);
        if (tblColGrants != null && tblColGrants.size() > 0) {
          pm.deletePersistentAll(tblColGrants);
        }

        List<MPartitionPrivilege> partGrants = this.listTableAllPartitionGrants(dbName, tableName);
        if (partGrants != null && partGrants.size() > 0) {
          pm.deletePersistentAll(partGrants);
        }

        List<MPartitionColumnPrivilege> partColGrants = listTableAllPartitionColumnGrants(dbName,
            tableName);
        if (partColGrants != null && partColGrants.size() > 0) {
          pm.deletePersistentAll(partColGrants);
        }
        // delete column statistics if present
        try {
          deleteTableColumnStatistics(dbName, tableName, null);
        } catch (NoSuchObjectException e) {
          LOG.info("Found no table level column statistics associated with db " + dbName +
          " table " + tableName + " record to delete");
        }

        preDropStorageDescriptor(tbl.getSd());
        // then remove the table
        pm.deletePersistentAll(tbl);
      }
      success = commitTransaction();
    } finally {
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

  public List<String> getAllTables(String dbName) throws MetaException {
    return getTables(dbName, ".*");
  }

  private MTable getMTable(String db, String table) {
    MTable mtbl = null;
    boolean commited = false;
    try {
      openTransaction();
      db = db.toLowerCase().trim();
      table = table.toLowerCase().trim();
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

        tableType = TableType.MANAGED_TABLE.toString();
      }
    }

    // A new table is always created with a new column descriptor
    return new MTable(tbl.getTableName().toLowerCase(), mdb,
        convertToMStorageDescriptor(tbl.getSd()), tbl.getOwner(), tbl
            .getCreateTime(), tbl.getLastAccessTime(), tbl.getRetention(),
        convertToMFieldSchemas(tbl.getPartitionKeys()), tbl.getParameters(),
        tbl.getViewOriginalText(), tbl.getViewExpandedText(),
        tableType);
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

  public boolean addPartition(Partition part) throws InvalidObjectException,
      MetaException {
    boolean success = false;
    boolean commited = false;
    try {
      MTable table = this.getMTable(part.getDbName(), part.getTableName());
      List<MTablePrivilege> tabGrants = null;
      List<MTableColumnPrivilege> tabColumnGrants = null;
      if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) {
        tabGrants = this.listAllTableGrants(part
            .getDbName(), part.getTableName());
        tabColumnGrants = this.listTableAllColumnGrants(
            part.getDbName(), part.getTableName());
      }
View Full Code Here

Examples of org.apache.hadoop.hive.metastore.model.MTable

    boolean commited = false;
    try {
      openTransaction();
      dbName = dbName.toLowerCase().trim();
      tableName = tableName.toLowerCase().trim();
      MTable mtbl = getMTable(dbName, tableName);
      if (mtbl == null) {
        commited = commitTransaction();
        return null;
      }
      // Change the query to use part_vals instead of the name which is
      // redundant
      String name = Warehouse.makePartName(convertToFieldSchemas(mtbl
          .getPartitionKeys()), part_vals);
      Query query = pm.newQuery(MPartition.class,
          "table.tableName == t1 && table.database.name == t2 && partitionName == t3");
      query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3");
      query.setUnique(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.