-
Notifications
You must be signed in to change notification settings - Fork 24.2k
/
BinaryLogic.java
42 lines (35 loc) · 1.63 KB
/
BinaryLogic.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.expression.predicate.logical;
import org.elasticsearch.xpack.sql.expression.Expression;
import org.elasticsearch.xpack.sql.expression.Expressions;
import org.elasticsearch.xpack.sql.expression.gen.pipeline.Pipe;
import org.elasticsearch.xpack.sql.expression.predicate.BinaryOperator;
import org.elasticsearch.xpack.sql.expression.predicate.logical.BinaryLogicProcessor.BinaryLogicOperation;
import org.elasticsearch.xpack.sql.tree.Location;
import org.elasticsearch.xpack.sql.type.DataType;
public abstract class BinaryLogic extends BinaryOperator<Boolean, Boolean, Boolean, BinaryLogicOperation> {
protected BinaryLogic(Location location, Expression left, Expression right, BinaryLogicOperation operation) {
super(location, left, right, operation);
}
@Override
public DataType dataType() {
return DataType.BOOLEAN;
}
@Override
protected TypeResolution resolveInputType(Expression e, Expressions.ParamOrdinal paramOrdinal) {
return Expressions.typeMustBeBoolean(e, functionName(), paramOrdinal);
}
@Override
protected Pipe makePipe() {
return new BinaryLogicPipe(location(), this, Expressions.pipe(left()), Expressions.pipe(right()), function());
}
@Override
public boolean nullable() {
// Cannot fold null due to 3vl, constant folding will do any possible folding.
return false;
}
}