nushell/crates/nu_plugin_polars/src
pyz4 147009a161
polars into-df/polars into-lazy: --schema will not throw error if only some columns are defined (#15473)
# Description
The current implementation of `polars into-df` and `polars into-lazy`
will throw an error if `--schema` is provided but not all columns are
defined. This PR seeks to remove this requirement so that when a partial
`--schema` is provided, the types on the defined columns are overridden
while the remaining columns take on their default types.

**Current Implementation**
```
$ [[a b]; [1 "foo"] [2 "bar"]] | polars into-df -s {a: str} | polars schema
Error:   × Schema does not contain column: b
   ╭─[entry #88:1:12]
 1 │ [[a b]; [1 "foo"] [2 "bar"]] | polars into-df -s {a: str} | polars schema
   ·            ─────
   ╰────
```

**New Implementation (no error thrown on partial schema definition)**
Column b is not defined in `--schema`
```
$ [[a b]; [1 "foo"] [2 "bar"]] | polars into-df --schema {a: str} | polars schema
╭───┬─────╮
│ a │ str │
│ b │ str │
╰───┴─────╯
```

# User-Facing Changes
Soft breaking change: The user's previous (erroneous) code that would
have thrown an error would no longer throw an error. The user's previous
working code will still work.

# Tests + Formatting


# After Submitting
2025-04-07 15:58:37 -07:00
..
cache Polars: Minor code cleanup (#15144) 2025-02-19 09:47:21 -08:00
cloud Polars AWS S3 support (#14648) 2024-12-25 06:15:50 -06:00
dataframe polars into-df/polars into-lazy: --schema will not throw error if only some columns are defined (#15473) 2025-04-07 15:58:37 -07:00
lib.rs Adds polars list-contains command (#15304) 2025-03-12 08:25:03 -07:00
main.rs remove mimalloc allocator (#15317) 2025-03-15 09:32:55 -05:00