Skip to content

Commit 2cd1e28

Browse files
committed
docs(api): Update README to reflect SQL support in UnifiedQueryPlanner
Signed-off-by: Chen Dai <daichen@amazon.com>
1 parent 01a4c03 commit 2cd1e28

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

api/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This module provides components organized into two main areas aligned with the [
88

99
### Unified Language Specification
1010

11-
- **`UnifiedQueryPlanner`**: Accepts PPL (Piped Processing Language) queries and returns Calcite `RelNode` logical plans as intermediate representation.
11+
- **`UnifiedQueryPlanner`**: Accepts PPL (Piped Processing Language) or ANSI SQL queries and returns Calcite `RelNode` logical plans as intermediate representation. PPL uses the ANTLR-based parser while SQL uses Calcite's native `SqlParser``SqlValidator``SqlToRelConverter` pipeline.
1212
- **`UnifiedQueryTranspiler`**: Converts Calcite logical plans (`RelNode`) into SQL strings for various target databases using different SQL dialects.
1313

1414
### Unified Execution Runtime
@@ -17,7 +17,7 @@ This module provides components organized into two main areas aligned with the [
1717
- **`UnifiedFunction`**: Engine-agnostic function interface that enables functions to be evaluated across different execution engines without engine-specific code duplication.
1818
- **`UnifiedFunctionRepository`**: Repository for discovering and loading functions as `UnifiedFunction` instances, providing a bridge between function definitions and external execution engines.
1919

20-
Together, these components enable complete workflows: parse PPL queries into logical plans, transpile those plans into target database SQL, compile and execute queries directly, or export PPL functions for use in external execution engines.
20+
Together, these components enable complete workflows: parse PPL or SQL queries into logical plans, transpile those plans into target database SQL, compile and execute queries directly, or export PPL functions for use in external execution engines.
2121

2222
### Experimental API Design
2323

@@ -44,17 +44,30 @@ UnifiedQueryContext context = UnifiedQueryContext.builder()
4444

4545
### UnifiedQueryPlanner
4646

47-
Use `UnifiedQueryPlanner` to parse and analyze PPL queries into Calcite logical plans. The planner accepts a `UnifiedQueryContext` and can be reused for multiple queries.
47+
Use `UnifiedQueryPlanner` to parse and analyze PPL or SQL queries into Calcite logical plans. The planner accepts a `UnifiedQueryContext` and can be reused for multiple queries.
4848

4949
```java
50-
// Create planner with context
50+
// Create planner with context (PPL)
5151
UnifiedQueryPlanner planner = new UnifiedQueryPlanner(context);
5252

5353
// Plan multiple queries (context is reused)
5454
RelNode plan1 = planner.plan("source = logs | where status = 200");
5555
RelNode plan2 = planner.plan("source = metrics | stats avg(cpu)");
5656
```
5757

58+
For SQL queries, create a context with `QueryType.SQL`:
59+
60+
```java
61+
UnifiedQueryContext sqlContext = UnifiedQueryContext.builder()
62+
.language(QueryType.SQL)
63+
.catalog("opensearch", opensearchSchema)
64+
.defaultNamespace("opensearch")
65+
.build();
66+
UnifiedQueryPlanner sqlPlanner = new UnifiedQueryPlanner(sqlContext);
67+
68+
RelNode plan = sqlPlanner.plan("SELECT * FROM employees WHERE age > 30");
69+
```
70+
5871
### UnifiedQueryTranspiler
5972

6073
Use `UnifiedQueryTranspiler` to convert Calcite logical plans into SQL strings for target databases. The transpiler supports various SQL dialects through Calcite's `SqlDialect` interface.
@@ -226,5 +239,4 @@ public class MySchema extends AbstractSchema {
226239

227240
## Future Work
228241

229-
- Expand support to SQL language.
230242
- Extend planner to generate optimized physical plans using Calcite's optimization frameworks.

0 commit comments

Comments
 (0)