Java Code Examples for org.apache.hadoop.hive.ql.metadata.Table#getTableName()
The following examples show how to use
org.apache.hadoop.hive.ql.metadata.Table#getTableName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveMetaStoreBridge.java From atlas with Apache License 2.0 | 6 votes |
private String getCreateTableString(Table table, String location){ String colString = ""; List<FieldSchema> colList = table.getAllCols(); if (colList != null) { for (FieldSchema col : colList) { colString += col.getName() + " " + col.getType() + ","; } if (colList.size() > 0) { colString = colString.substring(0, colString.length() - 1); colString = "(" + colString + ")"; } } String query = "create external table " + table.getTableName() + colString + " location '" + location + "'"; return query; }
Example 2
Source File: HiveMetaStoreBridge.java From incubator-atlas with Apache License 2.0 | 6 votes |
private String getCreateTableString(Table table, String location){ String colString = ""; List<FieldSchema> colList = table.getAllCols(); if ( colList != null) { for (FieldSchema col : colList) { colString += col.getName() + " " + col.getType() + ","; } if (colList.size() > 0) { colString = colString.substring(0, colString.length() - 1); colString = "(" + colString + ")"; } } String query = "create external table " + table.getTableName() + colString + " location '" + location + "'"; return query; }
Example 3
Source File: HiveMetaStoreBridge.java From incubator-atlas with Apache License 2.0 | 6 votes |
private Referenceable registerTable(Referenceable dbReference, Table table) throws AtlasHookException { try { String dbName = table.getDbName(); String tableName = table.getTableName(); LOG.info("Attempting to register table [{}]", tableName); Referenceable tableReference = getTableReference(table); LOG.info("Found result {}", tableReference); if (tableReference == null) { tableReference = createTableInstance(dbReference, table); tableReference = registerInstance(tableReference); } else { LOG.info("Table {}.{} is already registered with id {}. Updating entity.", dbName, tableName, tableReference.getId().id); tableReference = createOrUpdateTableInstance(dbReference, tableReference, table); updateInstance(tableReference); } return tableReference; } catch (Exception e) { throw new AtlasHookException("HiveMetaStoreBridge.getStorageDescQFName() failed.", e); } }
Example 4
Source File: HiveDataset.java From incubator-gobblin with Apache License 2.0 | 6 votes |
public HiveDataset(FileSystem fs, HiveMetastoreClientPool clientPool, Table table, Properties properties, Config datasetConfig) { this.fs = fs; this.clientPool = clientPool; this.table = table; this.properties = properties; this.tableRootPath = PathUtils.isGlob(this.table.getDataLocation()) ? Optional.<Path> absent() : Optional.fromNullable(this.table.getDataLocation()); this.tableIdentifier = this.table.getDbName() + "." + this.table.getTableName(); this.datasetNamePattern = Optional.fromNullable(ConfigUtils.getString(datasetConfig, DATASET_NAME_PATTERN_KEY, null)); this.dbAndTable = new DbAndTable(table.getDbName(), table.getTableName()); if (this.datasetNamePattern.isPresent()) { this.logicalDbAndTable = parseLogicalDbAndTable(this.datasetNamePattern.get(), this.dbAndTable, LOGICAL_DB_TOKEN, LOGICAL_TABLE_TOKEN); } else { this.logicalDbAndTable = this.dbAndTable; } this.datasetConfig = resolveConfig(datasetConfig, dbAndTable, logicalDbAndTable); this.metricContext = Instrumented.getMetricContext(new State(properties), HiveDataset.class, Lists.<Tag<?>> newArrayList(new Tag<>(DATABASE, table.getDbName()), new Tag<>(TABLE, table.getTableName()))); }
Example 5
Source File: AtlasHiveHookContext.java From atlas with Apache License 2.0 | 5 votes |
public String getQualifiedName(Table table) { String tableName = table.getTableName(); if (table.isTemporary()) { if (SessionState.get() != null && SessionState.get().getSessionId() != null) { tableName = tableName + TEMP_TABLE_PREFIX + SessionState.get().getSessionId(); } else { tableName = tableName + TEMP_TABLE_PREFIX + RandomStringUtils.random(10); } } return (table.getDbName() + QNAME_SEP_ENTITY_NAME + tableName + QNAME_SEP_METADATA_NAMESPACE).toLowerCase() + getMetadataNamespace(); }
Example 6
Source File: HiveMetastoreHookImpl.java From atlas with Apache License 2.0 | 4 votes |
private static boolean isTableRename(Table oldTable, Table newTable) { String oldTableName = oldTable.getTableName(); String newTableName = newTable.getTableName(); return !StringUtils.equalsIgnoreCase(oldTableName, newTableName); }
Example 7
Source File: ReplaceTableStageableTableMetadata.java From incubator-gobblin with Apache License 2.0 | 4 votes |
public ReplaceTableStageableTableMetadata(Table referenceTable) { super(referenceTable, referenceTable.getDbName(), referenceTable.getTableName(), referenceTable.getDataLocation().toString()); }