Package org.apache.hcatalog.common

Examples of org.apache.hcatalog.common.HCatException


        this.config = conf;
        try {
            hiveConfig = HCatUtil.getHiveConf(config);
            hmsClient = HCatUtil.getHiveClient(hiveConfig);
        } catch (MetaException exp) {
            throw new HCatException("MetaException while creating HMS client",
                exp);
        } catch (IOException exp) {
            throw new HCatException("IOException while creating HMS client",
                exp);
        }

    }
View Full Code Here


        Table oldtbl = null;
        Table newTable = null;
        try {
            oldtbl = hmsClient.getTable(checkDB(dbName), existingTblName);
        } catch (MetaException e1) {
            throw new HCatException(
                "MetaException while retrieving existing table.", e1);
        } catch (NoSuchObjectException e1) {
            throw new ObjectNotFoundException(
                "NoSuchObjectException while retrieving existing table.",
                e1);
View Full Code Here

    @Override
    public int addPartitions(List<HCatAddPartitionDesc> partInfoList)
        throws HCatException {
        int numPartitions = -1;
        if ((partInfoList == null) || (partInfoList.size() == 0)) {
            throw new HCatException("The partition list is null or empty.");
        }

        Table tbl = null;
        try {
            tbl = hmsClient.getTable(partInfoList.get(0).getDatabaseName(),
                partInfoList.get(0).getTableName());
            ArrayList<Partition> ptnList = new ArrayList<Partition>();
            for (HCatAddPartitionDesc desc : partInfoList) {
                ptnList.add(desc.toHivePartition(tbl));
            }
            numPartitions = hmsClient.add_partitions(ptnList);
        } catch (InvalidObjectException e) {
            throw new HCatException(
                "InvalidObjectException while adding partition.", e);
        } catch (AlreadyExistsException e) {
            throw new HCatException(
                "AlreadyExistsException while adding partition.", e);
        } catch (MetaException e) {
            throw new HCatException("MetaException while adding partition.", e);
        } catch (NoSuchObjectException e) {
            throw new ObjectNotFoundException("The table "
                + partInfoList.get(0).getTableName()
                + " is could not be found.", e);
        } catch (TException e) {
View Full Code Here

    public String getMessageBusTopicName(String dbName, String tableName) throws HCatException {
        try {
            return hmsClient.getTable(dbName, tableName).getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME);
        }
        catch (MetaException e) {
            throw new HCatException("MetaException while retrieving JMS Topic name.", e);
        } catch (NoSuchObjectException e) {
            throw new HCatException("Could not find DB:" + dbName + " or Table:" + tableName, e);
        } catch (TException e) {
            throw new ConnectionFailureException(
                    "TException while retrieving JMS Topic name.", e);
        }
    }
View Full Code Here

        List<String> pvals = new ArrayList<String>();
        for (FieldSchema field : hiveTable.getPartitionKeys()) {
            String val = partSpec.get(field.getName());
            if (val == null || val.length() == 0) {
                throw new HCatException("create partition: Value for key "
                    + field.getName() + " is null or empty");
            }
            pvals.add(val);
        }

        hivePtn.setValues(pvals);
        StorageDescriptor sd = new StorageDescriptor(hiveTable.getSd());
        hivePtn.setSd(sd);
        hivePtn.setParameters(hiveTable.getParameters());
        if (this.location != null) {
            hivePtn.getSd().setLocation(this.location);
        } else {
            String partName;
            try {
                partName = Warehouse.makePartName(
                    hiveTable.getPartitionKeys(), pvals);
                LOG.info("Setting partition location to :" + partName);
            } catch (MetaException e) {
                throw new HCatException("Exception while creating partition name.", e);
            }
            Path partPath = new Path(hiveTable.getSd().getLocation(), partName);
            hivePtn.getSd().setLocation(partPath.toString());
        }
        hivePtn.setCreateTime((int) (System.currentTimeMillis() / 1000));
View Full Code Here

                    sh.getSerDeClass().getName());
                newTable.putToParameters(
                    org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_STORAGE,
                    storageHandler);
            } catch (HiveException e) {
                throw new HCatException(
                    "Exception while creating instance of storage handler",
                    e);
            }
        }
        newTable.setSd(sd);
View Full Code Here

            Class<? extends HCatClient> clientClass = Class.forName(className,
                true, JavaUtils.getClassLoader()).asSubclass(
                    HCatClient.class);
            client = (HCatClient) clientClass.newInstance();
        } catch (ClassNotFoundException e) {
            throw new HCatException(
                "ClassNotFoundException while creating client class.", e);
        } catch (InstantiationException e) {
            throw new HCatException(
                "InstantiationException while creating client class.", e);
        } catch (IllegalAccessException e) {
            throw new HCatException(
                "IllegalAccessException while creating client class.", e);
        }
        if (client != null) {
            client.initialize(conf);
        }
View Full Code Here

            case HiveParser.TOK_SHOWPARTITIONS:
            case HiveParser.TOK_SHOWTABLES:
                break;

            default:
                throw new HCatException(ErrorType.ERROR_INTERNAL_EXCEPTION, "Unexpected token: " + ast.getToken());
            }

            authorizeDDL(context, rootTasks);

        } catch (HCatException e) {
View Full Code Here

                // fully-specified partition
                List<String> currentParts = client.listPartitionNames(outputInfo.getDatabaseName(),
                    outputInfo.getTableName(), partitionValues, (short) 1);

                if (currentParts.size() > 0) {
                    throw new HCatException(ErrorType.ERROR_DUPLICATE_PARTITION);
                }
            }
        } else {
            List<String> partitionValues = getPartitionValueList(
                table, outputInfo.getPartitionValues());
            // non-partitioned table

            Path tablePath = new Path(table.getTTable().getSd().getLocation());
            FileSystem fs = tablePath.getFileSystem(context.getConfiguration());

            if (fs.exists(tablePath)) {
                FileStatus[] status = fs.globStatus(new Path(tablePath, "*"), hiddenFileFilter);

                if (status.length > 0) {
                    throw new HCatException(ErrorType.ERROR_NON_EMPTY_TABLE,
                        table.getDbName() + "." + table.getTableName());
                }
            }
        }
    }
View Full Code Here

     * @throws java.io.IOException
     */
    static List<String> getPartitionValueList(Table table, Map<String, String> valueMap) throws IOException {

        if (valueMap.size() != table.getPartitionKeys().size()) {
            throw new HCatException(ErrorType.ERROR_INVALID_PARTITION_VALUES,
                "Table "
                    + table.getTableName() + " has " +
                    table.getPartitionKeys().size() + " partition keys, got " +
                    valueMap.size());
        }

        List<String> values = new ArrayList<String>();

        for (FieldSchema schema : table.getPartitionKeys()) {
            String value = valueMap.get(schema.getName().toLowerCase());

            if (value == null) {
                throw new HCatException(ErrorType.ERROR_MISSING_PARTITION_KEY,
                    "Key " + schema.getName() + " of table " + table.getTableName());
            }

            values.add(value);
        }
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.common.HCatException

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.