[
https://issues.apache.org/jira/browse/PHOENIX-1956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
James Taylor updated PHOENIX-1956:
----------------------------------
Attachment: PHOENIX-1956.patch
Good find, [~rajeshbabu]. Here's a patch.
> SELECT (FALSE OR FALSE) RETURNS TRUE
> ------------------------------------
>
> Key: PHOENIX-1956
> URL: https://issues.apache.org/jira/browse/PHOENIX-1956
> Project: Phoenix
> Issue Type: Bug
> Reporter: Rajeshbabu Chintaguntla
> Assignee: Rajeshbabu Chintaguntla
> Fix For: 5.0.0, 4.4.0
>
> Attachments: PHOENIX-1956.patch
>
>
> SELECT (FALSE OR FALSE) AS B FROM SYSTEM.CATALOG LIMIT 1;
> ------------
> B
> ------------
> true
> ------------
> 1 row selected (0.026 seconds)
> But actually it should return false.
> When a child of the expression is false boolean literal it will be removed
> from the list. When children is empty we are returning true literal
> expression but we should return false literal.
> Here is the code from ExpressionCompiler.
> {code}
> private Expression orExpression(List<Expression> children) throws
> SQLException {
> Iterator<Expression> iterator = children.iterator();
> Determinism determinism = Determinism.ALWAYS;
> while (iterator.hasNext()) {
> Expression child = iterator.next();
> if (child.getDataType() != PBoolean.INSTANCE) {
> throw TypeMismatchException.newException(PBoolean.INSTANCE,
> child.getDataType(), child.toString());
> }
> if (LiteralExpression.isFalse(child)) {
> iterator.remove();
> }
> if (LiteralExpression.isTrue(child)) {
> return child;
> }
> determinism = determinism.combine(child.getDeterminism());
> }
> if (children.size() == 0) {
> return LiteralExpression.newConstant(true, determinism);
> }
> if (children.size() == 1) {
> return children.get(0);
> }
> return new OrExpression(children);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)