nushell/crates
Darren Schroeder 664d8d3573
allow date grouping in group-by (#8084)
# Description

This small change allows tables to be grouped by date. It was previously
failing because nushell didn't know how to represent the date as a
string. This change allows the date to be formatted in rfc3339 format
with subseconds represented as dot milliseconds. This formatted datetime
representation is already understood by nushell.

Now you can do things like 

### Grouping by the exact time
```
> ls | group-by modified | table
╭───────────────────────────────┬────────────────╮
│ 2022-01-07T07:53:44.658-06:00 │ [table 1 row]  │
│ 2022-11-29T08:08:09.411-06:00 │ [table 2 rows] │
│ 2023-02-15T08:23:16.044-06:00 │ [table 5 rows] │
│ 2023-01-04T14:45:08.940-06:00 │ [table 2 rows] │
│ 2022-04-08T08:12:50.295-05:00 │ [table 1 row]  │
│ 2022-09-15T10:11:21.177-05:00 │ [table 1 row]  │
│ 2022-06-22T14:26:56.409-05:00 │ [table 1 row]  │
│ 2023-02-08T09:24:32.774-06:00 │ [table 1 row]  │
│ 2022-05-25T11:57:00.866-05:00 │ [table 2 rows] │
│ 2023-02-15T08:23:16.054-06:00 │ [table 4 rows] │
│ 2023-01-04T14:45:08.970-06:00 │ [table 3 rows] │
│ 2022-08-05T07:14:06.265-05:00 │ [table 1 row]  │
│ 2022-01-07T07:53:44.728-06:00 │ [table 1 row]  │
│ 2023-01-27T09:39:34.351-06:00 │ [table 1 row]  │
│ 2023-02-08T09:24:32.794-06:00 │ [table 1 row]  │
│ 2023-02-15T08:36:26.524-06:00 │ [table 1 row]  │
│ 2023-01-19T12:53:22.033-06:00 │ [table 1 row]  │
╰───────────────────────────────┴────────────────╯
```
### Grouping by only the date (truncating the time componenet to 0)
```
> ls | default "" date | update date {|r| $r.modified | date format '%Y-%m-%d' | into datetime} | group-by date | table
╭───────────────────────────────┬─────────────────╮
│ 2022-01-07T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-11-29T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2023-02-15T00:00:00.000-06:00 │ [table 10 rows] │
│ 2023-01-04T00:00:00.000-06:00 │ [table 5 rows]  │
│ 2022-04-08T00:00:00.000-06:00 │ [table 1 row]   │
│ 2022-09-15T00:00:00.000-06:00 │ [table 1 row]   │
│ 2022-06-22T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-02-08T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-05-25T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-08-05T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-01-27T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-01-19T00:00:00.000-06:00 │ [table 1 row]   │
╰───────────────────────────────┴─────────────────╯
```
### Grouping and Displaying only the date (you could do this before this
PR too)
```
> ls | default "" date | update date {|r| $r.modified | date format '%Y-%m-%d'} | group-by date | table
╭────────────┬─────────────────╮
│ 2022-01-07 │ [table 2 rows]  │
│ 2022-11-29 │ [table 2 rows]  │
│ 2023-02-15 │ [table 10 rows] │
│ 2023-01-04 │ [table 5 rows]  │
│ 2022-04-08 │ [table 1 row]   │
│ 2022-09-15 │ [table 1 row]   │
│ 2022-06-22 │ [table 1 row]   │
│ 2023-02-08 │ [table 2 rows]  │
│ 2022-05-25 │ [table 2 rows]  │
│ 2022-08-05 │ [table 1 row]   │
│ 2023-01-27 │ [table 1 row]   │
│ 2023-01-19 │ [table 1 row]   │
╰────────────┴─────────────────╯
```
### Shows that nushell understands the rfc3339 format
```
> 2022-01-07T07:53:44.658-06:00 | describe 
date
> 2022-01-07T07:53:44.658-06:00 | date format '%Y-%m-%d'
2022-01-07
```
# User-Facing Changes

Related to #8036

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-15 19:10:55 +00:00
..
nu_plugin_custom_values Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu_plugin_example Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu_plugin_formats Move some from xxx commands to plugin (#7942) 2023-02-13 12:42:08 +00:00
nu_plugin_gstat Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu_plugin_inc Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu_plugin_python Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
nu_plugin_query Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-cli Bump rstest from 0.15.0 to 0.16.0 (#8064) 2023-02-13 02:34:09 +00:00
nu-color-config Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-command move ast command to the debug group (#8077) 2023-02-14 18:47:34 +00:00
nu-engine Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-explore Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-glob Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-json Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-parser support multiplication operation on string and list values (#8061) 2023-02-13 16:35:53 +00:00
nu-path Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-plugin Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-pretty-hex Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-protocol allow date grouping in group-by (#8084) 2023-02-15 19:10:55 +00:00
nu-system Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-table Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-term-grid Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
nu-test-support Move some from xxx commands to plugin (#7942) 2023-02-13 12:42:08 +00:00
nu-utils Disable auto-benchmark harness for crates (#8057) 2023-02-12 22:22:00 +00:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.