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

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


        getMS().alterIndex(dbname, base_table_name, index_name, newIndex);
        success = true;
      } catch (InvalidObjectException e) {
        ex = e;
        throw new InvalidOperationException(e.getMessage());
      } catch (Exception e) {
        ex = e;
        if (e instanceof MetaException) {
          throw (MetaException) e;
        } else if (e instanceof InvalidOperationException) {
View Full Code Here


          listener.onAlterTable(alterTableEvent);
        }
      } catch (NoSuchObjectException e) {
        // thrown when the table to be altered does not exist
        ex = e;
        throw new InvalidOperationException(e.getMessage());
      } catch (Exception e) {
        ex = e;
        if (e instanceof MetaException) {
          throw (MetaException) e;
        } else if (e instanceof InvalidOperationException) {
View Full Code Here

      throw metaException(e);
    }
  }

  private InvalidOperationException invalidOperationException(Exception e) {
    InvalidOperationException ex = new InvalidOperationException(e.getMessage());
    ex.initCause(e.getCause());
    return ex;
  }
View Full Code Here

      if (!areColTypesCompatible(oldCols.get(i).getType(), newCols.get(i).getType())) {
        incompatibleCols.add(newCols.get(i).getName());
      }
    }
    if (!incompatibleCols.isEmpty()) {
      throw new InvalidOperationException(
          "The following columns have types incompatible with the existing " +
          "columns in their respective positions :\n" +
          StringUtils.join(incompatibleCols, ',')
        );
    }
View Full Code Here

    }
    return new Partition(getTableFromApiTable(t),tPart);
  }

  private InvalidOperationException invalidOperationException(Exception e) {
    InvalidOperationException ex = new InvalidOperationException(e.getMessage());
    ex.initCause(e.getCause());
    return ex;
  }
View Full Code Here

      try {
        ms.openTransaction();
        db = ms.getDatabase(name);
        List<String> allTables = get_all_tables(db.getName());
        if (!cascade && !allTables.isEmpty()) {
          throw new InvalidOperationException("Database " + db.getName() + " is not empty");
        }
        Path path = new Path(db.getLocationUri()).getParent();
        if (!wh.isWritable(path)) {
          throw new MetaException("Database not dropped since " +
              path + " is not writable by " +
View Full Code Here

            if (dbname == null || dbname.isEmpty()) {
              throw new UnknownDBException("DB name is null or empty");
            }
            if (names == null)
            {
              throw new InvalidOperationException(dbname + " cannot find null tables");
            }
            List<Table> foundTables = ms.getTableObjectsByName(dbname, names);
            return foundTables;
          }
        });
View Full Code Here

          public List<String> run(RawStore ms) throws Exception {
            if (dbName == null || dbName.isEmpty()) {
              throw new UnknownDBException("DB name is null or empty");
            }
            if (filter == null) {
              throw new InvalidOperationException(filter + " cannot apply null filter");
            }
            List<String> tables = ms.listTableNamesByFilter(dbName, filter, maxTables);
            return tables;
          }
        });
View Full Code Here

            alter_partition_core(ms, db_name, tbl_name, part_vals, new_part);
            return Boolean.TRUE;
          }
        });
      } catch (InvalidObjectException e) {
        throw new InvalidOperationException(e.getMessage());
      } catch (AlreadyExistsException e) {
        throw new InvalidOperationException(e.getMessage());
      } catch (MetaException e) {
        throw e;
      } catch (TException e) {
        throw e;
      } catch (Exception e) {
View Full Code Here

          ms.alterPartition(dbname, name, new_part.getValues(), new_part);
          for (MetaStoreEventListener listener : listeners) {
            listener.onAlterPartition(new AlterPartitionEvent(oldPart, new_part, true, this));
          }
        } catch (InvalidObjectException e) {
          throw new InvalidOperationException("alter is not possible");
        } catch (NoSuchObjectException e){
          //old partition does not exist
          throw new InvalidOperationException("alter is not possible");
        }
        return;
      }
      //rename partition
      try {
        ms.openTransaction();
        try {
          oldPart = ms.getPartition(dbname, name, part_vals);
        } catch (NoSuchObjectException e) {
          // this means there is no existing partition
          throw new InvalidObjectException(
              "Unable to rename partition because old partition does not exist");
        }
        Partition check_part = null;
        try {
          check_part = ms.getPartition(dbname, name, new_part.getValues());
        } catch(NoSuchObjectException e) {
          // this means there is no existing partition
          check_part = null;
        }
        if (check_part != null) {
          throw new AlreadyExistsException("Partition already exists:" + dbname + "." + name + "." + new_part.getValues());
        }
        tbl = ms.getTable(dbname, name);
        if (tbl == null) {
          throw new InvalidObjectException(
              "Unable to rename partition because table or database do not exist");
        }
        try {
          destPath = new Path(wh.getTablePath(ms.getDatabase(dbname), name), Warehouse.makePartName(tbl.getPartitionKeys(),
            new_part.getValues()));
        } catch (NoSuchObjectException e) {
          LOG.debug(e);
          throw new InvalidOperationException(
              "Unable to change partition or table. Database " + dbname + " does not exist"
                  + " Check metastore logs for detailed stack." + e.getMessage());
        }
        if (destPath != null) {
          newPartLoc = destPath.toString();
          oldPartLoc = oldPart.getSd().getLocation();

          srcPath = new Path(oldPartLoc);

          LOG.info("srcPath:" + oldPartLoc);
          LOG.info("descPath:" + newPartLoc);
          srcFs = wh.getFs(srcPath);
          destFs = wh.getFs(destPath);
          // check that src and dest are on the same file system
          if (srcFs != destFs) {
            throw new InvalidOperationException("table new location " + destPath
                + " is on a different file system than the old location "
                + srcPath + ". This operation is not supported");
          }
          try {
            srcFs.exists(srcPath); // check that src exists and also checks
            if (newPartLoc.compareTo(oldPartLoc) != 0 && destFs.exists(destPath)) {
              throw new InvalidOperationException("New location for this table "
                  + tbl.getDbName() + "." + tbl.getTableName()
                  + " already exists : " + destPath);
            }
          } catch (IOException e) {
            Warehouse.closeFs(srcFs);
            Warehouse.closeFs(destFs);
            throw new InvalidOperationException("Unable to access new location "
                + destPath + " for partition " + tbl.getDbName() + "."
                + tbl.getTableName() + " " + new_part.getValues());
          }
          new_part.getSd().setLocation(newPartLoc);
          ms.alterPartition(dbname, name, part_vals, new_part);
        }

        success = ms.commitTransaction();
      } finally {
        if (!success) {
          ms.rollbackTransaction();
        }
        if (success && newPartLoc.compareTo(oldPartLoc) != 0) {
          //rename the data directory
          try{
            if (srcFs.exists(srcPath)) {
              //if destPath's parent path doesn't exist, we should mkdir it
              Path destParentPath = destPath.getParent();
              if (!wh.mkdirs(destParentPath)) {
                  throw new IOException("Unable to create path " + destParentPath);
              }
              srcFs.rename(srcPath, destPath);
              LOG.info("rename done!");
            }
          } catch (IOException e) {
            boolean revertMetaDataTransaction = false;
            try {
              ms.openTransaction();
              ms.alterPartition(dbname, name, new_part.getValues(), oldPart);
              revertMetaDataTransaction = ms.commitTransaction();
            } catch (Exception e1) {
              LOG.error("Reverting metadata opeation failed During HDFS operation failed", e1);
              if (!revertMetaDataTransaction) {
                ms.rollbackTransaction();
              }
            }
            throw new InvalidOperationException("Unable to access old location "
                + srcPath + " for partition " + tbl.getDbName() + "."
                + tbl.getTableName() + " " + part_vals);
          }
        }
        for (MetaStoreEventListener listener : listeners) {
View Full Code Here

TOP

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

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.