public int getCreateTime() { return tTable.getCreateTime(); }
public int getCreateTime() { return tTable.getCreateTime(); }
@Override public long getUpdateTime(Table table) throws UpdateNotFoundException { // TODO if a table/partition is registered by gobblin an update time will be made available in table properties // Use the update time instead of create time return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS); }
protected static long getCreateTime(Table table) { return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS); }
/** * Sets create time if not already set. */ private Table gettableWithCreateTime(Table table, int createTime) { if (table.isSetCreateTime() && table.getCreateTime() > 0) { return table; } Table actualtable = table.deepCopy(); actualtable.setCreateTime(createTime); return actualtable; }
private static State getTableProps(Table table) { State tableProps = new State(); for (Map.Entry<String, String> entry : table.getParameters().entrySet()) { tableProps.setProp(entry.getKey(), entry.getValue()); } if (table.isSetCreateTime()) { tableProps.setProp(HiveConstants.CREATE_TIME, table.getCreateTime()); } if (table.isSetLastAccessTime()) { tableProps.setProp(HiveConstants.LAST_ACCESS_TIME, table.getCreateTime()); } if (table.isSetOwner()) { tableProps.setProp(HiveConstants.OWNER, table.getOwner()); } if (table.isSetTableType()) { tableProps.setProp(HiveConstants.TABLE_TYPE, table.getTableType()); } if (table.isSetRetention()) { tableProps.setProp(HiveConstants.RETENTION, table.getRetention()); } return tableProps; }
hiveDataset.getTable().getCompleteName(), updateTime, hiveDataset.getTable().getTTable().getCreateTime(), lowWatermark.getValue())); HiveWorkUnit hiveWorkUnit = workUnitForTable(hiveDataset); "Not creating workunit for table %s as updateTime %s and createTime %s is not greater than low watermark %s", hiveDataset.getTable().getCompleteName(), updateTime, hiveDataset.getTable().getTTable() .getCreateTime(), lowWatermark.getValue()));
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl, boolean isOutputPadded) { formatOutput("Database:", tbl.getDbName(), tableInfo); formatOutput("Owner:", tbl.getOwner(), tableInfo); formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo); formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo); if (!tbl.isView()) { formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo); } formatOutput("Table Type:", tbl.getTableType().name(), tableInfo); if (tbl.getParameters().size() > 0) { tableInfo.append("Table Parameters:").append(LINE_DELIM); displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded); } }
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl, boolean isOutputPadded) { formatOutput("Database:", tbl.getDbName(), tableInfo); formatOutput("OwnerType:", (tbl.getOwnerType() != null) ? tbl.getOwnerType().name() : "null", tableInfo); formatOutput("Owner:", tbl.getOwner(), tableInfo); formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo); formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo); if (!tbl.isView()) { formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo); } formatOutput("Table Type:", tbl.getTableType().name(), tableInfo); if (tbl.getParameters().size() > 0) { tableInfo.append("Table Parameters:").append(LINE_DELIM); displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded); } }
@Test public void testGetWorkunitsAfterWatermark() throws Exception { String dbName = "testdb4"; String tableName1 = "testtable1"; String tableSdLoc1 = "/tmp/testtable1"; String tableName2 = "testtable2"; String tableSdLoc2 = "/tmp/testtable2"; this.hiveMetastoreTestUtils.getLocalMetastoreClient().dropDatabase(dbName, false, true, true); this.hiveMetastoreTestUtils.createTestAvroTable(dbName, tableName1, tableSdLoc1, Optional.<String> absent()); this.hiveMetastoreTestUtils.createTestAvroTable(dbName, tableName2, tableSdLoc2, Optional.<String> absent(), true); List<WorkUnitState> previousWorkUnitStates = Lists.newArrayList(); Table table1 = this.hiveMetastoreTestUtils.getLocalMetastoreClient().getTable(dbName, tableName1); previousWorkUnitStates.add(ConversionHiveTestUtils.createWus(dbName, tableName1, TimeUnit.MILLISECONDS.convert(table1.getCreateTime(), TimeUnit.SECONDS))); SourceState testState = new SourceState(getTestState(dbName), previousWorkUnitStates); testState.setProp(HiveSource.HIVE_SOURCE_WATERMARKER_FACTORY_CLASS_KEY, TableLevelWatermarker.Factory.class.getName()); List<WorkUnit> workUnits = this.hiveSource.getWorkunits(testState); Assert.assertEquals(workUnits.size(), 1); WorkUnit wu = workUnits.get(0); HiveWorkUnit hwu = new HiveWorkUnit(wu); Assert.assertEquals(hwu.getHiveDataset().getDbAndTable().getDb(), dbName); Assert.assertEquals(hwu.getHiveDataset().getDbAndTable().getTable(), tableName2); }
.getCreateTime(), tbl.getLastAccessTime(), tbl.getRetention(), convertToMFieldSchemas(tbl.getPartitionKeys()), tbl.getParameters(), tbl.getViewOriginalText(), tbl.getViewExpandedText(), tbl.isRewriteEnabled(),
/** * Convert a {@link Table} into a {@link HiveTable}. */ public static HiveTable getHiveTable(Table table) { State tableProps = getTableProps(table); State storageProps = getStorageProps(table.getSd()); State serDeProps = getSerDeProps(table.getSd().getSerdeInfo()); HiveTable hiveTable = new HiveTable.Builder().withDbName(table.getDbName()).withTableName(table.getTableName()) .withPartitionKeys(getColumns(table.getPartitionKeys())).withProps(tableProps).withStorageProps(storageProps) .withSerdeProps(serDeProps).build(); if (table.getCreateTime() > 0) { hiveTable.setCreateTime(table.getCreateTime()); } if (table.getSd().getCols() != null) { hiveTable.setColumns(getColumns(table.getSd().getCols())); } if (table.getSd().getBucketCols() != null) { hiveTable.setBucketColumns(table.getSd().getBucketCols()); } return hiveTable; }
return getCreateTime();
@Test public void testAlterTable() throws Exception { Table originalTable = testTables[2]; String originalTableName = originalTable.getTableName(); String originalDatabase = originalTable.getDbName(); Table newTable = getTableWithAllParametersSet(); newTable.setTableName(originalTableName); newTable.setDbName(originalDatabase); // Partition keys can not be set, but getTableWithAllParametersSet is added one, so remove for // this test newTable.setPartitionKeys(originalTable.getPartitionKeys()); client.alter_table(originalDatabase, originalTableName, newTable); Table alteredTable = client.getTable(originalDatabase, originalTableName); // The extra parameters will be added on server side, so check that the required ones are // present for(String key: newTable.getParameters().keySet()) { Assert.assertEquals("parameters are present", newTable.getParameters().get(key), alteredTable.getParameters().get(key)); } // The parameters are checked manually, so do not check them newTable.setParameters(alteredTable.getParameters()); // Some of the data is set on the server side, so reset those newTable.setCreateTime(alteredTable.getCreateTime()); newTable.setCreationMetadata(alteredTable.getCreationMetadata()); newTable.setWriteId(alteredTable.getWriteId()); Assert.assertTrue(alteredTable.isSetId()); alteredTable.unsetId(); Assert.assertEquals("The table data should be the same", newTable, alteredTable); }
tbl.setCreateTime(ft.getTTable().getCreateTime()); tbl.getParameters().put(hive_metastoreConstants.DDL_TIME, ft.getParameters().get(hive_metastoreConstants.DDL_TIME));
table.setCreateTime(createdTable.getCreateTime());
Assert.assertNotEquals("Comparing CreateTime", 0, createdTable.getCreateTime()); Assert.assertEquals("Comparing LastAccessTime", 0, createdTable.getLastAccessTime()); Assert.assertEquals("Comparing Retention", 0, createdTable.getRetention());
@Override public long getUpdateTime(Table table) throws UpdateNotFoundException { // TODO if a table/partition is registered by gobblin an update time will be made available in table properties // Use the update time instead of create time return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS); }
@Override public long getUpdateTime(Table table) throws UpdateNotFoundException { // TODO if a table/partition is registered by gobblin an update time will be made available in table properties // Use the update time instead of create time return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS); }
/** * Sets create time if not already set. */ private Table gettableWithCreateTime(Table table, int createTime) { if (table.isSetCreateTime() && table.getCreateTime() > 0) { return table; } Table actualtable = table.deepCopy(); actualtable.setCreateTime(createTime); return actualtable; }