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

How to show human readable file sizes? #15

Closed
applee opened this issue May 17, 2017 · 3 comments
Closed

How to show human readable file sizes? #15

applee opened this issue May 17, 2017 · 3 comments

Comments

@applee
Copy link

applee commented May 17, 2017

It would be better to support some function to convert the size unit, e.g. kb/mb/gb. So the sql would be as below
fsql "select name, mb(size) from . where ...."

@kashav
Copy link
Owner

kashav commented May 17, 2017

Great idea!

I'm thinking about introducing something called an attribute modifier, essentially used to modify attributes (this'll also be used for #3). I'll create an in-depth issue about this in the coming days.

I want the syntax to focus more on the actual attribute, so it doesn't feel like you're using a function. My preliminary thought is to do something like this --

SELECT name::upper, size::mb FROM . WHERE time::iso ...

This will also allow attributes to have more than one modifier. Of course attributes can be selected without any modifier as well. The only downside that I see in doing it like this is that we're kind of moving away from SQL syntax (I'm not really sure if this is a problem).

Would love to hear your thoughts on this!

@applee
Copy link
Author

applee commented May 18, 2017

It sounds so cool, as you said attribute modifier breaks SQL syntax, but functions not. I'm using another tool named osquery, it looks like fully matched SQL syntax.

@kashav
Copy link
Owner

kashav commented Jun 4, 2017

@applee This is now implemented!

You can get a human-readable file size as follows:

$ fsql "SELECT name, FORMAT(size, MB) FROM . WHERE ..."

@kashav kashav closed this as completed Jun 5, 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

2 participants