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

Attribute modifiers #17

Closed
kashav opened this issue May 17, 2017 · 5 comments
Closed

Attribute modifiers #17

kashav opened this issue May 17, 2017 · 5 comments

Comments

@kashav
Copy link
Owner

kashav commented May 17, 2017

A lot of suggestions have revolved around modifying attributes in some way (#3, #15).

Attribute modifiers will apply some change to the attributes in the SELECT and WHERE clauses.

I'm most fond of the following syntax right now. Of the ideas suggested, it's the easiest to parse (particularly for chained modifiers), while still being intuitive. I'm open to ideas if anyone has a suggestion.

SELECT name::upper::fullpath, size::mb FROM . WHERE time::iso > 2017-05-17T06:07:28Z

As I mentioned in #15 (comment), one of the downsides of a syntax like this is that we're moving away from SQL (i'm not entirely sure that this is even a problem).

@jorbs
Copy link

jorbs commented May 20, 2017

Why not use them as functions? E.g.

SELECT fullpath(upper(name)), format(size, 'mb') FROM . WHERE format(time, 'iso') > 2017-05-17T06:07:28Z

@kashav
Copy link
Owner Author

kashav commented May 20, 2017

@jorbs I was originally considering using function syntax as well, but I decided against it for a few reasons --

  1. Parsing chained functions is slightly more work (and messier).

  2. Invoking fsql without quotes requires you to escape parentheses, so to run the above example, you'd use:

    $ fsql SELECT fullpath\(upper\(name\)\), format\(size, 'mb'\) FROM . WHERE format\(time, 'iso'\) \> 2017-05-17T06:07:28Z

    Of course, you still have the option of wrapping the entire query in quotes and not having to escape anything.

That being said, it seems like most people do prefer function syntax, so I'll probably end up going with that anyways! 😄

@khageshpatel
Copy link
Contributor

Hi,

I should have asked you before working on this. I was just playing around the code of this and implemented something of this sort. Please see if its of any use or not: #23

@kashav
Copy link
Owner Author

kashav commented May 24, 2017

Hey @khageshpatel, no worries! I'll get to reviewing and testing that right away!

@kashav
Copy link
Owner Author

kashav commented Jun 4, 2017

Completed in #27 (09ea293).

I ended up opting with the function notation for this to be consistent with SQL syntax. I also introduced an "interactive" mode in hopes of mitigating the need for escaping parentheses (which was my main concern with this notation, as mentioned above).

See README.md#attribute-modifiers for the full documentation.

@kashav kashav closed this as completed Jun 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants