Affects Version/s: None
Fix Version/s: 1.14.0
Bourne shell has a toolkit of commands that allow you to do relational processing: grep = WHERE, sort = ORDER BY, uniq = SELECT DISTINCT, head = OFFSET/LIMIT, and so forth. Shell hackers are accustomed to writing pipelines. For example, to find the 3 largest files one would type
SQL is not quite as concise but nevertheless:
sqlsh is "SQL shell", a wrapper around Calcite JDBC. files is a view backed by a table function that calls "find .". Other commands:
- du table function - e.g. select path, size_k from du
- git_ls_files table function calls git-ls-files - e.g. select * from git_ls_files
- ps table function calls ps aux - e.g. select * from ps
- wc function calls wc - e.g. select path, lineCount from git_ls_files cross apply wc(path)
SQL would run in a lexical mode which is case-sensitive, and identifiers are not upper-cased if not quoted.
We could consider allowing shell-safe characters such as '-' in unquoted identifiers. (It's difficult to quote identifiers in SQL if the SQL has already passed through bash's quote handling, and had double-quotes and single-quotes removed.)
It gets really interesting when commands accept arguments, and Calcite pushes down filters to become those arguments. For example, in
Calcite should rewrite to use git log.
When accessing files, some kinds of files have implicit names (and types) for fields, and some don't. You should be able to access fields by name or position; the following are equivalent: