Search in sources :

Example 1 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class WindowingShell method execute.

protected void execute(QueryDef q, QueryOutputPrinter outP) throws WindowingException {
    QuerySpec qSpec = q.getSpec();
    try {
        executor.execute(q, this);
    } finally {
        HiveTableDef hiveTable = q.getHiveTableDef();
        if (hiveTable instanceof HiveQueryDef) {
            String tableName = hiveTable.getHiveTableSpec().getTableName();
            hiveQryExec.dropTable(tableName);
        }
    }
    if (qSpec.getOutput().getHiveTable() != null) {
        loadToOutputTable(q);
    }
    if (outP != null) {
        outP.printQueryOutput(q, cfg);
    }
}
Also used : HiveQueryDef(com.sap.hadoop.windowing.query2.definition.HiveQueryDef) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec) HiveTableDef(com.sap.hadoop.windowing.query2.definition.HiveTableDef)

Example 2 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class WindowingShell method execute.

public void execute(String query, QueryOutputPrinter outP) throws WindowingException {
    QuerySpec qSpec = parse(query);
    QueryDef q = translator.translate(qSpec, this);
    ArrayList<QueryDef> componentQueries;
    executor.beforeComponentization(q, this);
    QueryComponentizer qC = new QueryComponentizer(q, this);
    componentQueries = qC.componentize();
    executor.beforeExecute(q, componentQueries, this);
    try {
        for (QueryDef cqDef : componentQueries) {
            execute(cqDef, outP);
        }
    } finally {
        executor.afterExecute(q, componentQueries, this);
    }
}
Also used : QueryComponentizer(com.sap.hadoop.windowing.query2.translate.QueryComponentizer) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec) QueryDef(com.sap.hadoop.windowing.query2.definition.QueryDef) HiveQueryDef(com.sap.hadoop.windowing.query2.definition.HiveQueryDef)

Example 3 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec 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)

Example 4 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class WindowSpecTranslation method translateWindowSpecOnInput.

/*
	 * <ol>
	 * <li> If wSpec points to a source WindowSpec. Validate that it is valid. If it hasn't been already translated then translate it.
	 * <li> Start with an empty WdwDef or a cloned WdwDef from the source WdwDef.
	 * <li> translate the PartitionSpec if it exists. Replace the existing PDef with this; also remove the OrderDef.
	 * <li> translate the OrderSpec if it exists. Replace existing OrderDef with this.
	 * <li> add in Partition Columns if not in OrderDef already.
	 * <li> translate the WindowSpec if it exists. Replace existing WdwDef with it.
	 * <li> If name is non-null add this def to TranslationInfo::nameToWdwDef map.
	 * </ol>
	 */
static WindowDef translateWindowSpecOnInput(QueryDef qDef, WindowSpec wSpec, InputInfo iInfo, String inputDesc) throws WindowingException {
    QuerySpec qSpec = qDef.getSpec();
    WindowDef wDef;
    fillInWindowSpec(qSpec, wSpec.getSourceId(), wSpec);
    wDef = new WindowDef(wSpec);
    PartitionSpec pSpec = wSpec.getPartition();
    OrderSpec oSpec = wSpec.getOrder();
    WindowFrameSpec wFrameSpec = wSpec.getWindow();
    PartitionDef pDef = translatePartition(qDef, iInfo, pSpec);
    OrderDef oDef = translateOrder(qDef, inputDesc, iInfo, oSpec, pDef);
    WindowFrameDef wdwDef = translateWindowFrame(qDef, wFrameSpec, iInfo);
    wDef.setPartDef(pDef);
    wDef.setOrderDef(oDef);
    wDef.setWindow(wdwDef);
    return wDef;
}
Also used : OrderSpec(com.sap.hadoop.windowing.query2.specification.OrderSpec) WindowFrameDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef) WindowDef(com.sap.hadoop.windowing.query2.definition.WindowDef) PartitionDef(com.sap.hadoop.windowing.query2.definition.PartitionDef) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec) OrderDef(com.sap.hadoop.windowing.query2.definition.OrderDef) PartitionSpec(com.sap.hadoop.windowing.query2.specification.PartitionSpec) WindowFrameSpec(com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)

Example 5 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class InputTranslation method translate.

public static void translate(QueryDef qDef) throws WindowingException {
    QuerySpec spec = qDef.getSpec();
    /*
		 * validate that input chain ends in a Hive Query or TAble.
		 */
    if (!spec.getInput().sourcedFromHive()) {
        throw new WindowingException("Translation not supported for HdfsLocation based queries");
    }
    EnsureTableFunctionInQuery.execute(qDef);
    SlidePartitionAndOrderSpecs.execute(qDef);
    TranslateInputSpecs.execute(qDef);
}
Also used : WindowingException(com.sap.hadoop.windowing.WindowingException) HiveQuerySpec(com.sap.hadoop.windowing.query2.specification.HiveQuerySpec) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec)

Aggregations

QuerySpec (com.sap.hadoop.windowing.query2.specification.QuerySpec)5 WindowingException (com.sap.hadoop.windowing.WindowingException)4 HiveQueryDef (com.sap.hadoop.windowing.query2.definition.HiveQueryDef)2 QueryDef (com.sap.hadoop.windowing.query2.definition.QueryDef)2 HiveTableDef (com.sap.hadoop.windowing.query2.definition.HiveTableDef)1 OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)1 PartitionDef (com.sap.hadoop.windowing.query2.definition.PartitionDef)1 QueryInputDef (com.sap.hadoop.windowing.query2.definition.QueryInputDef)1 WhereDef (com.sap.hadoop.windowing.query2.definition.WhereDef)1 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)1 WindowFrameDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef)1 HiveQuerySpec (com.sap.hadoop.windowing.query2.specification.HiveQuerySpec)1 OrderSpec (com.sap.hadoop.windowing.query2.specification.OrderSpec)1 PartitionSpec (com.sap.hadoop.windowing.query2.specification.PartitionSpec)1 WindowFrameSpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)1 WindowSpec (com.sap.hadoop.windowing.query2.specification.WindowSpec)1 QueryComponentizer (com.sap.hadoop.windowing.query2.translate.QueryComponentizer)1 InputInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1