All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jp.co.yahoo.yosegi.hive.pushdown.HiveExprFactory Maven / Gradle / Ivy

There is a newer version: 2.0.6_hive-1.2.1000.2.6.4.0-91
Show newest version
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jp.co.yahoo.yosegi.hive.pushdown; import jp.co.yahoo.yosegi.spread.column.filter.NumberFilterType; import jp.co.yahoo.yosegi.spread.column.filter.StringCompareFilterType; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; import org.apache.hadoop.hive.ql.udf.UDFLike; import org.apache.hadoop.hive.ql.udf.generic.GenericUDF; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBetween; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFIn; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFIndex; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqual; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualOrGreaterThan; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualOrLessThan; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPLessThan; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotNull; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNull; import java.util.List; public final class HiveExprFactory { private HiveExprFactory() {} /** * Convert Hive's filter condition to IHiveExprNode. */ public static IHiveExprNode get( final ExprNodeGenericFuncDesc exprNodeDesc , final GenericUDF udf , final List 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(); } /** * Create a corresponding IHiveExprNode from the UDF class name. */ public static IHiveExprNode getFromUdfClassName( final Class udf , final List childNodeDesc ) { if ( UDFLike.class.getName() == udf.getName() ) { return new RegexpHiveExpr( childNodeDesc ); } return new UnsupportHiveExpr(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy