aljazerzen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    1
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Lutra - a proposal for a data tool Lutra is a tool for executing relational data queries. It operates with a directory of PRQL source files and .parquet input data. It extracts queries, executes them using DuckDB and writes results to local disk. It is highly interactive, asking for additional information about what the user is trying to accomplish. It is designed as a CLI-library duo, so it can be used from command line as well integrated into other data tools. It uses the directory as the source of truth for project state, implementes appropriate locking to allow many concurrent invocations on the same directory. This is a typical project structure: ``` - lutra.toml # project config file - _project.prql # main PRQL source file - utils.prql # a PRQL source with utils - sales/ # a directory module - orders.prql # a sub module - order_dump.parquet # data input file ``` ## Building PRQL source files contain queries that either load data or transform that data. Any relational query that is not used in any other query is exported into a .parquet file. ``` # orders.prql # loading data let all_orders = ( from read_parquet('./sales/order_dump.parquet') filter important_column == null ) let closed = ( from all_orders filter status == 'closed' ) all_orders ``` Now we run: ``` $lutra run Building project... done. Results: - sales/orders.main.parquet - sales/orders.closed.parquet ``` And we get the following files: ``` - ... - sales/ # (already existed) - orders.prql # (already existed) - order_dump.parquet # (already existed) - orders.main.parquet # result of `sales.orders.main` - orders.closed.parquet # result of `sales.orders.closed` ``` ## Auto-importing When we add: ``` - ... - sales/ # (already existed) - orders.prql # (already existed) - ... - articles.parquet # new data input ``` ... and run: ``` $ lutra run > Found unimported data in `sales/articles.parquet`. Do you want to import it? [y] Yes, use default name `sales.articles.main` [e] Yes, but edit the name. [n] No, ignore it. Creating file `sales/articles.prql` with contents: from read_parquet('sales/articles.parquet') Building project... done. Results: - sales/order.main.parquet - sales/order.closed.parquet ``` Lutra is reading and writing .parquet files all over your project. To know which files are input, which are output and which were recently added, it needs to keep tracks of all `read_parquet` calls and all output files. This means that we need to build a DAG of all relations If we are traversing the trees, we might as well build the DAG and infer inputs and outputs from that. ## Importing other file formats When a CSV, JSON, XLSX, ODS, HTML or SQL files are detected to have been added into the project, Lutra will try to convert those files into parquet. That is preferred over other formats because parquet is very close to relational data. Each of the other format may contain wildly varied data, which needs to be converted and regularized into tabular data: - CSV contains only string data. Any numbers, booleans or temporal data has to be deserialized from strings. - JSON can contain tabular data in different data structures: an array of row objects, an array of row arrays, an array of column arrays are just a few of them. - XLSX and ODS can contain multiple sheets in one file, along with non-tabular structures. The workflow would look like this: ``` $ lutra run > Found unimported data in `sales/articles.csv`. Do you want to import it? [y] Yes, use default name `sales.articles.main` [e] Yes, but edit the name. [n] No, ignore it. > CSV files need to be converted to Parquet. Does this layout looks correct? article_id | article_name | category | out_of_stock | price int32 | text | text | bool | float64 ------------+--------------+----------+--------------+--------- 42 | Pilot M2 1mm | pen | false | 7.50 55 | Fountain G33 | pen | true | 10.99 ... 411 more rows (413 total) ... [y] Yes, import as-is [e] Edit column types [n] No, abort. Successfully imported. > How do you want to cleanup the original CSV file? [d] Delete it. [a] Move it into `archive/` directory. [i] Keep it where it is and ignore it in future runs. ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully