org.apache.hadoop.hive.metastore.api.Table.setCatName()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.hadoop.hive.metastore.api.Table.setCatName()方法的一些代码示例,展示了Table.setCatName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.setCatName()方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Table
类名称:Table
方法名:setCatName

Table.setCatName介绍

暂无

代码示例

代码示例来源:origin: apache/hive

  1. private Table createTestTbl(String dbName, String tblName, String tblOwner,
  2. List<FieldSchema> cols, List<FieldSchema> ptnCols) {
  3. String serdeLocation = "file:/tmp";
  4. Map<String, String> serdeParams = new HashMap<>();
  5. Map<String, String> tblParams = new HashMap<>();
  6. SerDeInfo serdeInfo = new SerDeInfo("serde", "seriallib", new HashMap<>());
  7. StorageDescriptor sd = new StorageDescriptor(cols, serdeLocation, "input", "output", false, 0,
  8. serdeInfo, null, null, serdeParams);
  9. sd.setStoredAsSubDirectories(false);
  10. Table tbl = new Table(tblName, dbName, tblOwner, 0, 0, 0, sd, ptnCols, tblParams, null, null,
  11. TableType.MANAGED_TABLE.toString());
  12. tbl.setCatName(DEFAULT_CATALOG_NAME);
  13. return tbl;
  14. }

代码示例来源:origin: apache/hive

  1. tbl.setCatName(defaultCat);
  2. if (primaryKeys != null) {
  3. primaryKeys.forEach(pk -> pk.setCatName(defaultCat));

代码示例来源:origin: apache/hive

  1. public void createTable(Table tbl, EnvironmentContext envContext) throws AlreadyExistsException,
  2. InvalidObjectException, MetaException, NoSuchObjectException, TException {
  3. if (!tbl.isSetCatName()) {
  4. tbl.setCatName(getDefaultCatalog(conf));
  5. }
  6. HiveMetaHook hook = getHook(tbl);
  7. if (hook != null) {
  8. hook.preCreateTable(tbl);
  9. }
  10. boolean success = false;
  11. try {
  12. // Subclasses can override this step (for example, for temporary tables)
  13. create_table_with_environment_context(tbl, envContext);
  14. if (hook != null) {
  15. hook.commitCreateTable(tbl);
  16. }
  17. success = true;
  18. }
  19. finally {
  20. if (!success && (hook != null)) {
  21. try {
  22. hook.rollbackCreateTable(tbl);
  23. } catch (Exception e){
  24. LOG.error("Create rollback failed with", e);
  25. }
  26. }
  27. }
  28. }

代码示例来源:origin: apache/hive

  1. public Table build(Configuration conf) throws MetaException {
  2. if (tableName == null) {
  3. throw new MetaException("You must set the table name");
  4. }
  5. if (ownerType == null) {
  6. ownerType = PrincipalType.USER;
  7. }
  8. if (owner == null) {
  9. try {
  10. owner = SecurityUtils.getUser();
  11. } catch (IOException e) {
  12. throw MetaStoreUtils.newMetaException(e);
  13. }
  14. }
  15. if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf);
  16. Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(),
  17. partCols, tableParams, viewOriginalText, viewExpandedText, type);
  18. if (rewriteEnabled) t.setRewriteEnabled(true);
  19. if (temporary) t.setTemporary(temporary);
  20. t.setCatName(catName);
  21. if (!mvReferencedTables.isEmpty()) {
  22. CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables);
  23. if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList);
  24. t.setCreationMetadata(cm);
  25. }
  26. return t;
  27. }

代码示例来源:origin: apache/hive

  1. newTable.setCatName(catName);

代码示例来源:origin: apache/hive

  1. try {
  2. if (!tbl.isSetCatName()) {
  3. tbl.setCatName(getDefaultCatalog(conf));

代码示例来源:origin: apache/hive

  1. new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
  2. null, null, TableType.MANAGED_TABLE.toString());
  3. tbl.setCatName(DEFAULT_CATALOG_NAME);
  4. cachedStore.createTable(tbl);

代码示例来源:origin: apache/hive

  1. new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
  2. null, null, TableType.MANAGED_TABLE.toString());
  3. tbl.setCatName(DEFAULT_CATALOG_NAME);
  4. cachedStore.createTable(tbl);

代码示例来源:origin: apache/hive

  1. private Table createPartitionedTable(String catName, String dbName, String tableName) throws Exception {
  2. try {
  3. db.dropTable(catName, dbName, tableName);
  4. Table table = new Table();
  5. table.setCatName(catName);
  6. table.setDbName(dbName);
  7. table.setTableName(tableName);
  8. FieldSchema col1 = new FieldSchema("key", "string", "");
  9. FieldSchema col2 = new FieldSchema("value", "int", "");
  10. FieldSchema col3 = new FieldSchema("city", "string", "");
  11. StorageDescriptor sd = new StorageDescriptor();
  12. sd.setSerdeInfo(new SerDeInfo());
  13. sd.setInputFormat(TextInputFormat.class.getCanonicalName());
  14. sd.setOutputFormat(HiveIgnoreKeyTextOutputFormat.class.getCanonicalName());
  15. sd.setCols(Arrays.asList(col1, col2));
  16. table.setPartitionKeys(Arrays.asList(col3));
  17. table.setSd(sd);
  18. db.createTable(table);
  19. return db.getTable(catName, dbName, tableName);
  20. } catch (Exception exception) {
  21. fail("Unable to drop and create table " + StatsUtils.getFullyQualifiedTableName(dbName, tableName) + " because "
  22. + StringUtils.stringifyException(exception));
  23. throw exception;
  24. }
  25. }

代码示例来源:origin: apache/hive

  1. private Table createPartitionedTable(String catName, String dbName, String tableName) throws Exception {
  2. try {
  3. db.dropTable(catName, dbName, tableName);
  4. Table table = new Table();
  5. table.setCatName(catName);
  6. table.setDbName(dbName);
  7. table.setTableName(tableName);
  8. FieldSchema col1 = new FieldSchema("key", "string", "");
  9. FieldSchema col2 = new FieldSchema("value", "int", "");
  10. FieldSchema col3 = new FieldSchema("city", "string", "");
  11. StorageDescriptor sd = new StorageDescriptor();
  12. sd.setSerdeInfo(new SerDeInfo());
  13. sd.setInputFormat(TextInputFormat.class.getCanonicalName());
  14. sd.setOutputFormat(HiveIgnoreKeyTextOutputFormat.class.getCanonicalName());
  15. sd.setCols(Arrays.asList(col1, col2));
  16. table.setPartitionKeys(Arrays.asList(col3));
  17. table.setSd(sd);
  18. db.createTable(table);
  19. return db.getTable(catName, dbName, tableName);
  20. } catch (Exception exception) {
  21. fail("Unable to drop and create table " + StatsUtils
  22. .getFullyQualifiedTableName(dbName, tableName) + " because " + StringUtils
  23. .stringifyException(exception));
  24. throw exception;
  25. }
  26. }

代码示例来源:origin: apache/hive

  1. t.setCatName(mtbl.getDatabase().getCatalogName());
  2. t.setWriteId(mtbl.getWriteId());
  3. return t;

代码示例来源:origin: apache/hive

  1. new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
  2. null, null, TableType.MANAGED_TABLE.toString());
  3. tbl.setCatName(DEFAULT_CATALOG_NAME);
  4. cachedStore.createTable(tbl);

代码示例来源:origin: apache/hive

  1. private TableWrapper createTableWrapper(String catName, String dbName, String tblName,
  2. Table tbl) {
  3. TableWrapper wrapper;
  4. Table tblCopy = tbl.deepCopy();
  5. tblCopy.setCatName(normalizeIdentifier(catName));
  6. tblCopy.setDbName(normalizeIdentifier(dbName));
  7. tblCopy.setTableName(normalizeIdentifier(tblName));
  8. if (tblCopy.getPartitionKeys() != null) {
  9. for (FieldSchema fs : tblCopy.getPartitionKeys()) {
  10. fs.setName(normalizeIdentifier(fs.getName()));
  11. }
  12. }
  13. if (tbl.getSd() != null) {
  14. byte[] sdHash = MetaStoreServerUtils.hashStorageDescriptor(tbl.getSd(), md);
  15. StorageDescriptor sd = tbl.getSd();
  16. increSd(sd, sdHash);
  17. tblCopy.setSd(null);
  18. wrapper = new TableWrapper(tblCopy, sdHash, sd.getLocation(), sd.getParameters());
  19. } else {
  20. wrapper = new TableWrapper(tblCopy, null, null, null);
  21. }
  22. return wrapper;
  23. }

代码示例来源:origin: apache/hive

  1. @Test(expected = InvalidOperationException.class)
  2. public void moveTablesBetweenCatalogsOnAlter() throws TException {
  3. String catName = "move_table_between_catalogs_on_alter";
  4. Catalog cat = new CatalogBuilder()
  5. .setName(catName)
  6. .setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName))
  7. .build();
  8. client.createCatalog(cat);
  9. String dbName = "a_db";
  10. // For this one don't specify a location to make sure it gets put in the catalog directory
  11. Database db = new DatabaseBuilder()
  12. .setName(dbName)
  13. .setCatalogName(catName)
  14. .create(client, metaStore.getConf());
  15. String tableName = "non_movable_table";
  16. Table before = new TableBuilder()
  17. .inDb(db)
  18. .setTableName(tableName)
  19. .addCol("col1", ColumnType.STRING_TYPE_NAME)
  20. .addCol("col2", ColumnType.INT_TYPE_NAME)
  21. .create(client, metaStore.getConf());
  22. Table after = before.deepCopy();
  23. after.setCatName(DEFAULT_CATALOG_NAME);
  24. client.alter_table(catName, dbName, tableName, after);
  25. }

代码示例来源:origin: apache/hive

  1. unsetCatName();
  2. } else {
  3. setCatName((String)value);

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

  1. public Table build(Configuration conf) throws MetaException {
  2. if (tableName == null) {
  3. throw new MetaException("You must set the table name");
  4. }
  5. if (owner == null) {
  6. try {
  7. owner = SecurityUtils.getUser();
  8. } catch (IOException e) {
  9. throw MetaStoreUtils.newMetaException(e);
  10. }
  11. }
  12. if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf);
  13. Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(),
  14. partCols, tableParams, viewOriginalText, viewExpandedText, type);
  15. if (rewriteEnabled) t.setRewriteEnabled(true);
  16. if (temporary) t.setTemporary(temporary);
  17. t.setCatName(catName);
  18. if (!mvReferencedTables.isEmpty()) {
  19. CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables);
  20. if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList);
  21. t.setCreationMetadata(cm);
  22. }
  23. return t;
  24. }

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

  1. newTable.setCatName(catName);

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

  1. try {
  2. if (!tbl.isSetCatName()) {
  3. tbl.setCatName(getDefaultCatalog(conf));

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

  1. t.setCatName(mtbl.getDatabase().getCatalogName());
  2. return t;

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

  1. unsetCatName();
  2. } else {
  3. setCatName((String)value);

相关文章

Table类方法