Skip to content

Commit

Permalink
Merge pull request #4724 from szarnyasg/nits-20250206b
Browse files Browse the repository at this point in the history
Nits 20250206b
  • Loading branch information
szarnyasg authored Feb 6, 2025
2 parents 8341c16 + 4ca2030 commit 76b7986
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 53 deletions.
13 changes: 8 additions & 5 deletions community_extensions/download_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ PIVOT (
UNPIVOT (
FROM read_json([
printf('https://community-extensions.duckdb.org/download-stats-weekly/%s.json',
strftime(x, '%Y/%W'))
FOR x IN range(TIMESTAMP '2024-10-01', now()::TIMESTAMP, INTERVAL 1 WEEK)
strftime(x, '%Y/%W')
)
FOR x
IN range(TIMESTAMP '2024-10-01', now()::TIMESTAMP, INTERVAL 1 WEEK)
IF strftime(x, '%W') != '53'
])
)
ON COLUMNS(* EXCLUDE _last_update)
INTO NAME extension VALUE tot
INTO NAME extension VALUE downloads
)
ON date_trunc('day',_last_update)
USING any_value(tot)
ON date_trunc('day', _last_update)
USING any_value(downloads)
ORDER BY extension;
```
2 changes: 1 addition & 1 deletion docs/sql/functions/date.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Dates can also be manipulated with the [timestamp functions]({% link docs/sql/fu
<div class="nostroke_table"></div>

| **Description** | Converts a date to a string according to the [format string]({% link docs/sql/functions/dateformat.md %}). |
| **Example** | `strftime(date '1992-01-01', '%a, %-d %B %Y')` |
| **Example** | `strftime(DATE '1992-01-01', '%a, %-d %B %Y')` |
| **Result** | `Wed, 1 January 1992` |

#### `time_bucket(bucket_width, date[, offset])`
Expand Down
92 changes: 46 additions & 46 deletions docs/sql/functions/datepart.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ The examples are the corresponding parts of the timestamp `2021-08-03 11:59:44.1

| Specifier | Description | Synonyms | Example |
|:--|:--|:---|:-|
| `'century'` | Gregorian century | `'cent'`, `'centuries'`, `'c'` | `21` |
| `'day'` | Gregorian day | `'days'`, `'d'`, `'dayofmonth'` | `3` |
| `'decade'` | Gregorian decade | `'dec'`, `'decades'`, `'decs'` | `202` |
| `'hour'` | Hours | `'hr'`, `'hours'`, `'hrs'`, `'h'` | `11` |
| `'microseconds'` | Sub-minute microseconds | `'microsecond'`, `'us'`, `'usec'`, `'usecs'`, `'usecond'`, `'useconds'` | `44123456` |
| `'millennium'` | Gregorian millennium | `'mil'`, `'millenniums'`, `'millenia'`, `'mils'`, `'millenium'` | `3` |
| `'milliseconds'` | Sub-minute milliseconds | `'millisecond'`, `'ms'`, `'msec'`, `'msecs'`, `'msecond'`, `'mseconds'` | `44123` |
| `'minute'` | Minutes | `'min'`, `'minutes'`, `'mins'`, `'m'` | `59` |
| `'month'` | Gregorian month | `'mon'`, `'months'`, `'mons'` | `8` |
| `'quarter'` | Quarter of the year (1-4) | `'quarters'` | `3` |
| `'second'` | Seconds | `'sec'`, `'seconds'`, `'secs'`, `'s'` | `44` |
| `'year'` | Gregorian year | `'yr'`, `'y'`, `'years'`, `'yrs'` | `2021` |
| `century` | Gregorian century | `cent`, `centuries`, `c` | `21` |
| `day` | Gregorian day | `days`, `d`, `dayofmonth` | `3` |
| `decade` | Gregorian decade | `dec`, `decades`, `decs` | `202` |
| `hour` | Hours | `hr`, `hours`, `hrs`, `h` | `11` |
| `microseconds` | Sub-minute microseconds | `microsecond`, `us`, `usec`, `usecs`, `usecond`, `useconds` | `44123456` |
| `millennium` | Gregorian millennium | `mil`, `millenniums`, `millenia`, `mils`, `millenium` | `3` |
| `milliseconds` | Sub-minute milliseconds | `millisecond`, `ms`, `msec`, `msecs`, `msecond`, `mseconds` | `44123` |
| `minute` | Minutes | `min`, `minutes`, `mins`, `m` | `59` |
| `month` | Gregorian month | `mon`, `months`, `mons` | `8` |
| `quarter` | Quarter of the year (1-4) | `quarters` | `3` |
| `second` | Seconds | `sec`, `seconds`, `secs`, `s` | `44` |
| `year` | Gregorian year | `yr`, `y`, `years`, `yrs` | `2021` |

## Part Specifiers Only Usable as Date Part Specifiers

| Specifier | Description | Synonyms | Example |
|:--|:--|:---|:-|
| `'dayofweek'` | Day of the week (Sunday = 0, Saturday = 6) | `'weekday'`, `'dow'` | `2` |
| `'dayofyear'` | Day of the year (1-365/366) | `'doy'` | `215` |
| `'epoch'` | Seconds since 1970-01-01 | | `1627991984` |
| `'era'` | Gregorian era (CE/AD, BCE/BC) | | `1` |
| `'isodow'` | ISO day of the week (Monday = 1, Sunday = 7) | | `2` |
| `'isoyear'` | ISO Year number (Starts on Monday of week containing Jan 4th) | | `2021` |
| `'timezone_hour'` | Time zone offset hour portion | | `0` |
| `'timezone_minute'` | Time zone offset minute portion | | `0` |
| `'timezone'` | Time zone offset in seconds | | `0` |
| `'week'` | Week number | `'weeks'`, `'w'` | `31` |
| `'yearweek'` | ISO year and week number in `YYYYWW` format | | `202131` |

Note that the time zone parts are all zero unless a time zone plugin such as ICU
| `dayofweek` | Day of the week (Sunday = 0, Saturday = 6) | `weekday`, `dow` | `2` |
| `dayofyear` | Day of the year (1-365/366) | `doy` | `215` |
| `epoch` | Seconds since 1970-01-01 | | `1627991984` |
| `era` | Gregorian era (CE/AD, BCE/BC) | | `1` |
| `isodow` | ISO day of the week (Monday = 1, Sunday = 7) | | `2` |
| `isoyear` | ISO Year number (Starts on Monday of week containing Jan 4th) | | `2021` |
| `timezone_hour` | Time zone offset hour portion | | `0` |
| `timezone_minute` | Time zone offset minute portion | | `0` |
| `timezone` | Time zone offset in seconds | | `0` |
| `week` | Week number | `weeks`, `w` | `31` |
| `yearweek` | ISO year and week number in `YYYYWW` format | | `202131` |

Note that the time zone parts are all zero unless a time zone extension such as [ICU]({% link docs/extensions/icu.md %})
has been installed to support `TIMESTAMP WITH TIME ZONE`.

## Part Functions
Expand Down Expand Up @@ -85,63 +85,63 @@ There are dedicated extraction functions to get certain subfields:
<div class="nostroke_table"></div>

| **Description** | Century. |
| **Example** | `century(date '1992-02-15')` |
| **Example** | `century(DATE '1992-02-15')` |
| **Result** | `20` |

#### `day(date)`

<div class="nostroke_table"></div>

| **Description** | Day. |
| **Example** | `day(date '1992-02-15')` |
| **Example** | `day(DATE '1992-02-15')` |
| **Result** | `15` |

#### `dayofmonth(date)`

<div class="nostroke_table"></div>

| **Description** | Day (synonym). |
| **Example** | `dayofmonth(date '1992-02-15')` |
| **Example** | `dayofmonth(DATE '1992-02-15')` |
| **Result** | `15` |

#### `dayofweek(date)`

<div class="nostroke_table"></div>

| **Description** | Numeric weekday (Sunday = 0, Saturday = 6). |
| **Example** | `dayofweek(date '1992-02-15')` |
| **Example** | `dayofweek(DATE '1992-02-15')` |
| **Result** | `6` |

#### `dayofyear(date)`

<div class="nostroke_table"></div>

| **Description** | Day of the year (starts from 1, i.e., January 1 = 1). |
| **Example** | `dayofyear(date '1992-02-15')` |
| **Example** | `dayofyear(DATE '1992-02-15')` |
| **Result** | `46` |

#### `decade(date)`

<div class="nostroke_table"></div>

| **Description** | Decade (year / 10). |
| **Example** | `decade(date '1992-02-15')` |
| **Example** | `decade(DATE '1992-02-15')` |
| **Result** | `199` |

#### `epoch(date)`

<div class="nostroke_table"></div>

| **Description** | Seconds since 1970-01-01. |
| **Example** | `epoch(date '1992-02-15')` |
| **Example** | `epoch(DATE '1992-02-15')` |
| **Result** | `698112000` |

#### `era(date)`

<div class="nostroke_table"></div>

| **Description** | Calendar era. |
| **Example** | `era(date '0044-03-15 (BC)')` |
| **Example** | `era(DATE '0044-03-15 (BC)')` |
| **Result** | `0` |

#### `hour(date)`
Expand All @@ -157,15 +157,15 @@ There are dedicated extraction functions to get certain subfields:
<div class="nostroke_table"></div>

| **Description** | Numeric ISO weekday (Monday = 1, Sunday = 7). |
| **Example** | `isodow(date '1992-02-15')` |
| **Example** | `isodow(DATE '1992-02-15')` |
| **Result** | `6` |

#### `isoyear(date)`

<div class="nostroke_table"></div>

| **Description** | ISO Year number (Starts on Monday of week containing Jan 4th). |
| **Example** | `isoyear(date '2022-01-01')` |
| **Example** | `isoyear(DATE '2022-01-01')` |
| **Result** | `2021` |

#### `microsecond(date)`
Expand All @@ -181,7 +181,7 @@ There are dedicated extraction functions to get certain subfields:
<div class="nostroke_table"></div>

| **Description** | Millennium. |
| **Example** | `millennium(date '1992-02-15')` |
| **Example** | `millennium(DATE '1992-02-15')` |
| **Result** | `2` |

#### `millisecond(date)`
Expand All @@ -205,15 +205,15 @@ There are dedicated extraction functions to get certain subfields:
<div class="nostroke_table"></div>

| **Description** | Month. |
| **Example** | `month(date '1992-02-15')` |
| **Example** | `month(DATE '1992-02-15')` |
| **Result** | `2` |

#### `quarter(date)`

<div class="nostroke_table"></div>

| **Description** | Quarter. |
| **Example** | `quarter(date '1992-02-15')` |
| **Example** | `quarter(DATE '1992-02-15')` |
| **Result** | `1` |

#### `second(date)`
Expand All @@ -229,61 +229,61 @@ There are dedicated extraction functions to get certain subfields:
<div class="nostroke_table"></div>

| **Description** | Time zone offset hour portion. |
| **Example** | `timezone_hour(date '1992-02-15')` |
| **Example** | `timezone_hour(DATE '1992-02-15')` |
| **Result** | `0` |

#### `timezone_minute(date)`

<div class="nostroke_table"></div>

| **Description** | Time zone offset minutes portion. |
| **Example** | `timezone_minute(date '1992-02-15')` |
| **Example** | `timezone_minute(DATE '1992-02-15')` |
| **Result** | `0` |

#### `timezone(date)`

<div class="nostroke_table"></div>

| **Description** | Time Zone offset in minutes. |
| **Example** | `timezone(date '1992-02-15')` |
| **Example** | `timezone(DATE '1992-02-15')` |
| **Result** | `0` |

#### `week(date)`

<div class="nostroke_table"></div>

| **Description** | ISO Week. |
| **Example** | `week(date '1992-02-15')` |
| **Example** | `week(DATE '1992-02-15')` |
| **Result** | `7` |

#### `weekday(date)`

<div class="nostroke_table"></div>

| **Description** | Numeric weekday synonym (Sunday = 0, Saturday = 6). |
| **Example** | `weekday(date '1992-02-15')` |
| **Example** | `weekday(DATE '1992-02-15')` |
| **Result** | `6` |

#### `weekofyear(date)`

<div class="nostroke_table"></div>

| **Description** | ISO Week (synonym). |
| **Example** | `weekofyear(date '1992-02-15')` |
| **Example** | `weekofyear(DATE '1992-02-15')` |
| **Result** | `7` |

#### `year(date)`

<div class="nostroke_table"></div>

| **Description** | Year. |
| **Example** | `year(date '1992-02-15')` |
| **Example** | `year(DATE '1992-02-15')` |
| **Result** | `1992` |

#### `yearweek(date)`

<div class="nostroke_table"></div>

| **Description** | `BIGINT` of combined ISO Year number and 2-digit version of ISO Week number. |
| **Example** | `yearweek(date '1992-02-15')` |
| **Example** | `yearweek(DATE '1992-02-15')` |
| **Result** | `199207` |
2 changes: 1 addition & 1 deletion docs/sql/functions/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ List comprehensions can also use the position of the list elements by adding a s
In the following example, we use `x, i`, where `x` is the value and `i` is the position:

```sql
SELECT [4, 5, 6] AS l, [x FOR x, i IN l IF i != 2] filtered;
SELECT [4, 5, 6] AS l, [x FOR x, i IN l IF i != 2] AS filtered;
```

<div class="monospace_table"></div>
Expand Down

0 comments on commit 76b7986

Please sign in to comment.