org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge Java Examples
The following examples show how to use
org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiveFunctionRegistry.java From dremio-oss with Apache License 2.0 | 6 votes |
private HiveFuncHolder matchAndCreateUDFHolder(String udfName, Class<? extends UDF> udfClazz, CompleteType[] argTypes, ObjectInspector[] argOIs) { try { GenericUDF udfInstance = new GenericUDFBridge(udfName, false/* is operator */, udfClazz.getName()); ObjectInspector returnOI = udfInstance.initialize(argOIs); return new HiveFuncHolder( udfName, udfClazz, argTypes, returnOI, CompleteType.fromMinorType(ObjectInspectorHelper.getMinorType(returnOI)), nonDeterministicUDFs.contains(udfClazz)); } catch (Exception e) { /*ignore this*/ } return null; }
Example #2
Source File: HiveUDFImplementor.java From marble with Apache License 2.0 | 5 votes |
public static GenericUDF newGenericUDF(String opName, SqlSyntax syntax) { if (opName.equals("NOT RLIKE")) { //we use a RexImpTable.NotImplementor to wrapper a HiveUDFImplementor , // so `NOT RLIKE` and `RLIKE` would be treated as same here opName = "RLIKE"; } if (opName.equals("NOT REGEXP")) { opName = "REGEXP"; } Class hiveUDFClazz = HiveSqlOperatorTable.instance() .getHiveUDFClass(opName, syntax); if (GenericUDF.class.isAssignableFrom(hiveUDFClazz)) { try { return (GenericUDF) hiveUDFClazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException( "fail to new instance for class " + hiveUDFClazz, e); } } else if (UDF.class.isAssignableFrom(hiveUDFClazz)) { return new GenericUDFBridge(opName, false, hiveUDFClazz.getName()); } else { throw new IllegalArgumentException("unknown hive udf class for opName=" + opName + ",and syntax=" + syntax); } }
Example #3
Source File: HiveFuncHolder.java From dremio-oss with Apache License 2.0 | 5 votes |
private JInvocation getUDFInstance(JCodeModel m) { if (isGenericUDF) { return JExpr._new(m.directClass(genericUdfClazz.getCanonicalName())); } else { return JExpr._new(m.directClass(GenericUDFBridge.class.getCanonicalName())) .arg(JExpr.lit(udfName)) .arg(JExpr.lit(false)) .arg(JExpr.lit(udfClazz.getCanonicalName().toString())); } }
Example #4
Source File: HiveExprFactory.java From multiple-dimension-spread with Apache License 2.0 | 4 votes |
public static IHiveExprNode get( final ExprNodeGenericFuncDesc exprNodeDesc , final GenericUDF udf , final List<ExprNodeDesc> childNodeDesc ){ if( udf instanceof GenericUDFBridge ){ return getFromUdfClassName( ( (GenericUDFBridge)udf ).getUdfClass() , childNodeDesc ); } if( udf instanceof GenericUDFOPEqual ){ return new EqualsHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFOPNotEqual ){ return new NotEqualsHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFOPNotNull ){ return new NotNullHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFIn ){ return new InHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFBetween ){ return new BetweenHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFOPNull ){ return new NullHiveExpr( childNodeDesc ); } else if( udf instanceof GenericUDFIndex ){ return new BooleanHiveExpr( exprNodeDesc , (GenericUDFIndex)udf ); } else if( udf instanceof GenericUDFOPEqualOrLessThan ){ return new CompareHiveExpr( childNodeDesc , StringCompareFilterType.LE , NumberFilterType.LE ); } else if( udf instanceof GenericUDFOPLessThan ){ return new CompareHiveExpr( childNodeDesc , StringCompareFilterType.LT , NumberFilterType.LT ); } else if( udf instanceof GenericUDFOPEqualOrGreaterThan ){ return new CompareHiveExpr( childNodeDesc , StringCompareFilterType.GE , NumberFilterType.GE ); } else if( udf instanceof GenericUDFOPGreaterThan ){ return new CompareHiveExpr( childNodeDesc , StringCompareFilterType.GT , NumberFilterType.GT ); } return new UnsupportHiveExpr(); }
Example #5
Source File: HiveFuncHolder.java From dremio-oss with Apache License 2.0 | 3 votes |
/** * Create holder for UDF * @param udfName name of the UDF class * @param udfClazz UDF implementation class * @param argTypes * @param returnOI * @param returnType */ public HiveFuncHolder(String udfName, Class< ? extends UDF> udfClazz, CompleteType[] argTypes, ObjectInspector returnOI, CompleteType returnType, boolean isRandom) { this(GenericUDFBridge.class, argTypes, returnOI, returnType, isRandom); this.isGenericUDF = false; this.udfClazz = udfClazz; this.udfName = udfName; }