use of org.apache.hadoop.hive.ql.exec.DDLTask in project hive by apache.
the class TestConditionalResolverCommonJoin method testResolvingDriverAlias.
@Test
public void testResolvingDriverAlias() throws Exception {
ConditionalResolverCommonJoin resolver = new ConditionalResolverCommonJoin();
HashMap<Path, ArrayList<String>> pathToAliases = new HashMap<>();
pathToAliases.put(new Path("path1"), new ArrayList<String>(Arrays.asList("alias1", "alias2")));
pathToAliases.put(new Path("path2"), new ArrayList<String>(Arrays.asList("alias3")));
HashMap<String, Long> aliasToKnownSize = new HashMap<String, Long>();
aliasToKnownSize.put("alias1", 1024l);
aliasToKnownSize.put("alias2", 2048l);
aliasToKnownSize.put("alias3", 4096l);
DDLTask task1 = new DDLTask();
task1.setId("alias2");
DDLTask task2 = new DDLTask();
task2.setId("alias3");
// joins alias1, alias2, alias3 (alias1 was not eligible for big pos)
// Must be deterministic order map for consistent q-test output across Java versions
HashMap<Task<? extends Serializable>, Set<String>> taskToAliases = new LinkedHashMap<Task<? extends Serializable>, Set<String>>();
taskToAliases.put(task1, new HashSet<String>(Arrays.asList("alias2")));
taskToAliases.put(task2, new HashSet<String>(Arrays.asList("alias3")));
ConditionalResolverCommonJoin.ConditionalResolverCommonJoinCtx ctx = new ConditionalResolverCommonJoin.ConditionalResolverCommonJoinCtx();
ctx.setPathToAliases(pathToAliases);
ctx.setTaskToAliases(taskToAliases);
ctx.setAliasToKnownSize(aliasToKnownSize);
HiveConf conf = new HiveConf();
conf.setLongVar(HiveConf.ConfVars.HIVESMALLTABLESFILESIZE, 4096);
// alias3 only can be selected
Task resolved = resolver.resolveMapJoinTask(ctx, conf);
Assert.assertEquals("alias3", resolved.getId());
conf.setLongVar(HiveConf.ConfVars.HIVESMALLTABLESFILESIZE, 65536);
// alias1, alias2, alias3 all can be selected but overriden by biggest one (alias3)
resolved = resolver.resolveMapJoinTask(ctx, conf);
Assert.assertEquals("alias3", resolved.getId());
conf.setLongVar(HiveConf.ConfVars.HIVESMALLTABLESFILESIZE, 2048);
// not selected
resolved = resolver.resolveMapJoinTask(ctx, conf);
Assert.assertNull(resolved);
}
use of org.apache.hadoop.hive.ql.exec.DDLTask in project hive by apache.
the class TestHiveDecimalParse method getColumnType.
private String getColumnType(String query) {
Driver driver = createDriver();
int rc = driver.compile(query);
if (rc != 0) {
return null;
}
QueryPlan plan = driver.getPlan();
DDLTask task = (DDLTask) plan.getRootTasks().get(0);
DDLWork work = task.getWork();
CreateTableDesc spec = work.getCreateTblDesc();
FieldSchema fs = spec.getCols().get(0);
return fs.getType();
}
Aggregations