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

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


            }

            List<HiveObjectPrivilege> result = null;

            if (partName != null) {
              Partition part = null;
              part = get_partition_by_name(dbName, tableName, partName);
              List<MPartitionColumnPrivilege> mPartitionCols
                  = ms.listPrincipalPartitionColumnGrants(principalName,
                  principalType, dbName, tableName, partName, columnName);
              if (mPartitionCols.size() > 0) {
                result = new ArrayList<HiveObjectPrivilege>();
                for (int i = 0; i < mPartitionCols.size(); i++) {
                  MPartitionColumnPrivilege sCol = mPartitionCols.get(i);
                  HiveObjectRef objectRef = new HiveObjectRef(
                      HiveObjectType.COLUMN, dbName, tableName,
                      part == null ? null : part.getValues(), sCol
                          .getColumnName());
                  HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef,
                      sCol.getPrincipalName(), principalType,
                      new PrivilegeGrantInfo(sCol.getPrivilege(), sCol
                          .getCreateTime(), sCol.getGrantor(), PrincipalType
View Full Code Here


    assertEquals(tbl.getDbName(), tblEvent.getTable().getDbName());
    assertEquals(tbl.getSd().getLocation(), tblEvent.getTable().getSd().getLocation());

    driver.run("alter table tmptbl add partition (b='2011')");
    listSize++;
    Partition part = msc.getPartition("tmpdb", "tmptbl", "b=2011");
    assertEquals(notifyList.size(), listSize);
    AddPartitionEvent partEvent = (AddPartitionEvent)(notifyList.get(listSize-1));
    assert partEvent.getStatus();
    assertEquals(part, partEvent.getPartition());

    driver.run(String.format("alter table %s touch partition (%s)", tblName, "b='2011'"));
    listSize++;
    assertEquals(notifyList.size(), listSize);
    AlterPartitionEvent alterPartEvent = (AlterPartitionEvent)notifyList.get(listSize - 1);
    assert alterPartEvent.getStatus();
    Partition origP = msc.getPartition(dbName, tblName, "b=2011");
    assertEquals(origP.getValues(), alterPartEvent.getOldPartition().getValues());
    assertEquals(origP.getDbName(), alterPartEvent.getOldPartition().getDbName());
    assertEquals(origP.getTableName(), alterPartEvent.getOldPartition().getTableName());
    //the partition did not change,
    // so the new partition should be similar to the original partition
    assertEquals(origP.getValues(), alterPartEvent.getNewPartition().getValues());
    assertEquals(origP.getDbName(), alterPartEvent.getNewPartition().getDbName());
    assertEquals(origP.getTableName(), alterPartEvent.getNewPartition().getTableName());

    driver.run(String.format("alter table %s rename to %s", tblName, renamed));
    listSize++;
    assertEquals(notifyList.size(), listSize);
    Table renamedTable = msc.getTable(dbName, renamed);
View Full Code Here

  public void publishTest(Job job) throws Exception {
    OutputCommitter committer = new HCatOutputCommitter(job,null);
    committer.cleanupJob(job);

    Partition part = client.getPartition(dbName, tblName, Arrays.asList("p1"));
    assertNotNull(part);

    StorerInfo storer = InitializeInput.extractStorerInfo(part.getSd(),part.getParameters());
    assertEquals(storer.getInputSDClass(), "testInputClass");
    assertEquals(storer.getProperties().get("hcat.testarg"), "testArgValue");
    assertTrue(part.getSd().getLocation().indexOf("p1") != -1);
  }
View Full Code Here

  /**
   * @param partition
   * @return
   */
  private Partition deepCopy(Partition partition) {
    Partition copy = null;
    if (partition != null) {
      copy = new Partition(partition);
    }
    return copy;
  }
View Full Code Here

    private Partition append_partition_common(RawStore ms, String dbName, String tableName,
        List<String> part_vals) throws InvalidObjectException,
        AlreadyExistsException, MetaException {

      Partition part = new Partition();
      boolean success = false, madeDir = false;
      Path partLocation = null;
      try {
        ms.openTransaction();
        part.setDbName(dbName);
        part.setTableName(tableName);
        part.setValues(part_vals);

        Table tbl = ms.getTable(part.getDbName(), part.getTableName());
        if (tbl == null) {
          throw new InvalidObjectException(
              "Unable to add partition because table or database do not exist");
        }
        if (tbl.getSd().getLocation() == null) {
            throw new MetaException(
              "Cannot append a partition to a view");
        }

        part.setSd(tbl.getSd());
        partLocation = new Path(tbl.getSd().getLocation(), Warehouse
            .makePartName(tbl.getPartitionKeys(), part_vals));
        part.getSd().setLocation(partLocation.toString());

        Partition old_part = null;
        try {
          old_part = ms.getPartition(part.getDbName(), part
            .getTableName(), part.getValues());
        } catch (NoSuchObjectException e) {
          // this means there is no existing partition
View Full Code Here

    Table table2 = client.getTable("default", "junit_parted_noisd");
    assertFalse(table2.getParameters().containsKey(HCatConstants.HCAT_ISD_CLASS));
    assertTrue(table2.getSd().getInputFormat().equals(HCatConstants.HIVE_RCFILE_IF_CLASS));

    // assert that there is one partition present, and it had hcat instrumentation inserted when it was created.
    Partition ptn = client.getPartition("default", "junit_parted_noisd", Arrays.asList("42"));

    assertNotNull(ptn);
    assertTrue(ptn.getParameters().containsKey(HCatConstants.HCAT_ISD_CLASS));
    assertTrue(ptn.getSd().getInputFormat().equals(HCatConstants.HIVE_RCFILE_IF_CLASS));
    driver.run("drop table junit_unparted_noisd");
  }
View Full Code Here

    List<FieldSchema> partSchema = table.getPartitionKeys();
    assertEquals("emp_country", partSchema.get(0).getName());
    assertEquals("emp_state", partSchema.get(1).getName());

    assertEquals(1, partitions.size());
    Partition partition = partitions.get(0);
    assertEquals("in", partition.getValues().get(0));
    assertEquals("tn", partition.getValues().get(1));
    assertEquals("org.apache.hcatalog.rcfile.RCFileInputDriver",
        partition.getParameters().get(HCatConstants.HCAT_ISD_CLASS));
    assertEquals("org.apache.hcatalog.rcfile.RCFileOutputDriver",
        partition.getParameters().get(HCatConstants.HCAT_OSD_CLASS));
  }
View Full Code Here

        Table table, FileSystem fs,
        String grpName, FsPermission perms) throws IOException {

      StorageDescriptor tblSD = table.getSd();
     
      Partition partition = new Partition();
      partition.setDbName(table.getDbName());
      partition.setTableName(table.getTableName());
      partition.setSd(new StorageDescriptor(tblSD));

      List<FieldSchema> fields = new ArrayList<FieldSchema>();
      for(HCatFieldSchema fieldSchema : outputSchema.getFields()) {
        fields.add(HCatSchemaUtils.getFieldSchema(fieldSchema));
      }

      partition.getSd().setCols(fields);

      partition.setValues(getPartitionValueList(table,partKVs));

      partition.setParameters(params);

      // Sets permissions and group name on partition dirs.

      Path partPath = new Path(partLocnRoot);
      for(FieldSchema partKey : table.getPartitionKeys()){
        partPath = constructPartialPartPath(partPath, partKey.getName().toLowerCase(), partKVs);
//        LOG.info("Setting perms for "+partPath.toString());
        fs.setPermission(partPath, perms);
        try{
          fs.setOwner(partPath, null, grpName);
        } catch(AccessControlException ace){
          // log the messages before ignoring. Currently, logging is not built in Hcatalog.
//          LOG.warn(ace);
        }
      }
      if (dynamicPartitioningUsed){
        String dynamicPartitionDestination = getFinalDynamicPartitionDestination(table,partKVs);
        if (harProcessor.isEnabled()){
          harProcessor.exec(context, partition, partPath);
          partition.getSd().setLocation(
              harProcessor.getProcessedLocation(new Path(dynamicPartitionDestination)));
        }else{
          partition.getSd().setLocation(dynamicPartitionDestination);
        }
      }else{
        partition.getSd().setLocation(partPath.toString());
      }

      return partition;
    }
View Full Code Here

      List<FieldSchema> partSchema = table.getPartitionKeys();
      assertEquals("emp_country", partSchema.get(0).getName());
      assertEquals("emp_state", partSchema.get(1).getName());

      assertEquals(1, partitions.size());
      Partition partition = partitions.get(0);
      assertEquals("IN", partition.getValues().get(0));
      assertEquals("TN", partition.getValues().get(1));
      assertEquals("org.apache.hcatalog.rcfile.RCFileInputDriver",
          partition.getParameters().get(HCatConstants.HCAT_ISD_CLASS));
      assertEquals("org.apache.hcatalog.rcfile.RCFileOutputDriver",
          partition.getParameters().get(HCatConstants.HCAT_OSD_CLASS));
    } catch (Exception e) {
      System.out.println("Test failed with " + e.getMessage());
      e.printStackTrace();
      throw e;
    }
View Full Code Here

    // Subscriber can get notification of newly add partition in a
    // particular table by listening on a topic named "dbName.tableName"
    // and message selector string as "HCAT_EVENT = HCAT_ADD_PARTITION"
    if(partitionEvent.getStatus()){

      Partition partition = partitionEvent.getPartition();
      String topicName;
      try {
        topicName = partitionEvent.getHandler().get_table(
            partition.getDbName(), partition.getTableName()).getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME);
      } catch (NoSuchObjectException e) {
        throw new MetaException(e.toString());
      }
      send(partition, topicName, HCatConstants.HCAT_ADD_PARTITION_EVENT);     
    }
View Full Code Here

TOP

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

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.