Refine search
if (castType.equals(TypeInfoFactory.byteTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("tinyint"); } else if (castType instanceof CharTypeInfo) { castUDF = handleCastForParameterizedType(castType, FunctionRegistry.getFunctionInfo("char")); } else if (castType instanceof VarcharTypeInfo) { castUDF = handleCastForParameterizedType(castType, FunctionRegistry.getFunctionInfo("varchar")); } else if (castType.equals(TypeInfoFactory.stringTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("string"); } else if (castType.equals(TypeInfoFactory.booleanTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("boolean"); } else if (castType.equals(TypeInfoFactory.shortTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("smallint"); } else if (castType.equals(TypeInfoFactory.intTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("int"); } else if (castType.equals(TypeInfoFactory.longTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("bigint"); } else if (castType.equals(TypeInfoFactory.floatTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("float"); } else if (castType.equals(TypeInfoFactory.doubleTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("double"); } else if (castType.equals(TypeInfoFactory.timestampTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("timestamp"); } else if (castType instanceof TimestampLocalTZTypeInfo) { castUDF = handleCastForParameterizedType(castType, FunctionRegistry.getFunctionInfo(serdeConstants.TIMESTAMPLOCALTZ_TYPE_NAME)); } else if (castType.equals(TypeInfoFactory.dateTypeInfo)) { castUDF = FunctionRegistry.getFunctionInfo("date"); } else if (castType instanceof DecimalTypeInfo) {
/** * Verify that UDF not in whitelist can't be accessed * @throws Exception */ @Test (expected=SemanticException.class) public void testUdfNotInWhiteList() throws Exception { Set<String> funcNames = FunctionRegistry.getFunctionNames(); funcNames.remove("reflect"); FunctionRegistry.setupPermissionsForBuiltinUDFs(funcNames.toString(), ""); assertEquals("reflect", FunctionRegistry.getFunctionInfo("reflect").getDisplayName()); }
if (((ExprNodeGenericFuncDesc) node).getGenericUDF() instanceof GenericUDFOPEqual) { return evaluateEqualNd(node, skewedCols, cell, uniqSkewedValues); } else if (FunctionRegistry.isOpAnd(node)) { return evaluateAndNode(node, skewedCols, cell, uniqSkewedValues); } else if (FunctionRegistry.isOpOr(node)) { return evaluateOrNode(node, skewedCols, cell, uniqSkewedValues); } else if (FunctionRegistry.isOpNot(node)) { return evaluateNotNode(node, skewedCols, cell, uniqSkewedValues); } else {
/** * Find a common class that objects of both TypeInfo a and TypeInfo b can * convert to. This is used for places other than comparison. * * The common class of string and double is string. * * @return null if no common class could be found. */ public static TypeInfo getCommonClass(TypeInfo a, TypeInfo b) { if (a.equals(b)) { return a; } // We try to infer a common primitive category PrimitiveCategory commonCat = getPrimitiveCommonCategory(a, b); if (commonCat != null) { return getTypeInfoForPrimitiveCategory((PrimitiveTypeInfo)a, (PrimitiveTypeInfo)b, commonCat); } // It is not primitive; check if it is a struct and we can infer a common class if (a.getCategory() == Category.STRUCT && b.getCategory() == Category.STRUCT) { return getCommonClassForStruct((StructTypeInfo)a, (StructTypeInfo)b, (type1, type2) -> getCommonClass(type1, type2)); } return null; }
/** * bind two predicates by AND op */ public static ExprNodeGenericFuncDesc mergePredicates(ExprNodeDesc prev, ExprNodeDesc next) { final List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>(2); if (FunctionRegistry.isOpAnd(prev)) { children.addAll(prev.getChildren()); } else { children.add(prev); } if (FunctionRegistry.isOpAnd(next)) { children.addAll(next.getChildren()); } else { children.add(next); } return new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, FunctionRegistry.getGenericUDFForAnd(), children); }
TypeInfo oiTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(oi); TypeInfo rTypeInfo = TypeInfoUtils .getTypeInfoFromObjectInspector(returnObjectInspector); if (oiTypeInfo == rTypeInfo) { switch (conversionType) { case COMMON: commonTypeInfo = FunctionRegistry.getCommonClass(oiTypeInfo, rTypeInfo); break; case UNION: commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(rTypeInfo, oiTypeInfo); break; case COMPARISON: commonTypeInfo = FunctionRegistry.getCommonClassForComparison(rTypeInfo, oiTypeInfo); break; .getStandardWritableObjectInspectorFromTypeInfo(commonTypeInfo);
String defaultPartitionName = HiveConf.getVar(conf, HiveConf.ConfVars.DEFAULTPARTITIONNAME); Map<String, String> colTypes = new HashMap<String, String>(); for (FieldSchema fs : tab.getPartitionKeys()) { for (int childIndex = 0; childIndex < ast.getChildCount(); childIndex++) { Tree partSpecTree = ast.getChild(childIndex); if (partSpecTree.getType() != HiveParser.TOK_PARTSPEC) { continue; HashSet<String> names = new HashSet<String>(partSpecTree.getChildCount()); for (int i = 0; i < partSpecTree.getChildCount(); ++i) { CommonTree partSpecSingleKey = (CommonTree) partSpecTree.getChild(i); assert (partSpecSingleKey.getType() == HiveParser.TOK_PARTVAL); op = makeBinaryPredicate(operator, column, new ExprNodeConstantDesc(pti, val)); } else { GenericUDF originalOp = FunctionRegistry.getFunctionInfo(operator).getGenericUDF(); String fnName; if (FunctionRegistry.isEq(originalOp)) { fnName = "isnull"; } else if (FunctionRegistry.isNeq(originalOp)) { fnName = "isnotnull"; } else {
/** * Verify that UDF in the whitelist can be access * @throws Exception */ @Test public void testDefaultWhiteList() throws Exception { assertEquals("", new HiveConf().getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_WHITELIST)); assertEquals("", new HiveConf().getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST)); FunctionRegistry.setupPermissionsForBuiltinUDFs("", ""); assertEquals("substr", FunctionRegistry.getFunctionInfo("substr").getDisplayName()); }
@SuppressWarnings("unchecked") private void analyzeDropMacro(ASTNode ast) throws SemanticException { String functionName = ast.getChild(0).getText(); boolean ifExists = (ast.getFirstChildWithType(TOK_IFEXISTS) != null); // we want to signal an error if the function doesn't exist and we're // configured not to ignore this boolean throwException = !ifExists && !HiveConf.getBoolVar(conf, ConfVars.DROPIGNORESNONEXISTENT); // Temp macros are not allowed to have qualified names. if (FunctionUtils.isQualifiedFunctionName(functionName)) { throw new SemanticException("Temporary macro name cannot be a qualified name."); } if (throwException && FunctionRegistry.getFunctionInfo(functionName) == null) { throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(functionName)); } DropMacroDesc desc = new DropMacroDesc(functionName); rootTasks.add(TaskFactory.get(new FunctionWork(desc))); addEntities(); }
|| exprTokenType == HiveParser.TOK_FUNCTIONSTAR) { assert (expressionTree.getChildCount() != 0); if (expressionTree.getChild(expressionTree.getChildCount()-1).getType() == HiveParser.TOK_WINDOWSPEC) { return 3; if (expressionTree.getChild(0).getType() == HiveParser.Identifier) { String functionName = SemanticAnalyzer.unescapeIdentifier(expressionTree.getChild(0) .getText()); GenericUDAFResolver udafResolver = FunctionRegistry.getGenericUDAFResolver(functionName); if (udafResolver != null) {
private void setupBlockedUdfs() { HiveConf hiveConf = getHiveConf(); FunctionRegistry.setupPermissionsForBuiltinUDFs( hiveConf.getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_WHITELIST), hiveConf.getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST)); }
desc = new ExprNodeGenericFuncDesc(t, FunctionRegistry.getGenericUDFForIndex(), children); } else if (myt.getCategory() == Category.MAP) { if (!TypeInfoUtils.implicitConvertible(children.get(1).getTypeInfo(), ((MapTypeInfo) myt).getMapKeyTypeInfo())) { throw new SemanticException(ErrorMsg.INVALID_MAPINDEX_TYPE desc = new ExprNodeGenericFuncDesc(t, FunctionRegistry.getGenericUDFForIndex(), children); FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcText); children.size()); for (ExprNodeDesc child : children) { if (FunctionRegistry.isOpOr(child)) { childrenList.addAll(child.getChildren()); } else { children.size()); for (ExprNodeDesc child : children) { if (FunctionRegistry.isOpAnd(child)) { childrenList.addAll(child.getChildren()); } else { FunctionRegistry.isDeterministic(genericUDF) && ExprNodeDescUtils.isAllConstants(children)) { ExprNodeDesc constantExpr = ConstantPropagateProcFactory.foldExpr((ExprNodeGenericFuncDesc)desc); if (FunctionRegistry.isOpPositive(desc)) { assert (desc.getChildren().size() == 1); desc = desc.getChildren().get(0);
if (argTypeInfos.get(0).equals(TypeInfoFactory.stringTypeInfo) || argTypeInfos.get(1).equals(TypeInfoFactory.stringTypeInfo)) { if (argTypeInfos.get(0).equals(TypeInfoFactory.decimalTypeInfo) || argTypeInfos.get(1).equals(TypeInfoFactory.decimalTypeInfo)) { modArgTypeInfos.add(TypeInfoFactory.decimalTypeInfo); TypeInfo commonType = FunctionRegistry.getCommonClass(modArgTypeInfos .get(0), modArgTypeInfos.get(1)); if (m.getName().equals("evaluate")) { List<TypeInfo> argumentTypeInfos = TypeInfoUtils.getParameterTypeInfos( m, pTypeInfos.size()); if (argumentTypeInfos == null) {
if (myt.getCategory() == Category.LIST) { desc = new ExprNodeGenericFuncDesc(t, FunctionRegistry.getGenericUDFForIndex(), children); } else if (myt.getCategory() == Category.MAP) { if (!TypeInfoUtils.implicitConvertible(children.get(1).getTypeInfo(), ((MapTypeInfo) myt).getMapKeyTypeInfo())) { throw new SemanticException(ErrorMsg.INVALID_MAPINDEX_TYPE desc = new ExprNodeGenericFuncDesc(t, FunctionRegistry.getGenericUDFForIndex(), children); FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcText); if (FunctionRegistry.isOpOr(child)) { childrenList.addAll(child.getChildren()); } else { if (FunctionRegistry.isOpAnd(child)) { childrenList.addAll(child.getChildren()); } else { FunctionRegistry.isConsistentWithinQuery(genericUDF) && ExprNodeDescUtils.isAllConstants(children)) { ExprNodeDesc constantExpr = ConstantPropagateProcFactory.foldExpr((ExprNodeGenericFuncDesc)desc); if (FunctionRegistry.isOpPositive(desc)) { assert (desc.getChildren().size() == 1); desc = desc.getChildren().get(0);
|| exprTokenType == HiveParser.TOK_FUNCTIONSTAR) { assert (expressionTree.getChildCount() != 0); if (expressionTree.getChild(expressionTree.getChildCount()-1).getType() == HiveParser.TOK_WINDOWSPEC) { if (expressionTree.getChild(0).getType() == HiveParser.Identifier) { String functionName = unescapeIdentifier(expressionTree.getChild(0) .getText()); if (FunctionRegistry.getFunctionInfo(functionName) == null) { throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(functionName)); if(FunctionRegistry.impliesOrder(functionName) && !parentIsWindowSpec) { throw new SemanticException(ErrorMsg.MISSING_OVER_CLAUSE.getMsg(functionName)); if (FunctionRegistry.getGenericUDAFResolver(functionName) != null) { if(containsLeadLagUDF(expressionTree) && !parentIsWindowSpec) { throw new SemanticException(ErrorMsg.MISSING_OVER_CLAUSE.getMsg(functionName)); FunctionInfo fi = FunctionRegistry.getFunctionInfo(functionName); if (!fi.isNative()) { unparseTranslator.addIdentifierTranslation((ASTNode) expressionTree
FilterDesc desc = filter.getConf(); if (!parseContext.getConf().getBoolVar(ConfVars.TEZ_DYNAMIC_PARTITION_PRUNING) && !parseContext.getConf().isSparkDPPAny()) { boolean semiJoin = parseContext.getConf().getBoolVar(ConfVars.TEZ_DYNAMIC_SEMIJOIN_REDUCTION); if (HiveConf.getVar(parseContext.getConf(), HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).equals("spark")) { betweenArgs.add(new ExprNodeDynamicValueDesc(new DynamicValue(keyBaseAlias + "_max", ctx.desc.getTypeInfo()))); ExprNodeDesc betweenNode = ExprNodeGenericFuncDesc.newInstance( FunctionRegistry.getFunctionInfo("between").getGenericUDF(), betweenArgs); TypeInfoFactory.binaryTypeInfo))); ExprNodeDesc bloomFilterNode = ExprNodeGenericFuncDesc.newInstance( FunctionRegistry.getFunctionInfo("in_bloom_filter"). getGenericUDF(), bloomFilterArgs); List<ExprNodeDesc> andArgs = new ArrayList<ExprNodeDesc>(); andArgs.add(bloomFilterNode); ExprNodeDesc andExpr = ExprNodeGenericFuncDesc.newInstance( FunctionRegistry.getFunctionInfo("and").getGenericUDF(), andArgs); replaceExprNode(ctx, desc, andExpr); } else {
inputTableAlias = SemanticAnalyzer.unescapeIdentifier(next.getChild(1).getText().toLowerCase()); } else { inputTableAlias = next.getChildCount() == 1 ? inputTableName : SemanticAnalyzer.unescapeIdentifier(next.getChild(next.getChildCount() - 1).getText().toLowerCase()); (ASTNode) lateralView.getChild(0).getChild(0); final ASTNode functionCall = (ASTNode) selExprClause.getChild(0); FunctionInfo inlineFunctionInfo = FunctionRegistry.getFunctionInfo(inlineFunctionName); SqlOperator calciteOp = SqlFunctionConverter.getCalciteOperator( inlineFunctionName, inlineFunctionInfo.getGenericUDTF(),
private void doTests(Random random, String typeName, String functionName) throws Exception { TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(typeName); String[] outputScratchTypeNames = new String[] { targetTypeInfo.getTypeName() }; DataTypePhysicalVariation[] outputDataTypePhysicalVariations = new DataTypePhysicalVariation[] { DataTypePhysicalVariation.NONE }; FunctionInfo funcInfo = null; try { funcInfo = FunctionRegistry.getFunctionInfo(functionName); } catch (SemanticException e) { Assert.fail("Failed to load " + functionName + " " + e);
(StructTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(structTypeName); TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo( structTypeInfo); getStandardStructObjectInspector(rowColumnNameList, structUdfObjectInspectorList); String structUdfTypeName = structUdfObjectInspector.getTypeName(); TypeInfo structUdfTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(structUdfTypeName); FunctionInfo fi = FunctionRegistry.getFunctionInfo(structFuncText); GenericUDF genericUDF = fi.getGenericUDF(); ExprNodeDesc col1Expr =
if (FunctionRegistry.isOpAnd(expr)) { exprInfo.convertedExpr : expr); return; } else if (!FunctionRegistry.isOpAnd(expr) && HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVEPPDREMOVEDUPLICATEFILTERS)) { ctx.addNonFinalCandidate(exprInfo != null ? exprInfo.alias : null, expr);