use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class SerializationTest method testNPath.
@Test
public void testNPath() throws Exception {
System.out.println("Beginning testReduceOnlyPlan");
QueryDef qDef = wshell.translate(" select origin_city_name, fl_num, year, month, day_of_month, sz, tpath " + " from npath( " + " flights_tiny " + " partition by fl_num " + " order by year, month, day_of_month, " + " 'LATE.LATE+', " + " 'LATE', arr_delay > 15, " + " 'origin_city_name, fl_num, year, month, day_of_month, size(tpath) as sz, tpath as tpath' " + " ) " + " into path='/tmp/testNPath' \n" + " serde 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' \n" + " with serdeproperties('field.delim'=',') \n" + " format 'org.apache.hadoop.mapred.TextOutputFormat'");
validateObjectSerialization(qDef, ".qdef");
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class SerializationTest method validateObjectSerialization.
public static void validateObjectSerialization(QueryDef qdef, String suffix) throws IOException, WindowingException {
File f = new File("SQW" + suffix);
FileOutputStream out = new FileOutputStream(f);
try {
SerializationUtils.serialize(out, qdef);
} finally {
if (out != null)
out.close();
}
FileInputStream in1 = new FileInputStream(f);
Object afterQDef = SerializationUtils.deserialize(in1);
if (afterQDef instanceof QueryDef) {
reconstructQueryDef((QueryDef) afterQDef, wshell.getCfg());
}
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class SerializationTest method reconstructQueryDef.
static void reconstructQueryDef(QueryDef qDef, HiveConf hiveConf) throws WindowingException {
QueryDefVisitor qdd = new QueryDefDeserializer(hiveConf);
QueryDefWalker qdw = new QueryDefWalker(qdd);
qdw.walk(qDef);
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class SerializationTest method test.
@Test
public void test() throws Exception {
System.out.println("Beginning testReduceOnlyPlan");
QueryDef qDef = wshell.translate("select p_mfgr,p_name, p_size,\n" + "rank() as r,\n" + "denserank() as dr\n" + "from part_tiny\n" + "partition by p_mfgr\n" + "order by p_mfgr\n" + "window w1 as rows between 2 preceding and 2 following\n" + "into path='/tmp/wout2'\n" + "serde 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'\n" + "with serdeproperties('field.delim'=',')\n" + "format 'org.apache.hadoop.mapred.TextOutputFormat'");
validateObjectSerialization(qDef, ".qdef");
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class InputTranslation method translate.
private static HiveTableDef translate(QueryDef qDef, HiveTableSpec spec, HiveTableDef def) throws WindowingException {
def = def == null ? new HiveTableDef() : def;
HiveMetaStoreClient hiveMSC = qDef.getTranslationInfo().getHiveMSClient();
Hive hive = qDef.getTranslationInfo().getHive();
def.setSpec(spec);
if (spec.getDbName() == null) {
spec.setDbName(hive.getCurrentDatabase());
}
try {
Table t = hiveMSC.getTable(spec.getDbName(), spec.getTableName());
qDef.getTranslationInfo().setTbl(TranslateUtils.getHiveMetaTable(hive, t.getDbName(), def.getHiveTableSpec().getTableName()));
StorageDescriptor sd = t.getSd();
def.setInputFormatClassName(sd.getInputFormat());
def.setTableSerdeClassName(sd.getSerdeInfo().getSerializationLib());
def.setTableSerdeProps(setupSerdeProps(qDef, sd));
def.setLocation(sd.getLocation());
Deserializer serde = HiveUtils.getDeserializer(qDef.getTranslationInfo().getHiveCfg(), t);
def.setOI((StructObjectInspector) serde.getObjectInspector());
def.setSerde((SerDe) serde);
} catch (WindowingException we) {
throw we;
} catch (Exception he) {
throw new WindowingException(he);
}
return def;
}
Aggregations