Search in sources :

Example 1 with TypeCheckCtx

use of org.apache.hadoop.hive.ql.parse.TypeCheckCtx in project SQLWindowing by hbutani.

the class ResultExpressionParser method setupSelectListInputInfo.

private void setupSelectListInputInfo() throws WindowingException {
    selectListInputRowResolver = HiveUtils.getRowResolver("npathInput", selectListInputOI);
    selectListInputTypeCheckCtx = new TypeCheckCtx(selectListInputRowResolver);
    selectListInputTypeCheckCtx.setUnparseTranslator(null);
}
Also used : TypeCheckCtx(org.apache.hadoop.hive.ql.parse.TypeCheckCtx)

Example 2 with TypeCheckCtx

use of org.apache.hadoop.hive.ql.parse.TypeCheckCtx in project SQLWindowing by hbutani.

the class WindowingTypeCheckProcFactory method processGByExpr.

/**
 * Function to do groupby subexpression elimination. This is called by all
 * the processors initially. As an example, consider the query select a+b,
 * count(1) from T group by a+b; Then a+b is already precomputed in the
 * group by operators key, so we substitute a+b in the select list with the
 * internal column name of the a+b expression that appears in the in input
 * row resolver.
 *
 * @param nd
 *            The node that is being inspected.
 * @param procCtx
 *            The processor context.
 *
 * @return exprNodeColumnDesc.
 */
public static ExprNodeDesc processGByExpr(Node nd, Object procCtx) throws SemanticException {
    // We recursively create the exprNodeDesc. Base cases: when we encounter
    // a column ref, we convert that into an exprNodeColumnDesc; when we
    // encounter
    // a constant, we convert that into an exprNodeConstantDesc. For others
    // we
    // just
    // build the exprNodeFuncDesc with recursively built children.
    ASTNode expr = (ASTNode) nd;
    TypeCheckCtx ctx = (TypeCheckCtx) procCtx;
    RowResolver input = ctx.getInputRR();
    ExprNodeDesc desc = null;
    // If the current subExpression is pre-calculated, as in Group-By etc.
    ColumnInfo colInfo = input.getExpression(expr);
    if (colInfo != null) {
        desc = new ExprNodeColumnDesc(colInfo.getType(), colInfo.getInternalName(), colInfo.getTabAlias(), colInfo.getIsVirtualCol());
        // }
        return desc;
    }
    return desc;
}
Also used : TypeCheckCtx(org.apache.hadoop.hive.ql.parse.TypeCheckCtx) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) ExprNodeColumnDesc(org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc) ColumnInfo(org.apache.hadoop.hive.ql.exec.ColumnInfo) RowResolver(org.apache.hadoop.hive.ql.parse.RowResolver) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc)

Aggregations

TypeCheckCtx (org.apache.hadoop.hive.ql.parse.TypeCheckCtx)2 ColumnInfo (org.apache.hadoop.hive.ql.exec.ColumnInfo)1 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1 RowResolver (org.apache.hadoop.hive.ql.parse.RowResolver)1 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)1 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)1