Search in sources :

Example 26 with QueryDef

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");
}
Also used : QueryDef(com.sap.hadoop.windowing.query2.definition.QueryDef) Test(org.junit.Test) LocalExecutorTest(com.sap.hadoop.windowing.testutils.LocalExecutorTest)

Example 27 with QueryDef

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());
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) QueryDef(com.sap.hadoop.windowing.query2.definition.QueryDef) FileInputStream(java.io.FileInputStream)

Example 28 with QueryDef

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);
}
Also used : QueryDefWalker(com.sap.hadoop.windowing.query2.translate.QueryDefWalker) QueryDefVisitor(com.sap.hadoop.windowing.query2.translate.QueryDefVisitor) QueryDefDeserializer(com.sap.hadoop.windowing.query2.translate.QueryDefDeserializer)

Example 29 with QueryDef

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");
}
Also used : QueryDef(com.sap.hadoop.windowing.query2.definition.QueryDef) Test(org.junit.Test) LocalExecutorTest(com.sap.hadoop.windowing.testutils.LocalExecutorTest)

Example 30 with QueryDef

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;
}
Also used : Hive(org.apache.hadoop.hive.ql.metadata.Hive) HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) Table(org.apache.hadoop.hive.metastore.api.Table) Deserializer(org.apache.hadoop.hive.serde2.Deserializer) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) WindowingException(com.sap.hadoop.windowing.WindowingException) WindowingException(com.sap.hadoop.windowing.WindowingException) HiveTableDef(com.sap.hadoop.windowing.query2.definition.HiveTableDef)

Aggregations

WindowingException (com.sap.hadoop.windowing.WindowingException)15 QueryDef (com.sap.hadoop.windowing.query2.definition.QueryDef)7 TableFuncDef (com.sap.hadoop.windowing.query2.definition.TableFuncDef)7 InputInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo)7 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)6 QueryInputDef (com.sap.hadoop.windowing.query2.definition.QueryInputDef)6 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)6 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)6 OrderColumnDef (com.sap.hadoop.windowing.query2.definition.OrderColumnDef)5 QuerySpec (com.sap.hadoop.windowing.query2.specification.QuerySpec)5 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)5 TableFunctionEvaluator (com.sap.hadoop.windowing.functions2.TableFunctionEvaluator)4 ArgDef (com.sap.hadoop.windowing.query2.definition.ArgDef)4 OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)4 LocalExecutorTest (com.sap.hadoop.windowing.testutils.LocalExecutorTest)4 Test (org.junit.Test)4 HiveQueryDef (com.sap.hadoop.windowing.query2.definition.HiveQueryDef)3 HiveTableDef (com.sap.hadoop.windowing.query2.definition.HiveTableDef)3 HiveTableSpec (com.sap.hadoop.windowing.query2.specification.HiveTableSpec)3 ArrayList (java.util.ArrayList)3