From 8091105eacf47894c993cc156dcffde5cd6c06ac Mon Sep 17 00:00:00 2001 From: Melbex De Leon Date: Thu, 21 Oct 2021 22:15:50 +0800 Subject: [PATCH 1/3] Initial commit and add select statement documentation --- README.md | 3 +++ docs/sql-support/select-statement.md | 15 +++++++++++++++ docs/sql-support/sql-support.md | 11 +++++++++++ 3 files changed, 29 insertions(+) create mode 100644 docs/sql-support/select-statement.md create mode 100644 docs/sql-support/sql-support.md 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/select-statement.md b/docs/sql-support/select-statement.md new file mode 100644 index 000000000..60c91b662 --- /dev/null +++ b/docs/sql-support/select-statement.md @@ -0,0 +1,15 @@ +## 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 +``` diff --git a/docs/sql-support/sql-support.md b/docs/sql-support/sql-support.md new file mode 100644 index 000000000..bf4022db4 --- /dev/null +++ b/docs/sql-support/sql-support.md @@ -0,0 +1,11 @@ +# 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) +- From 37fb44c28c4c6b5046196b85749fa048098e681c Mon Sep 17 00:00:00 2001 From: Melbex De Leon Date: Fri, 22 Oct 2021 13:56:00 +0800 Subject: [PATCH 2/3] Add aggregate function support --- docs/sql-support/select-statement.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/sql-support/select-statement.md b/docs/sql-support/select-statement.md index 60c91b662..d667d07cc 100644 --- a/docs/sql-support/select-statement.md +++ b/docs/sql-support/select-statement.md @@ -13,3 +13,9 @@ SELECT [ ALL | DISTINCT ] select_expr [, ...] -- 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 From 348988cf2eb9437996e66e4b4a430d08e41771a7 Mon Sep 17 00:00:00 2001 From: Melbex De Leon Date: Fri, 22 Oct 2021 16:15:01 +0800 Subject: [PATCH 3/3] Finalize(?) sql support documentation --- docs/sql-support/insert-statement.md | 14 ++++++++++++++ docs/sql-support/sql-support.md | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 docs/sql-support/insert-statement.md 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/sql-support.md b/docs/sql-support/sql-support.md index bf4022db4..bd174d468 100644 --- a/docs/sql-support/sql-support.md +++ b/docs/sql-support/sql-support.md @@ -8,4 +8,3 @@ The SQL grammar is mainly based on Facebook Presto DB. Currently the SQL support - [SELECT statement](./select-statement.md) - [INSERT statement](./insert-statement.md) --