Java Code Examples for org.apache.hadoop.hive.ql.io.sarg.PredicateLeaf#Type

The following examples show how to use org.apache.hadoop.hive.ql.io.sarg.PredicateLeaf#Type . 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: OrcTableSource.java    From flink with Apache License 2.0 6 votes vote down vote up
private PredicateLeaf.Type toOrcType(TypeInformation<?> type) {
	if (type == BasicTypeInfo.BYTE_TYPE_INFO ||
		type == BasicTypeInfo.SHORT_TYPE_INFO ||
		type == BasicTypeInfo.INT_TYPE_INFO ||
		type == BasicTypeInfo.LONG_TYPE_INFO) {
		return PredicateLeaf.Type.LONG;
	} else if (type == BasicTypeInfo.FLOAT_TYPE_INFO ||
		type == BasicTypeInfo.DOUBLE_TYPE_INFO) {
		return PredicateLeaf.Type.FLOAT;
	} else if (type == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
		return PredicateLeaf.Type.BOOLEAN;
	} else if (type == BasicTypeInfo.STRING_TYPE_INFO) {
		return PredicateLeaf.Type.STRING;
	} else if (type == SqlTimeTypeInfo.TIMESTAMP) {
		return PredicateLeaf.Type.TIMESTAMP;
	} else if (type == SqlTimeTypeInfo.DATE) {
		return PredicateLeaf.Type.DATE;
	} else if (type == BasicTypeInfo.BIG_DEC_TYPE_INFO) {
		return PredicateLeaf.Type.DECIMAL;
	} else {
		// unsupported type
		return null;
	}
}
 
Example 2
Source File: OrcTableSource.java    From flink with Apache License 2.0 5 votes vote down vote up
private PredicateLeaf.Type getLiteralType(BinaryComparison comp) {
	if (literalOnRight(comp)) {
		return toOrcType(((Literal) comp.right()).resultType());
	} else {
		return toOrcType(((Literal) comp.left()).resultType());
	}
}
 
Example 3
Source File: OrcTableSource.java    From flink with Apache License 2.0 5 votes vote down vote up
private PredicateLeaf.Type getLiteralType(BinaryComparison comp) {
	if (literalOnRight(comp)) {
		return toOrcType(((Literal) comp.right()).resultType());
	} else {
		return toOrcType(((Literal) comp.left()).resultType());
	}
}
 
Example 4
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
BinaryPredicate(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType);
	this.literal = literal;
}
 
Example 5
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
ColumnPredicate(String columnName, PredicateLeaf.Type literalType) {
	this.columnName = columnName;
	this.literalType = literalType;
}
 
Example 6
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
BinaryPredicate(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType);
	this.literal = literal;
}
 
Example 7
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
BinaryPredicate(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType);
	this.literal = literal;
}
 
Example 8
Source File: HiveORCSearchArgumentBuilder.java    From pxf with Apache License 2.0 4 votes vote down vote up
/**
 * Builds a single argument
 *
 * @param operatorNode the operatorNode node
 * @return true if the argument is build, false otherwise
 */
private boolean buildArgument(OperatorNode operatorNode) {

    Operator operator = operatorNode.getOperator();
    ColumnIndexOperandNode columnIndexOperand = operatorNode.getColumnIndexOperand();
    OperandNode valueOperandNode = operatorNode.getValueOperand();

    ColumnDescriptor filterColumn = columnDescriptors.get(columnIndexOperand.index());
    String filterColumnName = filterColumn.columnName();
    Object filterValue = null;

    // In Hive 1, boxing of values happened inside the builder
    // For Hive 2 libraries, we need to do it before passing values to
    // Hive jars

    if (valueOperandNode instanceof CollectionOperandNode) {
        CollectionOperandNode collectionOperand = (CollectionOperandNode) valueOperandNode;

        filterValue = collectionOperand
                .getData()
                .stream()
                .map(data -> boxLiteral(convertDataType(collectionOperand.getDataType().getTypeElem(), data)))
                .collect(Collectors.toList());
    } else if (valueOperandNode instanceof ScalarOperandNode) {
        ScalarOperandNode scalarOperand = (ScalarOperandNode) valueOperandNode;

        filterValue = convertDataType(scalarOperand);
        filterValue = boxLiteral(filterValue);
    }

    PredicateLeaf.Type predicateLeafType = PredicateLeaf.Type.STRING;

    if (filterValue != null) {
        predicateLeafType = getType(filterValue);
    }

    if (operator == Operator.NOOP) {
        // NOT boolean wraps a NOOP
        //       NOT
        //        |
        //       NOOP
        //        |
        //    ---------
        //   |         |
        //   4        true
        // that needs to be replaced with equals

        // also IN
        operator = Operator.EQUALS;
    }

    switch (operator) {
        case LESS_THAN:
            filterBuilder.lessThan(filterColumnName, predicateLeafType, filterValue);
            break;
        case GREATER_THAN:
            filterBuilder.startNot().lessThanEquals(filterColumnName, predicateLeafType, filterValue).end();
            break;
        case LESS_THAN_OR_EQUAL:
            filterBuilder.lessThanEquals(filterColumnName, predicateLeafType, filterValue);
            break;
        case GREATER_THAN_OR_EQUAL:
            filterBuilder.startNot().lessThan(filterColumnName, predicateLeafType, filterValue).end();
            break;
        case EQUALS:
            filterBuilder.equals(filterColumnName, predicateLeafType, filterValue);
            break;
        case NOT_EQUALS:
            filterBuilder.startNot().equals(filterColumnName, predicateLeafType, filterValue).end();
            break;
        case IS_NULL:
            filterBuilder.isNull(filterColumnName, predicateLeafType);
            break;
        case IS_NOT_NULL:
            filterBuilder.startNot().isNull(filterColumnName, predicateLeafType).end();
            break;
        case IN:
            if (filterValue instanceof Collection) {
                @SuppressWarnings("unchecked")
                Collection<Object> l = (Collection<Object>) filterValue;
                filterBuilder.in(filterColumnName, predicateLeafType, l.toArray(new Object[0]));
            } else {
                throw new IllegalArgumentException("filterValue should be instance of List for IN operation");
            }
            break;
        default: {
            LOG.debug("Filter push-down is not supported for {} operation.", operator);
            return false;
        }
    }
    return true;
}
 
Example 9
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an IN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literals.
 * @param literals The literal values to check the column against.
 */
public In(String columnName, PredicateLeaf.Type literalType, Serializable... literals) {
	super(columnName, literalType);
	this.literals = literals;
}
 
Example 10
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a LESS_THAN_EQUALS predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public LessThanEquals(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 11
Source File: OrcSplitReader.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a LESS_THAN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public LessThan(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 12
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a null-safe EQUALS predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public NullSafeEquals(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 13
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an EQUALS predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public Equals(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 14
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an BETWEEN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literals.
 * @param lowerBound The literal value of the (inclusive) lower bound to check the column against.
 * @param upperBound The literal value of the (inclusive) upper bound to check the column against.
 */
public Between(String columnName, PredicateLeaf.Type literalType, Serializable lowerBound, Serializable upperBound) {
	super(columnName, literalType);
	this.lowerBound = lowerBound;
	this.upperBound = upperBound;
}
 
Example 15
Source File: OrcSplitReader.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an BETWEEN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literals.
 * @param lowerBound The literal value of the (inclusive) lower bound to check the column against.
 * @param upperBound The literal value of the (inclusive) upper bound to check the column against.
 */
public Between(String columnName, PredicateLeaf.Type literalType, Serializable lowerBound, Serializable upperBound) {
	super(columnName, literalType);
	this.lowerBound = lowerBound;
	this.upperBound = upperBound;
}
 
Example 16
Source File: OrcSplitReader.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a LESS_THAN_EQUALS predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public LessThanEquals(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 17
Source File: OrcSplitReader.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an IN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literals.
 * @param literals The literal values to check the column against.
 */
public In(String columnName, PredicateLeaf.Type literalType, Serializable... literals) {
	super(columnName, literalType);
	this.literals = literals;
}
 
Example 18
Source File: OrcSplitReader.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an IS_NULL predicate.
 *
 * @param columnName The column to check for null.
 * @param literalType The type of the column to check for null.
 */
public IsNull(String columnName, PredicateLeaf.Type literalType) {
	super(columnName, literalType);
}
 
Example 19
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an EQUALS predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literal.
 * @param literal The literal value to check the column against.
 */
public Equals(String columnName, PredicateLeaf.Type literalType, Serializable literal) {
	super(columnName, literalType, literal);
}
 
Example 20
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an BETWEEN predicate.
 *
 * @param columnName The column to check.
 * @param literalType The type of the literals.
 * @param lowerBound The literal value of the (inclusive) lower bound to check the column against.
 * @param upperBound The literal value of the (inclusive) upper bound to check the column against.
 */
public Between(String columnName, PredicateLeaf.Type literalType, Serializable lowerBound, Serializable upperBound) {
	super(columnName, literalType);
	this.lowerBound = lowerBound;
	this.upperBound = upperBound;
}