Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

More docs in reference manual and add architecture doc #417

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b3254e1
Initial commit for PartiQL and complex query docs
dai-chen Mar 18, 2020
17476dd
Merge branch 'master' into automated-docs-phase-3
dai-chen Mar 18, 2020
7db02d1
Initial commit for PartiQL and complex query docs
dai-chen Mar 18, 2020
d8001ab
Initial commit for PartiQL and complex query docs
dai-chen Mar 18, 2020
ece5c14
Ignore multi-query for now because of bug
dai-chen Mar 18, 2020
034575f
Add test index mappings
dai-chen Mar 18, 2020
09fc3e7
Fix partiql doc
dai-chen Mar 19, 2020
21662a2
Bypass LEFT JOIN for now
dai-chen Mar 19, 2020
73594db
Add doc for JOINs
dai-chen Mar 19, 2020
0a55357
Add doc for JOINs
dai-chen Mar 19, 2020
63db8c2
Add doc for JOINs
dai-chen Mar 23, 2020
1d5d8cd
Add more cases for PartiQL
dai-chen Mar 26, 2020
eb62303
Add more cases for PartiQL
dai-chen Mar 26, 2020
51235c6
Add multi-line support
dai-chen Mar 27, 2020
2637e8b
Add multi-line support
dai-chen Mar 27, 2020
72a549f
Multi-line all complex queries
dai-chen Mar 27, 2020
19a28f4
Multi-line all complex queries
dai-chen Mar 30, 2020
092e9fe
Add doc for full text search
dai-chen Mar 31, 2020
0675b80
Add doc for full text search
dai-chen Mar 31, 2020
6ad2538
Add doc for metadata query
dai-chen Mar 31, 2020
90058aa
Add doc for multi match query
dai-chen Mar 31, 2020
1cf14d9
Add doc for delete statement
dai-chen Mar 31, 2020
99793e3
Remove join explain
dai-chen Apr 2, 2020
ee51857
Add RDD
dai-chen Apr 2, 2020
4b20d56
Add RDD
dai-chen Apr 2, 2020
9a5d653
Print test data for PartiQL
dai-chen Apr 2, 2020
83077dd
Print test data for PartiQL
dai-chen Apr 3, 2020
593c012
Change titles
dai-chen Apr 6, 2020
beb0577
Add architecture doc
dai-chen Apr 7, 2020
f40c747
Merge branch 'master' into automated-docs-phase-3
dai-chen Apr 7, 2020
c4c7bc7
Add docs for SQL functions
dai-chen Apr 8, 2020
a1f3c6f
Update index
dai-chen Apr 8, 2020
3e88f5b
Update docs
dai-chen Apr 8, 2020
45e8db9
Merge branch 'master' into automated-docs-phase-3
dai-chen Apr 8, 2020
7b4998a
Update docs
dai-chen Apr 8, 2020
131d254
Update docs
dai-chen Apr 8, 2020
8d4f684
Address PR comments
dai-chen Apr 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/dev/Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# OpenDistro SQL Engine Architecture

---
## 1.Overview

The OpenDistro SQL (OD-SQL) project is developed based on NLPChina project (https://github.com/NLPchina/elasticsearch-sql) which has been deprecated now ([attributions](https://github.com/opendistro-for-elasticsearch/sql/blob/master/docs/attributions.md)). Over the one year in development, a lot of features have been added to the OD-SQL project on top of the existing older nlp-china project. The purpose of this document is to explain the OD-SQL current architecture going ahead.
dai-chen marked this conversation as resolved.
Show resolved Hide resolved

---
## 2.High Level View

In the high level, the OD-SQL Engine could be divided into four major sub-module.

* *Parser*: Currently, there are two Lex&Parser coexists. The Druid Lex&Parser is the original one from NLPChina. The input AST of Core Engine is from the Druid Lex&Parser. The [ANTLR](https://github.com/opendistro-for-elasticsearch/sql/blob/master/src/main/antlr/OpenDistroSqlParser.g4) Lex&Parser is added by us to customized the verification and exception handling.
* *Analyzer*: The analyzer module take the output from ANTLR Lex&Parser then perform syntax and semantic analyze.
* *Core Engine*: The QueryAction take the output from Druid Lex&Parser and translate to the Elasticsearch DSL if possible. This is an NLPChina original module. The QueryPlanner Builder is added by us to support the JOIN and Post-processing logic. The QueryPlanner will take the take the output from Druid Lex&Parser and build the PhysicalPlan
* *Execution*: The execution module execute QueryAction or QueryPlanner and return the response to the client. Different from the Frontend, Analyzer and Core Engine which running on the Transport Thread and can’t do any blocking operation. The Execution module running on the client threadpool and can perform the blocking operation.

There are also others modules include in the OD-SQL engine.

* _Documentation_: it is used to auto-generated documentation.
* _Metrics_: it is used to collect OD-SQL related metrics.
* _Resource Manager_: it is used to monitor the memory consumption when performing join operation to avoid the impact to Elasticsearch availability.

![Architecture Overview](img/architecture-overview.png)

---
## 3.Journey of the query in OD-SQL engine.

The following diagram take a sample query and explain how the query flow within different modules.

![Architecture Journey](img/architecture-journey.png)

1. The ANTRL parser based on grammar file (https://github.com/opendistro-for-elasticsearch/sql/blob/master/src/main/antlr/OpenDistroSqlParser.g4) to auto generate the AST.
2. The Syntax and Semantic Analyzer will walk through the AST and verify whether the query is follow the grammar and supported by the OD-SQL. e.g. *SELECT * FROM semantics WHERE LOG(age, city) = 1, *will throw exception with message* Function [LOG] cannot work with [INTEGER, KEYWORD]. *and sample usage message* Usage: LOG(NUMBER T) → DOUBLE.
3. The Druid Lex&Parser takes the input query and generate the druid AST which is different from the AST generated by the ANTRL. This module is the open source library (https://github.com/alibaba/druid) used by NLPChina originally.
4. The QueryPlanner Builder take the AST as input and generate the LogicalPlan from it. Then it optimize the LogicalPlan to PhysicalPlan.(In current implementation, only rule-based model is implemented). The major part of PhysicalPlan generation use NLPChina’s original logic to translate the SQL expression in AST to Elasticsearch DSL.
5. The QueryPlanner executor execute the PhysicalPlan in worker thread.
6. The formatter will reformatted the response data to the required format. The default format is JDBC format.
dai-chen marked this conversation as resolved.
Show resolved Hide resolved

Binary file added docs/dev/img/architecture-journey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dev/img/architecture-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/user/admin/monitoring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Result set::
"failed_request_count_cb" : 0,
"failed_request_count_cuserr" : 0,
"circuit_breaker" : 0,
"request_total" : 0,
"request_total" : 49,
"request_count" : 0,
"failed_request_count_syserr" : 0
}
Expand Down
Loading