Search in sources :

Example 11 with WindowingException

use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.

the class Partition method append.

public void append(Writable o) throws WindowingException {
    try {
        elems.append(o);
        sz++;
    } catch (Exception e) {
        throw new WindowingException(e);
    }
}
Also used : WindowingException(com.sap.hadoop.windowing.WindowingException) WindowingException(com.sap.hadoop.windowing.WindowingException) ConcurrentModificationException(java.util.ConcurrentModificationException)

Example 12 with WindowingException

use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.

the class QueryOutputPrinter method printQueryOutput.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void printQueryOutput(QueryDef qry, HiveConf cfg) throws WindowingException {
    try {
        JobConf jCfg = new JobConf(cfg);
        SerDe outSerDe = setupOutputSerDe(qry, jCfg);
        RowSchema rSchema = getQueryOutputRowSchema(qry, jCfg);
        TableDesc tDesc = setupTableDesc(rSchema);
        tDesc.setDeserializerClass(qry.getOutput().getSerDe().getClass());
        String outputFormatClassName = qry.getOutput().getSpec().getOutputFormatClass();
        Class<? extends OutputFormat> outputFormatClass = (outputFormatClassName != null) ? (Class<? extends OutputFormat>) Class.forName(outputFormatClassName) : SequenceFileOutputFormat.class;
        // todo this is hack; check how this is done in Hive
        tDesc.setInputFileFormatClass(mapToInputFormat(outputFormatClass));
        tDesc.setProperties(qry.getOutput().getSpec().getSerDeProps());
        FetchOperator ftOp = setupFetchOperator(qry, tDesc, jCfg);
        while (true) {
            InspectableObject io = ftOp.getNextRow();
            if (io == null) {
                return;
            }
            String s = ((Text) outSerDe.serialize(io.o, io.oi)).toString();
            printOutput(s);
        }
    } catch (WindowingException we) {
        throw we;
    } catch (Exception e) {
        throw new WindowingException(e);
    }
}
Also used : SerDe(org.apache.hadoop.hive.serde2.SerDe) DelimitedJSONSerDe(org.apache.hadoop.hive.serde2.DelimitedJSONSerDe) InspectableObject(org.apache.hadoop.hive.serde2.objectinspector.InspectableObject) RowSchema(org.apache.hadoop.hive.ql.exec.RowSchema) WindowingException(com.sap.hadoop.windowing.WindowingException) Text(org.apache.hadoop.io.Text) TableDesc(org.apache.hadoop.hive.ql.plan.TableDesc) JobConf(org.apache.hadoop.mapred.JobConf) FetchOperator(org.apache.hadoop.hive.ql.exec.FetchOperator) WindowingException(com.sap.hadoop.windowing.WindowingException)

Example 13 with WindowingException

use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.

the class MRExecutor method execute.

/* 
	 * Create a MapRedWork object and an operator tree 
	 * for processing queries with table functions. 
	 * Execute the plan defined in the MapRedWork using 
	 * the Hive runtime environment. 
	 */
@Override
public void execute(QueryDef qdef, WindowingShell wShell) throws WindowingException {
    deleteQueryOutputDir(qdef);
    MapredWork mr = PlanUtils.getMapRedWork();
    try {
        createOperatorTree(qdef, mr);
        executePlan(mr, wShell.getCfg());
    } catch (SemanticException se) {
        throw new WindowingException(se);
    } catch (Exception e) {
        throw new WindowingException(e);
    }
}
Also used : MapredWork(org.apache.hadoop.hive.ql.plan.MapredWork) WindowingException(com.sap.hadoop.windowing.WindowingException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) IOException(java.io.IOException) WindowingException(com.sap.hadoop.windowing.WindowingException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Example 14 with WindowingException

use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.

the class MRExecutor method deleteQueryOutputDir.

static void deleteQueryOutputDir(QueryDef qDef) throws WindowingException {
    try {
        String outputPath = qDef.getOutput().getSpec().getPath();
        FileSystem fs = FileSystem.get(URI.create(outputPath), qDef.getTranslationInfo().getHiveCfg());
        Path p = new Path(outputPath);
        if (fs.exists(p)) {
            fs.delete(p, true);
        }
    } catch (IOException ie) {
        throw new WindowingException(ie);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) WindowingException(com.sap.hadoop.windowing.WindowingException) IOException(java.io.IOException)

Example 15 with WindowingException

use of com.sap.hadoop.windowing.WindowingException in project SQLWindowing by hbutani.

the class Translator method translate.

public QueryDef translate(QuerySpec qSpec, WindowingShell wShell) throws WindowingException {
    // clone the cfg
    HiveConf qCfg = new HiveConf(wShell.getCfg());
    QueryDef qry = new QueryDef();
    qry.setSpec(qSpec);
    QueryTranslationInfo transInfo = new QueryTranslationInfo();
    transInfo.setHiveCfg(qCfg);
    transInfo.setWshell(wShell);
    try {
        transInfo.setHive(Hive.get(qCfg));
        transInfo.setHiveMSClient(HiveUtils.getClient(qCfg));
    } catch (HiveException he) {
        throw new WindowingException(he);
    }
    qry.setTranslationInfo(transInfo);
    InputTranslation.translate(qry);
    WhereTranslation.translate(qry);
    OutputTranslation.translate(qry);
    return qry;
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) WindowingException(com.sap.hadoop.windowing.WindowingException) HiveConf(org.apache.hadoop.hive.conf.HiveConf) QueryDef(com.sap.hadoop.windowing.query2.definition.QueryDef)

Aggregations

WindowingException (com.sap.hadoop.windowing.WindowingException)62 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)18 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)11 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)10 IOException (java.io.IOException)9 SerDe (org.apache.hadoop.hive.serde2.SerDe)9 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)8 ArrayList (java.util.ArrayList)7 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)7 HiveMetaStoreClient (org.apache.hadoop.hive.metastore.HiveMetaStoreClient)6 Properties (java.util.Properties)5 Path (org.apache.hadoop.fs.Path)5 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)5 Table (org.apache.hadoop.hive.metastore.api.Table)5 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)5 Writable (org.apache.hadoop.io.Writable)5 TableFuncDef (com.sap.hadoop.windowing.query2.definition.TableFuncDef)4 HiveConf (org.apache.hadoop.hive.conf.HiveConf)4 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)4 ArgDef (com.sap.hadoop.windowing.query2.definition.ArgDef)3