#parquet #nu #add #nushell #write #read #nushell-plugin

app nu_plugin_parquet

nu plugin to add parquet support

2 unstable releases

new 0.8.0 Sep 18, 2024
0.7.0 Sep 9, 2024

#439 in Database interfaces

Download history 65/week @ 2024-09-03 54/week @ 2024-09-10

119 downloads per month

MIT and maybe CC-PDDC

83KB
640 lines

From jakeswenson

This repo is a copy from jakeswenson's repo and updated to support nushell v0.60+ by @flying-sheep. See the original here https://github.com/jakeswenson/nu_plugin_from_parquet. Asked permission to fork, update, and add license here https://github.com/jakeswenson/nu_plugin_from_parquet/issues/4

nu_plugin_parquet

This is a nushell plugin to add parquet compatibility with nu structured types. It can read parquet files to nu tables, or write tables to parquet files.

Installing

To add the plugin permanently, just install it and call plugin add on it:

Using Cargo

cargo install --path .
plugin add ~/.cargo/bin/nu_plugin_parquet
plugin use ~/.cargo/bin/nu_plugin_parquet # required if you don't want to quit out and restart nushell

Usage

Reading

open -r sample.parquet | from parquet | first 10

or

open sample.parquet | first 10
╭───┬───────────────┬────┬────────────┬───────────┬──────────────┬────────┬──────────────┬──────────────┬──────────────┬────────────┬───────────┬──────────────┬──────────╮
│ # │ registration… │ id │ first_name │ last_name │    email     │ gender │  ip_address  │      cc      │   country    │ birthdate  │  salary   │    title     │ comments │
├───┼───────────────┼────┼────────────┼───────────┼──────────────┼────────┼──────────────┼──────────────┼──────────────┼────────────┼───────────┼──────────────┼──────────┤
│ 06 years ago   │  1 │ Amanda     │ Jordan    │ ajordan0@co… │ Female │ 1.197.201.267595218649… │ Indonesia    │ 3/8/197149756.53 │ Internal Au… │ 1E+02    │
│ 16 years ago   │  2 │ Albert     │ Freeman   │ afreeman1@i… │ Male   │ 218.111.175… │              │ Canada       │ 1/16/1968150280.17 │ Accountant … │          │
│ 26 years ago   │  3 │ Evelyn     │ Morgan    │ emorgan2@al… │ Female │ 7.161.136.9467671190719… │ Russia       │ 2/1/1960144972.51 │ Structural … │          │
│ 36 years ago   │  4 │ Denise     │ Riley     │ driley3@gmp… │ Female │ 140.35.109.… │ 35760315989… │ China        │ 4/8/199790263.05 │ Senior Cost… │          │
│ 46 years ago   │  5 │ Carlos     │ Burns     │ cburns4@mii… │        │ 169.113.235… │ 56022562552… │ South Africa │            │           │              │          │
│ 56 years ago   │  6 │ Kathryn    │ White     │ kwhite5@goo… │ Female │ 195.131.81.… │ 35831363260… │ Indonesia    │ 2/25/198369227.11 │ Account Exe… │          │
│ 66 years ago   │  7 │ Samuel     │ Holmes    │ sholmes6@fo… │ Male   │ 232.234.81.… │ 35826413669… │ Portugal     │ 12/18/198714247.62 │ Senior Fina… │          │
│ 76 years ago   │  8 │ Harry      │ Howell    │ hhowell7@ee… │ Male   │ 91.235.51.73 │              │ Bosnia and … │ 3/1/1962186469.43 │ Web Develop… │          │
│ 86 years ago   │  9 │ Jose       │ Foster    │ jfoster8@ye… │ Male   │ 132.31.53.61 │              │ South Korea  │ 3/27/1992231067.84 │ Software Te… │ 1E+02    │
│ 96 years ago   │ 10 │ Emily      │ Stewart   │ estewart9@o… │ Female │ 143.28.251.… │ 35742541103… │ Nigeria      │ 1/28/199727234.28 │ Health Coac… │          │
├───┼───────────────┼────┼────────────┼───────────┼──────────────┼────────┼──────────────┼──────────────┼──────────────┼────────────┼───────────┼──────────────┼──────────┤
│ # │ registration… │ id │ first_name │ last_name │    email     │ gender │  ip_address  │      cc      │   country    │ birthdate  │  salary   │    title     │ comments │
╰───┴───────────────┴────┴────────────┴───────────┴──────────────┴────────┴──────────────┴──────────────┴──────────────┴────────────┴───────────┴──────────────┴──────────╯

Displaying Metadata

Display metadata, instead of data, from the parquet file by passing the --metadata, -m flag to from parquet:

open -r sample.parquet | from parquet --metadata  | table -e
╭────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ version    │ 1                                                                                                   │
│ creator    │ parquet-mr version 1.8.1 (build 4aba4dae7bb0d4edbcf7923ae1339f28fd3f7fcf)                           │
│ num_rows   │ 1000                                                                                                │
│ key_values │ [list 0 items]                                                                                      │
│            │ ╭─────────────┬───────────────────────────────────────────────────────────────────────────────────╮ │
│ schema     │ │ name        │ hive_schema                                                                       │ │
│            │ │ num_columns │ 13                                                                                │ │
│            │ │             │ ╭────┬───────────────────┬────────────┬────────────┬─────────────┬──────────────╮ │ │
│            │ │ schema      │ │  # │       name        │ repetition │    type    │ type_length │ logical_type │ │ │
│            │ │             │ ├────┼───────────────────┼────────────┼────────────┼─────────────┼──────────────┤ │ │
│            │ │             │ │  0 │ registration_dttm │ OPTIONALINT96      │             │              │ │ │
│            │ │             │ │  1 │ id                │ OPTIONALINT32      │             │              │ │ │
│            │ │             │ │  2 │ first_name        │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  3 │ last_name         │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  4 │ email             │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  5 │ gender            │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  6 │ ip_address        │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  7 │ cc                │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  8 │ country           │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │  9 │ birthdate         │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │ 10 │ salary            │ OPTIONALDOUBLE     │             │              │ │ │
│            │ │             │ │ 11 │ title             │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ │ 12 │ comments          │ OPTIONALBYTE_ARRAY-1UTF8         │ │ │
│            │ │             │ ╰────┴───────────────────┴────────────┴────────────┴─────────────┴──────────────╯ │ │
│            │ ╰─────────────┴───────────────────────────────────────────────────────────────────────────────────╯ │
│            │ ╭───┬──────────┬─────────────────╮                                                                  │
│ row_groups │ │ # │ num_rows │ total_byte_size │                                                                  │
│            │ ├───┼──────────┼─────────────────┤                                                                  │
│            │ │ 01000112492 │                                                                  │
│            │ ╰───┴──────────┴─────────────────╯                                                                  │
╰────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────╯

Writing

[{a:1, b:3}, {a: 2, b:4}] | save example.parquet

Or, to save all running processes:

ps | save example.parquet

Dependencies

~31–61MB
~1M SLoC