mechatroner / RBQL

🦜RBQL - Rainbow Query Language: SQL-like query engine for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions.
https://rbql.org
MIT License
276 stars 13 forks source link

support 'AS' keyword as a way to name the output columns #29

Closed mechatroner closed 1 year ago

mechatroner commented 3 years ago

AS in SQL: definition It would be very convenient for CSV and Parquet(if we start to support it).

Although AS wouldn't make sense for some of the output formats e.g. for json (if we start to support it at some point). It could be possible to treat AS in json output as a way to create key-value dictionary pairs, but it is actually much easier to do through the native json syntax e.g. instead of SELECT a['foo'] as 'bar' write SELECT {'foo': a['bar']}, the later notation also provides much more flexibility. Also AS will not work well with native 2D-arrays as the output format.

ankon commented 2 years ago

I'm using RBQL (through VSCode) to "explore" CSV data produced as output by other scripts, and AS would help a lot with queries such as SELECT a1,AVG(a2) GROUP BY a1 -- right now the second column just appears as col2. That's fine with just one column, but it gets annoying with many of them.

mechatroner commented 1 year ago

Done. Now it is possible to rewrite the query like this: SELECT a2 as id,AVG(a4) AS average GROUP BY a2.