@Override public String getExprString() { return desc.getExprString() + "." + fieldName; }
private void replaceExprNode(DynamicListContext ctx, FilterDesc desc, ExprNodeDesc node) { if (ctx.grandParent == null) { desc.setPredicate(node); } else { int i = ctx.grandParent.getChildren().indexOf(ctx.parent); ctx.grandParent.getChildren().remove(i); ctx.grandParent.getChildren().add(i, node); } }
/** * Compiles the appropriate vector expression writer based on an expression info (ExprNodeDesc) */ public static VectorExpressionWriter genVectorExpressionWritable(ExprNodeDesc nodeDesc) throws HiveException { ObjectInspector objectInspector = nodeDesc.getWritableObjectInspector(); if (null == objectInspector) { objectInspector = TypeInfoUtils .getStandardWritableObjectInspectorFromTypeInfo(nodeDesc.getTypeInfo()); } if (null == objectInspector) { throw new HiveException(String.format( "Failed to initialize VectorExpressionWriter for expr: %s", nodeDesc.getExprString())); } return genVectorExpressionWritable(objectInspector); }
public static void addExprToStringBuffer(ExprNodeDesc expr, Appendable sb, boolean userLevelExplain, boolean sortExpressions) { try { sb.append(expr.getExprString(sortExpressions)); if (!userLevelExplain) { sb.append(" (type: "); sb.append(expr.getTypeString()); sb.append(")"); } } catch (IOException e) { throw new RuntimeException(e); } }
/** * return true if predicate is already included in source */ public static boolean containsPredicate(ExprNodeDesc source, ExprNodeDesc predicate) { if (source.isSame(predicate)) { return true; } if (FunctionRegistry.isOpAnd(source)) { if (containsPredicate(source.getChildren().get(0), predicate) || containsPredicate(source.getChildren().get(1), predicate)) { return true; } } return false; }
public static boolean isConstantStruct(ExprNodeDesc valueDesc) { return valueDesc instanceof ExprNodeConstantDesc && valueDesc.getTypeInfo() instanceof StructTypeInfo; }
private VectorExpression getCastToLongExpression(List<ExprNodeDesc> childExpr, PrimitiveCategory integerPrimitiveCategory) throws HiveException { ExprNodeDesc child = childExpr.get(0); String inputType = childExpr.get(0).getTypeString(); if (child instanceof ExprNodeConstantDesc) { // Return a constant vector expression Object constantValue = ((ExprNodeConstantDesc) child).getValue(); Long longValue = castConstantToLong(constantValue, child.getTypeInfo(), integerPrimitiveCategory); return getConstantVectorExpression(longValue, TypeInfoFactory.longTypeInfo, VectorExpressionDescriptor.Mode.PROJECTION); } // Float family, timestamp are handled via descriptor based lookup, int family needs // special handling. if (isIntFamily(inputType)) { // integer and boolean types require no conversion, so use a no-op return getIdentityExpression(childExpr); } return null; }
LOG.debug("Replacing column " + col + " with constant " + constant + " in " + op); if (!col.getType().equals(constant.getTypeInfo())) { constant = typeCast(constant, col.getType()); col.setObjectinspector(constant.getWritableObjectInspector());
@Override public List<String> getReferencedColumns() throws SemanticException { MatchPath matchPath = (MatchPath) evaluator; List<String> columns = new ArrayList<>(); for (ExprNodeDesc exprNode : matchPath.resultExprInfo.resultExprNodes) { Utilities.mergeUniqElems(columns, exprNode.getCols()); } for (ExprNodeDesc exprNode : matchPath.symInfo.symbolExprsDecs) { Utilities.mergeUniqElems(columns, exprNode.getCols()); } return columns; }
if (source instanceof ExprNodeGenericFuncDesc) { ExprNodeGenericFuncDesc function = (ExprNodeGenericFuncDesc) source.clone(); List<ExprNodeDesc> newChildren = flattenExprList(function.getChildren()); for (ExprNodeDesc newChild : newChildren) { return new ExprNodeColumnDesc(source.getTypeInfo(), newColumn, column.getTabAlias(), false); ExprNodeFieldDesc field = (ExprNodeFieldDesc) source.clone(); ExprNodeDesc fieldDesc = flattenExpr(field.getDesc()); if (fieldDesc == null) {
protected static boolean isExisted(ExprNodeDesc expr, List<ExprNodeDesc> columns) { for (ExprNodeDesc thisExpr : columns) { if (thisExpr != null && thisExpr.isSame(expr)) { return true; } } return false; }
public static ArrayList<ExprNodeDesc> clone(List<ExprNodeDesc> sources) { ArrayList<ExprNodeDesc> result = new ArrayList<ExprNodeDesc>(); for (ExprNodeDesc expr : sources) { result.add(expr.clone()); } return result; }
private boolean isColumnOrNonNullConst(ExprNodeDesc exprNodeDesc) { if (exprNodeDesc instanceof ExprNodeColumnDesc) { return true; } if (exprNodeDesc instanceof ExprNodeConstantDesc) { String typeString = exprNodeDesc.getTypeString(); if (!typeString.equalsIgnoreCase("void")) { return true; } } return false; }
/** * Convert exprNodeDesc array to ObjectInspector array. */ static ArrayList<ObjectInspector> getWritableObjectInspector(ArrayList<ExprNodeDesc> exprs) { ArrayList<ObjectInspector> result = new ArrayList<ObjectInspector>(); for (ExprNodeDesc expr : exprs) { result.add(expr.getWritableObjectInspector()); } return result; }
/** * Convert the ColumnList to FieldSchema list. */ public static List<FieldSchema> getFieldSchemasFromColumnList( List<ExprNodeDesc> cols, String fieldPrefix) { List<FieldSchema> schemas = new ArrayList<FieldSchema>(cols.size()); for (int i = 0; i < cols.size(); i++) { schemas.add(HiveMetaStoreUtils.getFieldSchemaFromTypeInfo(fieldPrefix + i, cols.get(i).getTypeInfo())); } return schemas; }
private VectorExpression getCastToLongExpression(List<ExprNodeDesc> childExpr, PrimitiveCategory integerPrimitiveCategory) throws HiveException { ExprNodeDesc child = childExpr.get(0); String inputType = childExpr.get(0).getTypeString(); if (child instanceof ExprNodeConstantDesc) { // Return a constant vector expression Object constantValue = ((ExprNodeConstantDesc) child).getValue(); Long longValue = castConstantToLong(constantValue, child.getTypeInfo(), integerPrimitiveCategory); return getConstantVectorExpression(longValue, TypeInfoFactory.longTypeInfo, VectorExpressionDescriptor.Mode.PROJECTION); } // Float family, timestamp are handled via descriptor based lookup, int family needs // special handling. if (isIntFamily(inputType)) { // integer and boolean types require no conversion, so use a no-op return getIdentityExpression(childExpr); } return null; }
public static void addExprToStringBuffer(ExprNodeDesc expr, Appendable sb, boolean userLevelExplain) { try { sb.append(expr.getExprString()); if (!userLevelExplain) { sb.append(" (type: "); sb.append(expr.getTypeString()); sb.append(")"); } } catch (IOException e) { throw new RuntimeException(e); } }
LOG.debug("Replacing column " + col + " with constant " + constant + " in " + op); if (!col.getType().equals(constant.getTypeInfo())) { constant = typeCast(constant, col.getType()); col.setObjectinspector(constant.getWritableObjectInspector());
@Override public List<String> getCols() { List<String> colList = new ArrayList<String>(); if (desc != null) { colList = Utilities.mergeUniqElems(colList, desc.getCols()); } return colList; }