private void setupSelectListInputInfo() throws SemanticException { selectListInputTypeCheckCtx = new TypeCheckCtx(selectListInputRowResolver); selectListInputTypeCheckCtx.setUnparseTranslator(null); /* * create SelectListOI */ selectListInputOI = PTFTranslator.getStandardStructOI(selectListInputRowResolver); }
public static ExprNodeDesc buildExprNode(ASTNode expr, TypeCheckCtx typeCheckCtx) throws SemanticException { // todo: use SemanticAnalyzer::genExprNodeDesc // currently SA not available to PTFTranslator. Map<ASTNode, ExprNodeDesc> map = TypeCheckProcFactory .genExprNode(expr, typeCheckCtx); ExprNodeDesc desc = map.get(expr); if (desc == null) { String errMsg = typeCheckCtx.getError(); if ( errMsg == null) { errMsg = "Error in parsing "; } throw new SemanticException(errMsg); } return desc; } }
if (!ctx.isUseCaching() && ctx.getOuterRR() == null) { return null; RowResolver input = ctx.getInputRR(); ExprNodeDesc desc = null; if ((ctx == null) || (input == null) || (!ctx.getAllowGBExprElimination())) { return null; RowResolver outerRR = ctx.getOuterRR(); if(colInfo == null && outerRR != null) { colInfo = outerRR.getExpression(expr); desc = new ExprNodeColumnDesc(colInfo); ASTNode source = input.getExpressionSource(expr); if (source != null && ctx.getUnparseTranslator() != null) { ctx.getUnparseTranslator().addCopyTranslation(expr, source);
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, RowResolver outerRR, Map<ASTNode, RelNode> subqueryToRelNode, boolean useCaching) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, false); tcCtx.setOuterRR(outerRR); tcCtx.setSubqueryToRelNode(subqueryToRelNode); return genExprNodeDesc(expr, input, tcCtx); }
if (isDescendant(nd, ctx.getErrorSrcNode())) { ctx.setError(null, null); if (ctx.getError() != null) { return null; if (!ctx.getallowWindowing()) { throw new SemanticException(SemanticAnalyzer.generateErrorMessage(expr, ErrorMsg.INVALID_FUNCTION.getMsg("Windowing is not supported in the context"))); if (!ctx.getallowAllColRef()) { throw new SemanticException(SemanticAnalyzer.generateErrorMessage(expr, ErrorMsg.INVALID_COLUMN RowResolver input = ctx.getInputRR(); ExprNodeColumnListDesc columnList = new ExprNodeColumnListDesc(); assert expr.getChildCount() <= 1; if (!ctx.getAllowDistinctFunctions() && expr.getType() == HiveParser.TOK_FUNCTIONDI) { throw new SemanticException( SemanticAnalyzer.generateErrorMessage(expr, ErrorMsg.DISTINCT_NOT_SUPPORTED.getMsg())); if (!ctx.getallowFunctionStar()) { throw new SemanticException(SemanticAnalyzer.generateErrorMessage(expr, ErrorMsg.INVALID_COLUMN RowResolver input = ctx.getInputRR(); for (ColumnInfo colInfo : input.getColumnInfos()) { if (!colInfo.getIsVirtualCol()) {
TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); tcCtx.setAllowDistinctFunctions(false); ExprNodeDesc exp = genExprNodeDesc((ASTNode) aggAst.getChild(0), inputRR, tcCtx); udafRetType = exp.getTypeInfo();
if (ctx.getError() != null) { return null; RowResolver input = ctx.getInputRR(); if(input == null) { ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr), expr); return null; ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr), expr); return null; if(ctx.getOuterRR() != null && colInfo == null && !isTableAlias) { RowResolver outerRR = ctx.getOuterRR(); isTableAlias = outerRR.hasTableAlias(tableOrCol); colInfo = outerRR.get(null, tableOrCol); ctx.setError(ErrorMsg.NON_KEY_EXPR_IN_GROUPBY.getMsg(exprNode), expr); return null; } else { String reason = String.format("(possible column names are: %s)", StringUtils.join(possibleColumnNames, ", ")); ctx.setError(ErrorMsg.INVALID_TABLE_OR_COLUMN.getMsg(expr.getChild(0), reason), expr); LOG.debug(ErrorMsg.INVALID_TABLE_OR_COLUMN.toString() + ":"
private List<RexNode> getPartitionKeys(PartitionSpec ps, RexNodeConverter converter, RowResolver inputRR) throws SemanticException { List<RexNode> pKeys = new ArrayList<RexNode>(); if (ps != null) { List<PartitionExpression> pExprs = ps.getExpressions(); for (PartitionExpression pExpr : pExprs) { TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); ExprNodeDesc exp = genExprNodeDesc(pExpr.getExpression(), inputRR, tcCtx); pKeys.add(converter.convert(exp)); } } return pKeys; }
if (ctx.getError() != null) { return null; ASTNode sqNode = (ASTNode) expr.getParent().getChild(1); if (!ctx.getallowSubQueryExpr()) { throw new CalciteSubquerySemanticException(SemanticAnalyzer.generateErrorMessage(sqNode, ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg("Currently SubQuery expressions are only allowed as " + Map<ASTNode, RelNode> subqueryToRelNode = ctx.getSubqueryToRelNode(); if(subqueryToRelNode == null) { throw new CalciteSubquerySemanticException(ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg( ctx.setError(ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg(sqNode, "Currently only IN & EXISTS SubQuery expressions are allowed"), sqNode);
if (ctx.getError() != null) { return null; RowResolver input = ctx.getInputRR(); ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr), expr); return null; ctx.setError(ErrorMsg.NON_KEY_EXPR_IN_GROUPBY.getMsg(exprNode), expr); return null; } else { String reason = String.format("(possible column names are: %s)", StringUtils.join(possibleColumnNames, ", ")); ctx.setError(ErrorMsg.INVALID_TABLE_OR_COLUMN.getMsg(expr.getChild(0), reason), expr); LOG.debug(ErrorMsg.INVALID_TABLE_OR_COLUMN.toString() + ":"
/** * Generates an expression node descriptors for the expression and children of it * with default TypeCheckCtx. */ public Map<ASTNode, ExprNodeDesc> genAllExprNodeDesc(ASTNode expr, RowResolver input) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input); return genAllExprNodeDesc(expr, input, tcCtx); }
if (isDescendant(nd, ctx.getErrorSrcNode())) { ctx.setError(null, null); if (ctx.getError() != null) { return null; && nodeOutputs[0] == null) { RowResolver input = ctx.getInputRR(); String tableAlias = BaseSemanticAnalyzer.unescapeIdentifier(expr .getChild(0).getChild(0).getText()); ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr.getChild(1)), expr); return null;
protected ExprNodeDesc processQualifiedColRef(TypeCheckCtx ctx, ASTNode expr, Object... nodeOutputs) throws SemanticException { RowResolver input = ctx.getInputRR(); String tableAlias = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getChild(0) .getText()); // NOTE: tableAlias must be a valid non-ambiguous table alias, // because we've checked that in TOK_TABLE_OR_COL's process method. String colName; if (nodeOutputs[1] instanceof ExprNodeConstantDesc) { colName = ((ExprNodeConstantDesc) nodeOutputs[1]).getValue().toString(); } else if (nodeOutputs[1] instanceof ExprNodeColumnDesc) { colName = ((ExprNodeColumnDesc)nodeOutputs[1]).getColumn(); } else { throw new SemanticException("Unexpected ExprNode : " + nodeOutputs[1]); } ColumnInfo colInfo = input.get(tableAlias, colName); // Try outer Row resolver if(colInfo == null && ctx.getOuterRR() != null) { RowResolver outerRR = ctx.getOuterRR(); colInfo = outerRR.get(tableAlias, colName); } if (colInfo == null) { ctx.setError(ErrorMsg.INVALID_COLUMN.getMsg(expr.getChild(1)), expr); return null; } return toExprNodeDesc(colInfo); }
TypeCheckCtx tcCtx) throws SemanticException { tcCtx.setUnparseTranslator(unparseTranslator); ExprNodeDesc desc = nodeOutputs.get(expr); if (desc == null) { String errMsg = tcCtx.getError(); if (errMsg == null) { errMsg = "Error in parsing "; && !tmp[0].equals(columnDesc.getTabAlias()) && tcCtx.getOuterRR() != null) { tmp = tcCtx.getOuterRR().reverseLookup(columnDesc.getColumn());
} else if (funcText.equals("[")) { if (!ctx.getallowIndexExpr()) { throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(expr)); ctx.getUnparseTranslator().addIdentifierTranslation( (ASTNode) expr.getChild(0)); if (!ctx.isCBOExecuted()) { ArrayList<ExprNodeDesc> orOperands = TypeCheckProcFactoryUtils.rewriteInToOR(children); if (orOperands != null) { } else if (ctx.isFoldExpr() && canConvertIntoCoalesce(genericUDF, children)) { if (ctx.isFoldExpr() && desc instanceof ExprNodeGenericFuncDesc && FunctionRegistry.isConsistentWithinQuery(genericUDF) && ExprNodeDescUtils.isAllConstants(children)) {
} else if (funcText.equals("[")) { if (!ctx.getallowIndexExpr()) throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(expr)); ctx.getUnparseTranslator().addIdentifierTranslation( (ASTNode) expr.getChild(0)); } else if (ctx.isFoldExpr() && canConvertIntoNvl(genericUDF, children)) { if (ctx.isFoldExpr() && desc instanceof ExprNodeGenericFuncDesc && FunctionRegistry.isDeterministic(genericUDF) && ExprNodeDescUtils.isAllConstants(children)) {
TypeCheckCtx tcCtx = new TypeCheckCtx(input); tcCtx.setUnparseTranslator(unparseTranslator); ExprNodeDesc desc = (ExprNodeDesc) nodeOutputs.get(expr); if (desc == null) { throw new SemanticException(tcCtx.getError());
TypeCheckCtx ctx = (TypeCheckCtx) procCtx; RowResolver input = ctx.getInputRR(); ExprNodeDesc desc = null; if ((ctx == null) || (input == null) || (!ctx.getAllowGBExprElimination())) { return null; ASTNode source = input.getExpressionSource(expr); if (source != null) { ctx.getUnparseTranslator().addCopyTranslation(expr, source);
@Override public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { TypeCheckCtx ctx = (TypeCheckCtx) procCtx; if (ctx.getError() != null) { return null; } ASTNode expr = (ASTNode) nd; ASTNode sqNode = (ASTNode) expr.getParent().getChild(1); if (!ctx.getallowSubQueryExpr()) throw new SemanticException(SemanticAnalyzer.generateErrorMessage(sqNode, ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg())); ExprNodeDesc desc = TypeCheckProcFactory.processGByExpr(nd, procCtx); if (desc != null) { return desc; } /* * Restriction.1.h :: SubQueries only supported in the SQL Where Clause. */ ctx.setError(ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg(sqNode, "Currently SubQuery expressions are only allowed as Where Clause predicates"), sqNode); return null; } }
TypeCheckCtx tcCtx) throws SemanticException { tcCtx.setUnparseTranslator(unparseTranslator); ExprNodeDesc desc = nodeOutputs.get(expr); if (desc == null) { String errMsg = tcCtx.getError(); if (errMsg == null) { errMsg = "Error in parsing ";