-
Notifications
You must be signed in to change notification settings - Fork 504
Bring EXTRACT into alignment with PostgreSQL v14 #10027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3a3e978
Bring EXTRACT into alignment with PostgreSQL v14
jkosh44 d155340
Clean up generics with DecimalLike
jkosh44 fbce708
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 c4cced3
Remove unnecessary nanoseconds from DateLike epoch
jkosh44 1d9cfb2
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 2158f75
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 7d5c5c1
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 a43a0dd
Fix user docs
jkosh44 92b9213
Remove mention of Ingres and date_part from extract docs
jkosh44 d6b93f0
Hoist generics up a level
jkosh44 e5f4345
Pushed unwrapping Datums down where possible
jkosh44 70317bd
Remove Ingres from and SQL standard from date-part docs
jkosh44 8733cf1
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 3fc700d
Remove alias from docs
jkosh44 b4c9906
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 bd496cd
Fix release notes
jkosh44 de66b42
Merge branch 'main' of github.com:MaterializeInc/materialize into jko…
jkosh44 1ea3baa
Fix lint issues
jkosh44 bcbfec7
Add date-part diagram
jkosh44 7faaf6f
Fix date-part test
jkosh44 b9ad09a
Fix test error msg
jkosh44 45b95cc
Fix release notes link
jkosh44 010d994
Fix testdrive
jkosh44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| title: "date_part Function" | ||
| description: "Returns a specified time component from a time-based value" | ||
| menu: | ||
| main: | ||
| parent: 'sql-functions' | ||
| --- | ||
|
|
||
| `date_part` returns some time component from a time-based value, such as the year from a Timestamp. | ||
| It is mostly functionally equivalent to the function [`EXTRACT`](../extract), except to maintain | ||
| PostgreSQL compatibility, `date_part` returns values of type [`float`](../../types/float). This can | ||
| result in a loss of precision in certain uses. Using [`EXTRACT`](../extract) is recommended instead. | ||
|
|
||
| ## Signatures | ||
|
|
||
| {{< diagram "func-date-part.svg" >}} | ||
|
|
||
| Parameter | Type | Description | ||
| ----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|------------ | ||
| _val_ | [`time`](../../types/time), [`timestamp`](../../types/timestamp), [`timestamp with time zone`](../../types/timestamptz), [`interval`](../../types/interval), [`date`](../../types/date) | The value from which you want to extract a component. vals of type [`date`](../../types/date) are first cast to type [`timestamp`](../../types/timestamp). | ||
|
|
||
| ### Arguments | ||
|
|
||
| `date_part` supports multiple synonyms for most time periods. | ||
|
|
||
| Time period | Synonyms | ||
| ------------|--------- | ||
| epoch | `EPOCH` | ||
| millennium | `MIL`, `MILLENNIUM`, `MILLENNIA` | ||
| century | `C`, `CENT`, `CENTURY`, `CENTURIES` | ||
| decade | `DEC`, `DECS`, `DECADE`, `DECADES` | ||
| year | `Y`, `YEAR`, `YEARS`, `YR`, `YRS` | ||
| quarter | `QTR`, `QUARTER` | ||
| month | `MON`, `MONS`, `MONTH`, `MONTHS` | ||
| week | `W`, `WEEK`, `WEEKS` | ||
| day | `D`, `DAY`, `DAYS` | ||
| hour |`H`, `HR`, `HRS`, `HOUR`, `HOURS` | ||
| minute | `M`, `MIN`, `MINS`, `MINUTE`, `MINUTES` | ||
| second | `S`, `SEC`, `SECS`, `SECOND`, `SECONDS` | ||
| microsecond | `US`, `USEC`, `USECS`, `USECONDS`, `MICROSECOND`, `MICROSECONDS` | ||
| millisecond | `MS`, `MSEC`, `MSECS`, `MSECONDS`, `MILLISECOND`, `MILLISECONDS` | ||
| day of week |`DOW` | ||
| ISO day of week | `ISODOW` | ||
| day of year | `DOY` | ||
|
|
||
| ### Return value | ||
|
|
||
| `date_part` returns a [`float`](../../types/float) value. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Extract second from timestamptz | ||
|
|
||
| ```sql | ||
| SELECT date_part('S', TIMESTAMP '2006-01-02 15:04:05.06') | ||
| AS sec_extr; | ||
| ``` | ||
| ```nofmt | ||
| sec_extr | ||
| ---------- | ||
| 5.06 | ||
| ``` | ||
|
|
||
| ### Extract century from date | ||
|
|
||
| ```sql | ||
| SELECT date_part('CENTURIES', DATE '2006-01-02') | ||
| AS sec_extr; | ||
| ``` | ||
| ```nofmt | ||
| sec_extr | ||
| ---------- | ||
| 21 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.