Search in sources :

Example 6 with Expression

use of org.apache.hadoop.hive.ql.wm.Expression in project hive by apache.

the class TestTriggersTezSessionPoolManager method testTriggerCustomReadOps.

@Test(timeout = 60000)
public void testTriggerCustomReadOps() throws Exception {
    Expression expression = ExpressionFactory.fromString("HDFS_READ_OPS > 50");
    Trigger trigger = new ExecutionTrigger("high_read_ops", expression, new Action(Action.Type.KILL_QUERY));
    setupTriggers(Lists.newArrayList(trigger));
    String query = "select sleep(t1.under_col, 5), t1.value from " + tableName + " t1 join " + tableName + " t2 on t1.under_col>=t2.under_col";
    runQueryWithTrigger(query, getConfigs(), trigger + " violated");
}
Also used : ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Action(org.apache.hadoop.hive.ql.wm.Action) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) Expression(org.apache.hadoop.hive.ql.wm.Expression) Test(org.junit.Test)

Example 7 with Expression

use of org.apache.hadoop.hive.ql.wm.Expression in project hive by apache.

the class TestTriggersTezSessionPoolManager method testTriggerCustomCreatedDynamicPartitionsUnionAll.

@Test(timeout = 60000)
public void testTriggerCustomCreatedDynamicPartitionsUnionAll() throws Exception {
    List<String> cmds = getConfigs();
    cmds.add("drop table src2");
    cmds.add("create table src2 (key int) partitioned by (value string)");
    // query will get cancelled before creating 57 partitions
    String query = "insert overwrite table src2 partition (value) " + "select temps.* from (" + "select * from " + tableName + " where under_col < 100 " + "union all " + "select * from " + tableName + " where under_col >= 100 and under_col < 200) temps";
    Expression expression = ExpressionFactory.fromString("CREATED_DYNAMIC_PARTITIONS > 70");
    Trigger trigger = new ExecutionTrigger("high_partitions", expression, new Action(Action.Type.KILL_QUERY));
    setupTriggers(Lists.newArrayList(trigger));
    runQueryWithTrigger(query, cmds, trigger + " violated");
}
Also used : ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Action(org.apache.hadoop.hive.ql.wm.Action) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) Expression(org.apache.hadoop.hive.ql.wm.Expression) Test(org.junit.Test)

Example 8 with Expression

use of org.apache.hadoop.hive.ql.wm.Expression in project hive by apache.

the class TestTriggersTezSessionPoolManager method testTriggerDagRawInputSplitsKill.

@Test(timeout = 60000)
public void testTriggerDagRawInputSplitsKill() throws Exception {
    // Map 1 - 55 splits
    // Map 3 - 55 splits
    Expression expression = ExpressionFactory.fromString("DAG_RAW_INPUT_SPLITS > 100");
    Trigger trigger = new ExecutionTrigger("highly_parallel", expression, new Action(Action.Type.KILL_QUERY));
    setupTriggers(Lists.newArrayList(trigger));
    String query = "select t1.under_col, t1.value from " + tableName + " t1 join " + tableName + " t2 on t1.under_col>=t2.under_col";
    runQueryWithTrigger(query, getConfigs(), "Query was cancelled");
}
Also used : ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Action(org.apache.hadoop.hive.ql.wm.Action) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) Expression(org.apache.hadoop.hive.ql.wm.Expression) Test(org.junit.Test)

Example 9 with Expression

use of org.apache.hadoop.hive.ql.wm.Expression in project hive by apache.

the class TestTriggersTezSessionPoolManager method testTriggerDefaultRawInputSplits.

@Test(timeout = 60000)
public void testTriggerDefaultRawInputSplits() throws Exception {
    // Map 1 - 55 splits
    // Map 3 - 55 splits
    Expression expression = ExpressionFactory.fromString("RAW_INPUT_SPLITS > 50");
    Trigger trigger = new ExecutionTrigger("highly_parallel", expression, new Action(Action.Type.KILL_QUERY));
    setupTriggers(Lists.newArrayList(trigger));
    String query = "select t1.under_col, t1.value from " + tableName + " t1 join " + tableName + " t2 on t1.under_col>=t2.under_col";
    runQueryWithTrigger(query, getConfigs(), "Query was cancelled");
}
Also used : ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Action(org.apache.hadoop.hive.ql.wm.Action) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) Expression(org.apache.hadoop.hive.ql.wm.Expression) Test(org.junit.Test)

Example 10 with Expression

use of org.apache.hadoop.hive.ql.wm.Expression in project hive by apache.

the class TestTriggersTezSessionPoolManager method testTriggerTotalTasks.

@Test(timeout = 60000)
public void testTriggerTotalTasks() throws Exception {
    Expression expression = ExpressionFactory.fromString("VERTEX_TOTAL_TASKS > 50");
    Trigger trigger = new ExecutionTrigger("highly_parallel", expression, new Action(Action.Type.KILL_QUERY));
    setupTriggers(Lists.newArrayList(trigger));
    String query = "select sleep(t1.under_col, 5), t1.value from " + tableName + " t1 join " + tableName + " t2 on t1.under_col>=t2.under_col";
    runQueryWithTrigger(query, getConfigs(), trigger + " violated");
}
Also used : ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Action(org.apache.hadoop.hive.ql.wm.Action) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) Expression(org.apache.hadoop.hive.ql.wm.Expression) Test(org.junit.Test)

Aggregations

Action (org.apache.hadoop.hive.ql.wm.Action)28 ExecutionTrigger (org.apache.hadoop.hive.ql.wm.ExecutionTrigger)28 Expression (org.apache.hadoop.hive.ql.wm.Expression)28 Trigger (org.apache.hadoop.hive.ql.wm.Trigger)28 Test (org.junit.Test)28 WMTrigger (org.apache.hadoop.hive.metastore.api.WMTrigger)24 ArrayList (java.util.ArrayList)5 WMPoolTrigger (org.apache.hadoop.hive.metastore.api.WMPoolTrigger)4