Skip to content

Commit

Permalink
parser: lowercase timespans in extract
Browse files Browse the repository at this point in the history
The `extract` builtin is kind of weird - it is actually supported by the
parser and not an ordinary builtin function that people can call without
parser support. As such, we can normalize its inputs right in the
parser.

The benefit of this is that, later, we are going to unconditionally
ToLower() the string arguments to extract - which costs an allocation.
So we can do this normalization up front to save a bunch of allocations
in queries that run `extract` over a lot of data rows.

Release note (performance improvement): improve the allocation
performance of workloads that use the `EXTRACT` builtin.
  • Loading branch information
jordanlewis committed Jan 29, 2021
1 parent 58a7d76 commit 8d30d35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -11453,7 +11453,7 @@ array_expr_list:
extract_list:
extract_arg FROM a_expr
{
$$.val = tree.Exprs{tree.NewStrVal($1), $3.expr()}
$$.val = tree.Exprs{tree.NewStrVal(strings.ToLower($1)), $3.expr()}
}
| expr_list
{
Expand Down

0 comments on commit 8d30d35

Please sign in to comment.