@Override public Partition exchange_partition(Map<String, String> partitionSpecs, String sourceDbName, String sourceTableName, String destDbName, String destTableName) throws TException { exchange_partitions(partitionSpecs, sourceDbName, sourceTableName, destDbName, destTableName); // Wouldn't it make more sense to return the first element of the list returned by the // previous call? return new Partition(); }
/** * Performs a deep copy on <i>other</i>. */ public DropPartitionsResult(DropPartitionsResult other) { if (other.isSetPartitions()) { List<Partition> __this__partitions = new ArrayList<Partition>(other.partitions.size()); for (Partition other_element : other.partitions) { __this__partitions.add(new Partition(other_element)); } this.partitions = __this__partitions; } }
/** * Performs a deep copy on <i>other</i>. */ public PartitionListComposingSpec(PartitionListComposingSpec other) { if (other.isSetPartitions()) { List<Partition> __this__partitions = new ArrayList<Partition>(other.partitions.size()); for (Partition other_element : other.partitions) { __this__partitions.add(new Partition(other_element)); } this.partitions = __this__partitions; } }
/** * Performs a deep copy on <i>other</i>. */ public GetPartitionsByNamesResult(GetPartitionsByNamesResult other) { if (other.isSetPartitions()) { List<Partition> __this__partitions = new ArrayList<Partition>(other.partitions.size()); for (Partition other_element : other.partitions) { __this__partitions.add(new Partition(other_element)); } this.partitions = __this__partitions; } }
@Override public Partition getPartition(String dbName, String tableName, List<String> partitionValues) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !ImmutableSet.of(TEST_PARTITION_VALUES1, TEST_PARTITION_VALUES2).contains(partitionValues)) { throw new NoSuchObjectException(); } return new Partition(null, TEST_DATABASE, TEST_TABLE, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableMap.of()); }
@Override public List<Partition> getPartitionsByNames(String dbName, String tableName, List<String> names) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !ImmutableSet.of(TEST_PARTITION1, TEST_PARTITION2).containsAll(names)) { throw new NoSuchObjectException(); } return Lists.transform(names, name -> { try { return new Partition(ImmutableList.copyOf(Warehouse.getPartValuesFromPartName(name)), TEST_DATABASE, TEST_TABLE, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableMap.of()); } catch (MetaException e) { throw new RuntimeException(e); } }); }
public Object call() { Partition ptn = new Partition(Arrays.asList(ptnVal), dbNames.get(0), tblName, 0, 0, tbl.getSd(), partParams); sharedCache.addPartitionToCache(DEFAULT_CATALOG_NAME, dbNames.get(0), tblName, ptn); return null; } };
public Object call() { Partition ptn = new Partition(Arrays.asList(ptnVal), dbNames.get(0), tblName, 0, 0, tbl.getSd(), partParams); sharedCache.addPartitionToCache(DEFAULT_CATALOG_NAME, dbNames.get(0), tblName, ptn); return null; } };
@Test(expected = InvalidOperationException.class) public void testRenamePartitionNoTable() throws Exception { client.renamePartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2018", "01", "16"), new Partition()); }
public Partition build(Configuration conf) throws MetaException { if (tableName == null) { throw new MetaException("table name must be provided"); } if (values == null) throw new MetaException("You must provide partition values"); if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf); Partition p = new Partition(values, dbName, tableName, createTime, lastAccessTime, buildSd(), partParams); p.setCatName(catName); return p; }
/** * create an empty partition. * SemanticAnalyzer code requires that an empty partition when the table is not partitioned. */ public Partition(Table tbl) throws HiveException { org.apache.hadoop.hive.metastore.api.Partition tPart = new org.apache.hadoop.hive.metastore.api.Partition(); if (!tbl.isView()) { tPart.setSd(tbl.getTTable().getSd().deepCopy()); } initialize(tbl, tPart); }
private static void populatePartitions(HiveMetaStoreClient hmsc, Table table, List<String> blurbs) throws Exception { for (int i=0; i< nDates; ++i) { for (String blurb : blurbs) { StorageDescriptor sd = new StorageDescriptor(table.getSd()); // Add partitions located in the table-directory (i.e. default). List<String> values = Arrays.asList(datePrefix + i, blurb); sd.setLocation(getPartitionPath(table, values)); hmsc.add_partition(new Partition(values, dbName, tableName, 0, 0, sd, null)); } } }
public static org.apache.hadoop.hive.metastore.api.Partition toMetastoreApiPartition(Partition partition) { org.apache.hadoop.hive.metastore.api.Partition result = new org.apache.hadoop.hive.metastore.api.Partition(); result.setDbName(partition.getDatabaseName()); result.setTableName(partition.getTableName()); result.setValues(partition.getValues()); result.setSd(makeStorageDescriptor(partition.getTableName(), partition.getColumns(), partition.getStorage())); result.setParameters(partition.getParameters()); return result; }
@Test public void testExchangePartitionYearSet() throws Exception { Map<String, String> partitionSpecs = getPartitionSpec(Lists.newArrayList("2017", "", "")); Partition exchangedPartition = client.exchange_partition(partitionSpecs, sourceTable.getDbName(), sourceTable.getTableName(), destTable.getDbName(), destTable.getTableName()); Assert.assertEquals(new Partition(), exchangedPartition); checkExchangedPartitions(sourceTable, destTable, Lists.newArrayList(partitions[0], partitions[1], partitions[2], partitions[3])); checkRemainingPartitions(sourceTable, destTable, Lists.newArrayList(partitions[4])); }
private Partition convertToPart(String catName, String dbName, String tblName, MPartition mpart) throws MetaException { if (mpart == null) { return null; } Partition p = new Partition(convertList(mpart.getValues()), dbName, tblName, mpart.getCreateTime(), mpart.getLastAccessTime(), convertToStorageDescriptor(mpart.getSd(), false), convertMap(mpart.getParameters())); p.setCatName(catName); p.setWriteId(mpart.getWriteId()); return p; }
private static Partition createPtn(Table t, List<String> pvals) { Partition ptn = new Partition(); ptn.setDbName(t.getDbName()); ptn.setTableName(t.getTableName()); ptn.setValues(pvals); return ptn; }
@Test public void isFastStatsSameWithNullPartitions() { Partition partition = new Partition(); assertFalse(MetaStoreServerUtils.isFastStatsSame(null, null)); assertFalse(MetaStoreServerUtils.isFastStatsSame(null, partition)); assertFalse(MetaStoreServerUtils.isFastStatsSame(partition, null)); }
protected Partition newPartition(Table t, String value, List<Order> sortCols) throws Exception { Partition part = new Partition(); part.addToValues(value); part.setDbName(t.getDbName()); part.setTableName(t.getTableName()); part.setSd(newStorageDescriptor(getLocation(t.getTableName(), value), sortCols)); part.setParameters(new HashMap<String, String>()); ms.add_partition(part); return part; }
private static void addPartition(IMetaStoreClient client, Table tbl , List<String> partValues) throws IOException, TException { Partition part = new Partition(); part.setDbName(tbl.getDbName()); part.setTableName(tbl.getTableName()); StorageDescriptor sd = new StorageDescriptor(tbl.getSd()); sd.setLocation(sd.getLocation() + Path.SEPARATOR + makePartPath(tbl.getPartitionKeys(), partValues)); part.setSd(sd); part.setValues(partValues); client.add_partition(part); }
private void add_partition(HiveMetaStoreClient client, Table table, List<String> vals, String location) throws TException { Partition part = new Partition(); part.setDbName(table.getDbName()); part.setTableName(table.getTableName()); part.setValues(vals); part.setParameters(new HashMap<>()); part.setSd(table.getSd().deepCopy()); part.getSd().setSerdeInfo(table.getSd().getSerdeInfo()); part.getSd().setLocation(table.getSd().getLocation() + location); client.add_partition(part); }