@Override public String getExprString() { return getColumn(); }
private String getColumnName(String alias, ExprNodeDesc exprNode, int colIdx) { if (alias != null) { return alias; } else if (exprNode instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc) exprNode; return colDesc.getColumn(); } return "matchpath_col_" + colIdx; }
private String getColumnName(String alias, ExprNodeDesc exprNode, int colIdx) { if (alias != null) { return alias; } else if (exprNode instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc) exprNode; return colDesc.getColumn(); } return "matchpath_col_" + colIdx; }
public void addAffectedColumn(ExprNodeColumnDesc column) { affectedColumns.add(column.getColumn()); }
private boolean isJoinKey(final String columnName, final ExprNodeDesc[][] joinKeys) { for (int i = 0; i < joinKeys.length; i++) { for (ExprNodeDesc expr : Arrays.asList(joinKeys[i])) { if (expr instanceof ExprNodeColumnDesc) { if (((ExprNodeColumnDesc) expr).getColumn().equals(columnName)) { return true; } } } } return false; }
private static List<String> getKeyColNames(List<ExprNodeDesc> keys) { List<String> colList = new ArrayList<String>(); for (ExprNodeDesc expr: keys) { if (expr instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colExpr = (ExprNodeColumnDesc)expr; colList.add(colExpr.getColumn()); } else if (expr instanceof ExprNodeConstantDesc) { continue; } else { return null; } } return colList; } }
private static ExprNodeDesc findParentExpr(ExprNodeColumnDesc col, Operator<?> op) { ExprNodeDesc parentExpr = col; Map<String, ExprNodeDesc> mapping = op.getColumnExprMap(); if (mapping != null) { parentExpr = mapping.get(col.getColumn()); if (parentExpr == null && op instanceof ReduceSinkOperator) { return col; } } return parentExpr; }
protected int getInputColumnIndex(ExprNodeColumnDesc colExpr) throws HiveException { // Call the regular method since it does error checking. return getInputColumnIndex(colExpr.getColumn()); }
/** * Recommend name for the expression */ public static String recommendInputName(ExprNodeDesc desc) { if (desc instanceof ExprNodeColumnDesc) { return ((ExprNodeColumnDesc)desc).getColumn(); } List<ExprNodeDesc> children = desc.getChildren(); if (FunctionRegistry.isOpPreserveInputName(desc) && !children.isEmpty() && children.get(0) instanceof ExprNodeColumnDesc) { return ((ExprNodeColumnDesc)children.get(0)).getColumn(); } return null; }
public static Map<String, List<IndexSearchCondition>> decompose( List<IndexSearchCondition> searchConditions) { Map<String, List<IndexSearchCondition>> result = new HashMap<String, List<IndexSearchCondition>>(); for (IndexSearchCondition condition : searchConditions) { List<IndexSearchCondition> conditions = result.get(condition.getColumnDesc().getColumn()); if (conditions == null) { conditions = new ArrayList<IndexSearchCondition>(); result.put(condition.getColumnDesc().getColumn(), conditions); } conditions.add(condition); } return result; }
private static ExprNodeDesc findParentExpr(ExprNodeColumnDesc col, Operator<?> op) { if (op instanceof ReduceSinkOperator) { return col; } ExprNodeDesc parentExpr = col; Map<String, ExprNodeDesc> mapping = op.getColumnExprMap(); if (mapping != null) { parentExpr = mapping.get(col.getColumn()); } return parentExpr; }
private ImmutableMap<String, Integer> buildHiveColNameToInputPosMap( List<ExprNodeDesc> col_list, RowResolver inputRR) { // Build a map of Hive column Names (ExprNodeColumnDesc Name) // to the positions of those projections in the input Map<Integer, ExprNodeDesc> hashCodeTocolumnDescMap = new HashMap<Integer, ExprNodeDesc>(); ExprNodeDescUtils.getExprNodeColumnDesc(col_list, hashCodeTocolumnDescMap); ImmutableMap.Builder<String, Integer> hiveColNameToInputPosMapBuilder = new ImmutableMap.Builder<String, Integer>(); String exprNodecolName; for (ExprNodeDesc exprDesc : hashCodeTocolumnDescMap.values()) { exprNodecolName = ((ExprNodeColumnDesc) exprDesc).getColumn(); hiveColNameToInputPosMapBuilder.put(exprNodecolName, inputRR.getPosition(exprNodecolName)); } return hiveColNameToInputPosMapBuilder.build(); }
static private void extractColumns(Set<String> colNamesExprs, ExprNodeDesc exprNode) throws SemanticException { if (exprNode instanceof ExprNodeColumnDesc) { colNamesExprs.add(((ExprNodeColumnDesc) exprNode).getColumn()); return; } if (exprNode instanceof ExprNodeGenericFuncDesc) { ExprNodeGenericFuncDesc funcDesc = (ExprNodeGenericFuncDesc) exprNode; for (ExprNodeDesc childExpr : funcDesc.getChildren()) { extractColumns(colNamesExprs, childExpr); } } }
private static ExprNodeDesc backtrack(ExprNodeColumnDesc column, Operator<?> current, Operator<?> terminal) throws SemanticException { Map<String, ExprNodeDesc> mapping = current.getColumnExprMap(); if (mapping == null) { return backtrack((ExprNodeDesc)column, current, terminal); } ExprNodeDesc mapped = mapping.get(column.getColumn()); return mapped == null ? null : backtrack(mapped, current, terminal); }
static List<BucketCol> extractBucketCols(ReduceSinkOperator rop, List<ExprNodeDesc> outputValues) { List<BucketCol> bucketCols = new ArrayList<BucketCol>(); for (ExprNodeDesc partitionCol : rop.getConf().getPartitionCols()) { if (!(partitionCol instanceof ExprNodeColumnDesc)) { return Collections.emptyList(); } int index = ExprNodeDescUtils.indexOf(partitionCol, outputValues); if (index < 0) { return Collections.emptyList(); } bucketCols.add(new BucketCol(((ExprNodeColumnDesc) partitionCol).getColumn(), index)); } // If the partition columns can't all be found in the values then the data is not bucketed return bucketCols; }
private static ExprNodeDesc backtrack(ExprNodeColumnDesc column, Operator<?> current, Operator<?> terminal) throws SemanticException { Map<String, ExprNodeDesc> mapping = current.getColumnExprMap(); if (mapping == null) { return backtrack((ExprNodeDesc)column, current, terminal); } ExprNodeDesc mapped = mapping.get(column.getColumn()); return mapped == null ? null : backtrack(mapped, current, terminal); }
@Override public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { ExprNodeColumnDesc cd = (ExprNodeColumnDesc) nd; PcrExprProcCtx epc = (PcrExprProcCtx) procCtx; if (cd.getTabAlias().equalsIgnoreCase(epc.getTabAlias()) && cd.getIsPartitionColOrVirtualCol() && !VirtualColumn.VIRTUAL_COLUMN_NAMES.contains(cd.getColumn().toUpperCase())) { return new NodeInfoWrapper(WalkState.PART_COL, null, cd); } else { return new NodeInfoWrapper(WalkState.UNKNOWN, null, cd); } } }
private ExprNodeDesc getRSColExprFromResidualFilter(ExprNodeDesc childExpr, CommonJoinOperator<JoinDesc> join) { ExprNodeColumnDesc colExpr = ExprNodeDescUtils.getColumnExpr(childExpr); final String joinColName = colExpr.getColumn(); // use name to get the alias pos of parent and name in parent final int aliasPos = join.getConf().getReversedExprs().get(joinColName); final ExprNodeDesc rsColExpr = join.getColumnExprMap().get(joinColName); // Get the correct parent final ReduceSinkOperator parentRS = (ReduceSinkOperator) (join.getParentOperators().get(aliasPos)); // Fetch the colExpr from parent return parentRS.getColumnExprMap().get( ExprNodeDescUtils.extractColName(rsColExpr)); }
@Override protected ExprNodeDesc processColumnDesc(NodeProcessorCtx procCtx, ExprNodeColumnDesc cd) { ExprNodeDesc newcd; LBExprProcCtx ctx = (LBExprProcCtx) procCtx; Partition part = ctx.getPart(); if (cd.getTabAlias().equalsIgnoreCase(ctx.getTabAlias()) && isPruneForListBucketing(part, cd.getColumn())) { newcd = cd.clone(); } else { newcd = new ExprNodeConstantDesc(cd.getTypeInfo(), null); } return newcd; }
protected ColumnInfo resolveDot(ASTNode node) { try { TypeCheckCtx tcCtx = new TypeCheckCtx(parentQueryRR); String str = BaseSemanticAnalyzer.unescapeIdentifier(node.getChild(1).getText()); ExprNodeDesc idDesc = new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, str.toLowerCase()); Object desc = defaultExprProcessor.process(node, stack, tcCtx, (Object) null, idDesc); if (desc != null && desc instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc) desc; String[] qualName = parentQueryRR.reverseLookup(colDesc.getColumn()); return parentQueryRR.get(qualName[0], qualName[1]); } } catch(SemanticException se) { } return null; }