select: Return early from bool AND, OR (#13914)

Return as soon as an AND fails and whenever an OR succeeds. Faster and more flexible.

For example makes `select * from S3object where _2 != '' AND _2 > 1` able to operate on empty fields.

Followup to #13900
This commit is contained in:
Klaus Post
2021-12-15 16:47:21 -08:00
committed by GitHub
parent da540ccf8c
commit 91f72f25ab
2 changed files with 14 additions and 0 deletions

View File

@@ -69,6 +69,9 @@ func (e *Expression) evalNode(r Record, tableAlias string) (*Value, error) {
if !ok {
return nil, errExpectedBool
}
if b {
return FromBool(true), nil
}
result = result || b
}
return FromBool(result), nil
@@ -91,6 +94,9 @@ func (e *AndCondition) evalNode(r Record, tableAlias string) (*Value, error) {
if !ok {
return nil, errExpectedBool
}
if !b {
return FromBool(false), nil
}
result = result && b
}
return FromBool(result), nil