/** * Setter for location. */ public HCatTable location(String location) { this.sd.setLocation(location); return this; }
/** * Setter for partition directory location. */ public HCatPartition location(String location) { this.sd.setLocation(location); return this; }
public void setDataLocation(Path path) { this.path = path; tTable.getSd().setLocation(path == null ? null : path.toString()); }
public void setLocation(String location) { tPartition.getSd().setLocation(location); }
public synchronized void increSd(StorageDescriptor sd, byte[] sdHash) { ByteArrayWrapper byteArray = new ByteArrayWrapper(sdHash); if (sdCache.containsKey(byteArray)) { sdCache.get(byteArray).refCount++; } else { StorageDescriptor sdToCache = sd.deepCopy(); sdToCache.setLocation(null); sdToCache.setParameters(null); sdCache.put(byteArray, new StorageDescriptorWrapper(sdToCache, 1)); } }
@Override public void setRootLocation(String rootLocation) throws MetaException { partitionSpec.setRootPath(rootLocation); partitionSpec.getSharedSDPartitionSpec().getSd().setLocation(rootLocation); }
@Before public void injectMocks() throws Exception { when(mockClient.getTable(DATABASE_NAME, TABLE_NAME)).thenReturn(mockTable); when(mockTable.getDbName()).thenReturn(DATABASE_NAME); when(mockTable.getTableName()).thenReturn(TABLE_NAME); when(mockTable.getPartitionKeys()).thenReturn(PARTITION_KEYS); when(mockTable.getSd()).thenReturn(tableStorageDescriptor); tableStorageDescriptor.setLocation(TABLE_LOCATION); when(mockClient.getPartition(DATABASE_NAME, TABLE_NAME, PARTITIONED_VALUES)).thenReturn(mockPartition); when(mockPartition.getSd()).thenReturn(mockPartitionStorageDescriptor); when(mockPartitionStorageDescriptor.getLocation()).thenReturn(PARTITION_LOCATION); helper = new MetaStorePartitionHelper(mockClient, DATABASE_NAME, TABLE_NAME, TABLE_PATH); }
protected Table getDummyTable() throws SemanticException { Path dummyPath = createDummyFile(); Table desc = new Table(DUMMY_DATABASE, DUMMY_TABLE); desc.getTTable().getSd().setLocation(dummyPath.toString()); desc.getTTable().getSd().getSerdeInfo().setSerializationLib(NullStructSerDe.class.getName()); desc.setInputFormatClass(NullRowsInputFormat.class); desc.setOutputFormatClass(HiveIgnoreKeyTextOutputFormat.class); return desc; }
public TableBuilder name(String name) { sd.setLocation(database.getLocationUri() + Path.SEPARATOR + name); table.setTableName(name); serDeInfo.setName(name); return this; }
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)); } } }
@Test(expected = MetaException.class) public void testAddPartitionSpecWithSharedSDInvalidSD() throws Exception { Table table = createTable(); PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0); partition.setRelativePath("year2002"); StorageDescriptor sd = new StorageDescriptor(); sd.setLocation(table.getSd().getLocation() + "/nullLocationTest/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), sd); client.add_partitions_pspec(partitionSpecProxy); }
private static void makeTestChangesOnPartition(Partition partition) { partition.getParameters().put("hmsTestParam001", "testValue001"); partition.setCreateTime(NEW_CREATE_TIME); partition.setLastAccessTime(NEW_CREATE_TIME); partition.getSd().setLocation(partition.getSd().getLocation()+"/hh=01"); partition.getSd().getCols().add(new FieldSchema("newcol", "string", "")); }
@Test(expected = MetaException.class) public void testAlterTableInvalidStorageDescriptorNullLocation() throws Exception { Table originalTable = testTables[0]; Table newTable = originalTable.deepCopy(); newTable.getSd().setLocation(null); client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable); }
@Test public void testAddPartitionsForViewNullPartLocation() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.getSd().setLocation(null); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd().getLocation()); }
@Test public void testAddPartitionSpecForViewNullPartLocation() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.getSd().setLocation(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, tableName, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd().getLocation()); }
public static Table getTestTable(String dbName, String tableName) { Table table = new Table(); table.setDbName(dbName); table.setTableName(tableName); table.setTableType(TableType.EXTERNAL_TABLE.name()); StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("/tmp/test"); table.setSd(sd); return table; }
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 static Partition makePartitionObject(String dbName, String tblName, List<String> ptnVals, Table tbl, String ptnLocationSuffix) throws MetaException { Partition part4 = new Partition(); part4.setDbName(dbName); part4.setTableName(tblName); part4.setValues(ptnVals); part4.setParameters(new HashMap<>()); part4.setSd(tbl.getSd().deepCopy()); part4.getSd().setSerdeInfo(tbl.getSd().getSerdeInfo().deepCopy()); part4.getSd().setLocation(tbl.getSd().getLocation() + ptnLocationSuffix); MetaStoreServerUtils.updatePartitionStatsFast(part4, tbl, warehouse, false, false, null, true); return part4; }
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); }
private void addPartition(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<String, String>()); part.setSd(table.getSd().deepCopy()); part.getSd().setSerdeInfo(table.getSd().getSerdeInfo()); part.getSd().setLocation(table.getSd().getLocation() + location); client.add_partition(part); } }