Skip to content

Commit

Permalink
Added EXTRACT(<time unit> FROM <date/datetime/time col) as partition …
Browse files Browse the repository at this point in the history
…pruning function (#18456)
  • Loading branch information
mjonss authored Oct 16, 2024
1 parent 59a2f82 commit a62679f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions partition-pruning.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ If the `fn` function is monotonous, for any `x` and `y`, if `x > y`, then `fn(x)

* [`UNIX_TIMESTAMP()`](/functions-and-operators/date-and-time-functions.md)
* [`TO_DAYS()`](/functions-and-operators/date-and-time-functions.md)
* [`EXTRACT(<time unit> FROM <DATETIME/DATE/TIME column>)`](/functions-and-operators/date-and-time-functions.md). For `DATE` and `DATETIME` columns, `YEAR` and `YEAR_MONTH` time units are considered monotonous functions. For the `TIME` column, `HOUR`, `HOUR_MINUTE`, `HOUR_SECOND` and `HOUR_MICROSECOND` are considered monotonous functions. Note that `WEEK` is not supported as time unit in `EXTRACT` for partition pruning.

For example, partition pruning takes effect when the partition expression is in the form of `fn(col)`, where the `fn` is monotonous function `to_days`:

Expand Down
1 change: 1 addition & 0 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@ Currently, partition pruning does not work with `LIKE` conditions.

* [`UNIX_TIMESTAMP()`](/functions-and-operators/date-and-time-functions.md)
* [`TO_DAYS()`](/functions-and-operators/date-and-time-functions.md)
* [`EXTRACT(<time unit> FROM <DATETIME/DATE/TIME column>)`](/functions-and-operators/date-and-time-functions.md). For `DATE` and `DATETIME` columns, `YEAR` and `YEAR_MONTH` time units are considered monotonous functions. For the `TIME` column, `HOUR`, `HOUR_MINUTE`, `HOUR_SECOND` and `HOUR_MICROSECOND` are considered monotonous functions. Note that `WEEK` is not supported as time unit in `EXTRACT` for partition pruning.

For example, the partition expression is a simple column:

Expand Down

0 comments on commit a62679f

Please sign in to comment.