public String getCatalogName() { return this.tTable.getCatName(); }
public String getCatName() { return tTable.getCatName(); }
boolean sameDatabase(String catName, String dbName) { return catName.equals(t.getCatName()) && dbName.equals(t.getDbName()); }
private String getJDOFilterStrForPartitionVals(Table table, List<String> vals, Map params) throws MetaException { String partNameMatcher = MetaStoreUtils.makePartNameMatcher(table, vals, ".*"); StringBuilder queryFilter = new StringBuilder("table.database.name == dbName"); queryFilter.append(" && table.database.catalogName == catName"); queryFilter.append(" && table.tableName == tableName"); queryFilter.append(" && partitionName.matches(partialRegex)"); params.put("dbName", table.getDbName()); params.put("catName", table.getCatName()); params.put("tableName", table.getTableName()); params.put("partialRegex", partNameMatcher); return queryFilter.toString(); }
private void getNextBatch() { int batch_counter = 0; List<String> nameBatch = new ArrayList<String>(); while (batch_counter < batch_size && partitionNamesIter.hasNext()) { nameBatch.add(partitionNamesIter.next()); batch_counter++; } try { batchIter = msc.getPartitionsByNames(table.getCatName(), table.getDbName(), table.getTableName(), nameBatch).iterator(); } catch (Exception e) { throw new RuntimeException(e); } }
public T onTable(Table table) { this.catName = table.getCatName(); this.dbName = table.getDbName(); this.tableName = table.getTableName(); return child; }
private String getTableCatalog(Table table) { String catName = table.isSetCatName() ? table.getCatName() : MetaStoreUtils.getDefaultCatalog(getConf()); return catName.toLowerCase(); }
/** * Get table name in cat.db.table format. * @param table table object * @return fully qualified name. */ public static String getCatalogQualifiedTableName(Table table) { return TableName.getQualified(table.getCatName(), table.getDbName(), table.getTableName()); }
/** * Primary constructor that fetches all partitions in a given table, given * a Hive object and a table object, and a partial partition spec. */ public PartitionIterable(IMetaStoreClient msc, Table table, int batch_size) throws MetastoreException { this.currType = Type.LAZY_FETCH_PARTITIONS; this.msc = msc; this.table = table; this.batch_size = batch_size; partitionNames = getPartitionNames(msc, table.getCatName(), table.getDbName(), table.getTableName(), (short) -1); }
public static List<Partition> getAllPartitionsOf(IMetaStoreClient msc, Table table) throws MetastoreException { try { return msc.listPartitions(table.getCatName(), table.getDbName(), table.getTableName(), (short)-1); } catch (Exception e) { throw new MetastoreException(e); } }
public PartitionBuilder inTable(Table table) { this.dbName = table.getDbName(); this.tableName = table.getTableName(); this.catName = table.getCatName(); setCols(table.getSd().getCols()); return this; }
/** * Gets the partition names from a table, pruned using an expression. * @param table Table. * @param expr Expression. * @param defaultPartName Default partition name from job config, if any. * @param maxParts Maximum number of partition names to return. * @param result The resulting names. * @return Whether the result contains any unknown partitions. */ private boolean getPartitionNamesPrunedByExprNoTxn(Table table, byte[] expr, String defaultPartName, short maxParts, List<String> result) throws MetaException { result.addAll(getPartitionNamesNoTxn(table.getCatName(), table.getDbName(), table.getTableName(), maxParts)); return expressionProxy.filterPartitionsByExpr(table.getPartitionKeys(), expr, getDefaultPartitionName(defaultPartName), result); }
@Test public void testTableExistsCaseInsensitive() throws Exception { Table table = testTables[0]; // Test in upper case Assert.assertTrue("Table exists", client.tableExists(table.getCatName().toUpperCase(), table.getDbName().toUpperCase(), table.getTableName().toUpperCase())); // Test in mixed case Assert.assertTrue("Table exists", client.tableExists("hIVe", "DeFaUlt", "tEsT_TabLE")); }
private boolean getPartitionNamesPrunedByExprNoTxn(Table table, byte[] expr, String defaultPartName, short maxParts, List<String> result, SharedCache sharedCache) throws MetaException, NoSuchObjectException { List<Partition> parts = sharedCache.listCachedPartitions(StringUtils.normalizeIdentifier(table.getCatName()), StringUtils.normalizeIdentifier(table.getDbName()), StringUtils.normalizeIdentifier(table.getTableName()), maxParts); for (Partition part : parts) { result.add(Warehouse.makePartName(table.getPartitionKeys(), part.getValues())); } if (defaultPartName == null || defaultPartName.isEmpty()) { defaultPartName = MetastoreConf.getVar(getConf(), ConfVars.DEFAULTPARTITIONNAME); } return expressionProxy.filterPartitionsByExpr(table.getPartitionKeys(), expr, defaultPartName, result); }
@Test public void testGetTableCaseInsensitive() throws Exception { Table table = testTables[0]; // Test in upper case Table resultUpper = client.getTable(table.getCatName().toUpperCase(), table.getDbName().toUpperCase(), table.getTableName().toUpperCase()); Assert.assertEquals("Comparing tables", table, resultUpper); // Test in mixed case Table resultMix = client.getTable("hIvE", "DeFaUlt", "tEsT_TabLE"); Assert.assertEquals("Comparing tables", table, resultMix); }
@Test public void dropNoSuchTable() throws TException { try { client.dropConstraint(testTables[0].getCatName(), testTables[0].getDbName(), "nosuch", "mypk"); Assert.fail(); } catch (InvalidObjectException|TApplicationException e) { // NOP } }
@Test public void dropNoSuchDatabase() throws TException { try { client.dropConstraint(testTables[0].getCatName(), "nosuch", testTables[0].getTableName(), "mypk"); Assert.fail(); } catch (InvalidObjectException|TApplicationException e) { // NOP } }
@Test public void dropNoSuchConstraint() throws TException { try { client.dropConstraint(testTables[0].getCatName(), testTables[0].getDbName(), testTables[0].getTableName(), "nosuch"); Assert.fail(); } catch (InvalidObjectException|TApplicationException e) { // NOP } }
@Test public void testTableExists() throws Exception { // Using the second table, since a table called "test_table" exists in both databases Table table = testTables[1]; Assert.assertTrue("Table exists", client.tableExists(table.getCatName(), table.getDbName(), table.getTableName())); Assert.assertFalse("Table not exists", client.tableExists(table.getCatName(), table.getDbName(), "non_existing_table")); // No such database Assert.assertFalse("Table not exists", client.tableExists("no_such_database", table.getTableName())); // No such table in the given database Assert.assertFalse("Table not exists", client.tableExists(OTHER_DATABASE, table.getTableName())); }
@Override public void onInsert(InsertEvent insertEvent) throws MetaException { Table tableObj = insertEvent.getTableObj(); InsertMessage msg = MessageBuilder.getInstance().buildInsertMessage(tableObj, insertEvent.getPartitionObj(), insertEvent.isReplace(), new FileChksumIterator(insertEvent.getFiles(), insertEvent.getFileChecksums())); NotificationEvent event = new NotificationEvent(0, now(), EventType.INSERT.toString(), msgEncoder.getSerializer().serialize(msg)); event.setCatName(tableObj.isSetCatName() ? tableObj.getCatName() : DEFAULT_CATALOG_NAME); event.setDbName(tableObj.getDbName()); event.setTableName(tableObj.getTableName()); process(event, insertEvent); }