Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is "It's not a real SQL" a feature? #108

Open
pavlus opened this issue Jul 9, 2021 · 2 comments
Open

Is "It's not a real SQL" a feature? #108

pavlus opened this issue Jul 9, 2021 · 2 comments

Comments

@pavlus
Copy link
Contributor

pavlus commented Jul 9, 2021

I was thinking about more advanced queries and metadata, and some of them, along with some existing, are playing nicely with more traditional SQL syntax, but it could complicate writing queries for users, or very much complicate parsing and introduce unexpected behavior, if relaxed syntax remained.

Examples:

Arrays

is_image, is_video, etc could be global array variables containing extensions of files, so is_video = true becomes something like ext in _video_exts

Relations

  • mp3_* are implying that we parse only MP3 ID3 tags, but there are similar metadata available in OGG, FLAC and other files. We could have mp3, vorbis_comments, etc. relations with a single view like tags coalescing data from columns in those relations, (btw, images and videos can have tags too).

Glob expansion for relations

select path, tags.* from ~/Music/ -- simple way to display all tags for audio files.

GROUP BY

Currently aggregation is total, we cannot define grouping criteria, if we could, such use-cases would be possible:

  • select tags.album, count(tags.title) from ~/Music/ group by tags.album -- list number of titles in each album.
  • select ext, format_size(sum(size)), count(ext) from ~/ group by ext -- statistics of disc usage by file extension.

Aliases

From the top of my head would only affect naming of fields in JSON output, or CSV headers, if there were csv-with-headers output option, but with support for tuples, we could also do something like this:
select path, (width, height) as dimensions from ~/Pictures/ where ext in _image_exts into json, which could produce output like this:

[
  {
  "path": "~/Pictures/cats.jpg",
  "dimensions": {
    "width": 1024,
    "height": 768
    },
  },
  {
  "path": "~/Pictures/dogs.jpg",
  "dimensions": {
    "width": 640,
    "height": 480
    }
  }
]
@pavlus pavlus changed the title Is 'It's not a real SQL' a feature? Is "It's not a real SQL" a feature? Jul 9, 2021
@shah
Copy link

shah commented Apr 15, 2022

I just discovered this fantastic tool and found myself thinking the same thing @pavlus - it would be great if we could offer fselect to our data scientists that already know SQL but are not good at the CLI. For now fselect is already much better than using find at the CLI but the improvements you've suggested in this ticket would be ideal.

@rickological
Copy link

I've also very recently discovered this tool and I love it - and for me GROUP BY to work with the aggregate functions it already has would be amazing. I'm new to Rust (from PHP) and learning lots but at present adding the above might be a bit beyond my ability. I am still going to try tho!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants