Search in sources :

Example 1 with AlterTableCompactDesc

use of org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc in project hive by apache.

the class AlterTableConcatenateAnalyzer method compactAcidTable.

private void compactAcidTable(TableName tableName, Map<String, String> partitionSpec) throws SemanticException {
    boolean isBlocking = !HiveConf.getBoolVar(conf, ConfVars.TRANSACTIONAL_CONCATENATE_NOBLOCK, false);
    AlterTableCompactDesc desc = new AlterTableCompactDesc(tableName, partitionSpec, "MAJOR", isBlocking, null);
    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
    setAcidDdlDesc(getTable(tableName), desc);
}
Also used : DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) AlterTableCompactDesc(org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc)

Example 2 with AlterTableCompactDesc

use of org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc in project hive by apache.

the class TestQBCompact method parseAndAnalyzeAlterTable.

private AlterTableCompactDesc parseAndAnalyzeAlterTable(String query) throws Exception {
    ParseDriver hd = new ParseDriver();
    ASTNode head = (ASTNode) hd.parse(query).getTree().getChild(0);
    BaseSemanticAnalyzer a = SemanticAnalyzerFactory.get(queryState, head);
    a.analyze(head, new Context(conf));
    List<Task<?>> roots = a.getRootTasks();
    Assert.assertEquals(1, roots.size());
    return (AlterTableCompactDesc) ((DDLWork) roots.get(0).getWork()).getDDLDesc();
}
Also used : Context(org.apache.hadoop.hive.ql.Context) Task(org.apache.hadoop.hive.ql.exec.Task) AlterTableCompactDesc(org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc)

Example 3 with AlterTableCompactDesc

use of org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc in project hive by apache.

the class TestQBCompact method testMajor.

@Test
public void testMajor() throws Exception {
    AlterTableCompactDesc desc = parseAndAnalyzeAlterTable("alter table foo partition(ds = 'today') compact 'major'");
    Assert.assertEquals("major", desc.getCompactionType());
    Assert.assertEquals("default.foo", desc.getTableName());
    Map<String, String> parts = desc.getPartitionSpec();
    Assert.assertEquals(1, parts.size());
    Assert.assertEquals("today", parts.get("ds"));
}
Also used : AlterTableCompactDesc(org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc) Test(org.junit.Test)

Example 4 with AlterTableCompactDesc

use of org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc in project hive by apache.

the class TestQBCompact method testMinor.

@Test
public void testMinor() throws Exception {
    AlterTableCompactDesc desc = parseAndAnalyzeAlterTable("alter table foo partition(ds = 'today') compact 'minor'");
    Assert.assertEquals("minor", desc.getCompactionType());
    Assert.assertEquals("default.foo", desc.getTableName());
    Map<String, String> parts = desc.getPartitionSpec();
    Assert.assertEquals(1, parts.size());
    Assert.assertEquals("today", parts.get("ds"));
}
Also used : AlterTableCompactDesc(org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc) Test(org.junit.Test)

Example 5 with AlterTableCompactDesc

use of org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc in project hive by apache.

the class TestQBCompact method testNonPartitionedTable.

@Test
public void testNonPartitionedTable() throws Exception {
    AlterTableCompactDesc desc = parseAndAnalyzeAlterTable("alter table foo compact 'major'");
    Assert.assertEquals("major", desc.getCompactionType());
    Assert.assertEquals("default.foo", desc.getTableName());
}
Also used : AlterTableCompactDesc(org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc) Test(org.junit.Test)

Aggregations

AlterTableCompactDesc (org.apache.hadoop.hive.ql.ddl.table.storage.compact.AlterTableCompactDesc)5 Test (org.junit.Test)3 Context (org.apache.hadoop.hive.ql.Context)1 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)1 Task (org.apache.hadoop.hive.ql.exec.Task)1