diff --git a/README.md b/README.md index 0a5ca16ae..e1b59ec5d 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,9 @@ marketstore connect --url
``` and run commands through the sql session. +### SQL Support +See [SQL support](./docs/sql-support/sql-support.md) + ## Plugins Go plugin architecture works best with Go1.10+ on linux. For more on plugins, see the [plugins package](./plugins/) Some featured plugins are covered here - diff --git a/docs/sql-support/insert-statement.md b/docs/sql-support/insert-statement.md new file mode 100644 index 000000000..e59ea9b7b --- /dev/null +++ b/docs/sql-support/insert-statement.md @@ -0,0 +1,14 @@ +## INSERT Statements + +``` +INSERT INTO data_location select_statement; +``` + +#### Where `data_directory` is a sub-directory pointing to the `rootDirectory` of your configuration file +```sql +-- example +INSERT INTO `gdax_BTC-USD/1D/OHLCV` SELECT * FROM `binance_BTC-USDT/1D/OHLCV`; +``` + +### Aggregate functions supported: +- TICKCANDLER diff --git a/docs/sql-support/select-statement.md b/docs/sql-support/select-statement.md new file mode 100644 index 000000000..d667d07cc --- /dev/null +++ b/docs/sql-support/select-statement.md @@ -0,0 +1,21 @@ +## SELECT Statements + +``` +SELECT [ ALL | DISTINCT ] select_expr [, ...] +[ FROM data_directory [, ...] ] +[ WHERE condition ] +[ { LIMIT [ count ] } ] +``` + +#### Where `data_directory` is a sub-directory pointing to the `rootDirectory` of your configuration file + +``` sql +-- example +SELECT * FROM `gdax_BTC-USD/1D/OHLCV`; --escape dashes by wrapping it with backticks +``` + +#### Aggregate functions supported are the following: +- COUNT +- AVG +- MAX +- MIN diff --git a/docs/sql-support/sql-support.md b/docs/sql-support/sql-support.md new file mode 100644 index 000000000..bd174d468 --- /dev/null +++ b/docs/sql-support/sql-support.md @@ -0,0 +1,10 @@ +# SQL Support + +The SQL interpreter uses ANTLR4 in order to generate a parse tree and evaluate the given SQL statements within the CLI application. + +In order to achieve this, ANTLR4 requires a lexer file and a grammar file in order to work. The lexer file can be found in `sqlparser/parser/SQLLexerRules.g4` directory and the grammar rules can be found at `sqlparser/parser/SQLBase.g4` directory. + +The SQL grammar is mainly based on Facebook Presto DB. Currently the SQL support is limited to the following Data Manipulation Language since market data is a structured data and highly likely it will stay this way (but contribution is highly recommended if you want to expand the current support): + +- [SELECT statement](./select-statement.md) +- [INSERT statement](./insert-statement.md)