S3 Select: Parsing tweaks (#8261)

* Don't output empty lines.
* Trim whitespace from byte to int/float/bool conversions.
This commit is contained in:
Klaus Post
2019-09-17 17:21:23 -07:00
committed by Harshavardhana
parent cb01516a26
commit dac1cf5a9a
4 changed files with 490 additions and 20 deletions

View File

@@ -219,11 +219,12 @@ func (e *SelectStatement) AggregateRow(input Record) error {
// Eval - evaluates the Select statement for the given record. It
// applies only to non-aggregation queries.
func (e *SelectStatement) Eval(input, output Record) error {
// The function returns whether the statement passed the WHERE clause and should be outputted.
func (e *SelectStatement) Eval(input, output Record) (bool, error) {
ok, err := e.isPassingWhereClause(input)
if err != nil || !ok {
// Either error or row did not pass where clause
return err
return false, err
}
if e.selectAST.Expression.All {
@@ -234,13 +235,13 @@ func (e *SelectStatement) Eval(input, output Record) error {
if e.limitValue > -1 {
e.outputCount++
}
return output.CopyFrom(input)
return true, output.CopyFrom(input)
}
for i, expr := range e.selectAST.Expression.Expressions {
v, err := expr.evalNode(input)
if err != nil {
return err
return false, err
}
// Pick output column names
@@ -258,7 +259,7 @@ func (e *SelectStatement) Eval(input, output Record) error {
e.outputCount++
}
return nil
return true, nil
}
// LimitReached - returns true if the number of records output has