Search in sources :

Example 1 with CreateViewDesc

use of org.apache.hadoop.hive.ql.ddl.view.create.CreateViewDesc in project hive by apache.

the class ReplLoadTask method createViewTask.

public static Task<?> createViewTask(MetaData metaData, String dbNameToLoadIn, HiveConf conf, String dumpDirectory, ReplicationMetricCollector metricCollector) throws SemanticException {
    Table table = new Table(metaData.getTable());
    String dbName = dbNameToLoadIn == null ? table.getDbName() : dbNameToLoadIn;
    TableName tableName = HiveTableName.ofNullable(table.getTableName(), dbName);
    String dbDotView = tableName.getNotEmptyDbTable();
    String viewOriginalText = table.getViewOriginalText();
    String viewExpandedText = table.getViewExpandedText();
    if (!dbName.equals(table.getDbName())) {
    // TODO: If the DB name doesn't match with the metadata from dump, then need to rewrite the original and expanded
    // texts using new DB name. Currently it refers to the source database name.
    }
    CreateViewDesc desc = new CreateViewDesc(dbDotView, table.getCols(), null, table.getParameters(), table.getPartColNames(), false, false, viewOriginalText, viewExpandedText, table.getPartCols());
    desc.setReplicationSpec(metaData.getReplicationSpec());
    desc.setOwnerName(table.getOwner());
    return TaskFactory.get(new DDLWork(new HashSet<>(), new HashSet<>(), desc, true, dumpDirectory, metricCollector), conf);
}
Also used : TableName(org.apache.hadoop.hive.common.TableName) HiveTableName(org.apache.hadoop.hive.ql.parse.HiveTableName) CreateViewDesc(org.apache.hadoop.hive.ql.ddl.view.create.CreateViewDesc) LoadTable(org.apache.hadoop.hive.ql.exec.repl.bootstrap.load.table.LoadTable) Table(org.apache.hadoop.hive.ql.metadata.Table) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 TableName (org.apache.hadoop.hive.common.TableName)1 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)1 CreateViewDesc (org.apache.hadoop.hive.ql.ddl.view.create.CreateViewDesc)1 LoadTable (org.apache.hadoop.hive.ql.exec.repl.bootstrap.load.table.LoadTable)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 HiveTableName (org.apache.hadoop.hive.ql.parse.HiveTableName)1