apache / apache/datafusion-sqlparser-rs

DorisSQL: add Doris Dialect

未关闭
#2,379 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
3.5k
派生
772
平均合并
4 天 9 小时
30 天内合并 PR
17

描述

# Doris SQL: Support Doris Dialect

## Summary

Add Doris SQL dialect, covering the core Doris syntax needed to parse common Doris DDL and load statements.

## Motivation

Apache Doris has SQL syntax that differs from the generic SQL dialect, especially around `CREATE TABLE` clauses, key models, partition/distribution definitions, table properties, and Doris-specific load statements. A dedicated `DorisDialect` would let users parse Doris SQL without weakening generic parser behavior.

## Proposed Scope

- Add `DorisDialect`
- Support Doris `CREATE TABLE` clauses:
- `ENGINE = OLAP`
- `DUPLICATE KEY`, `UNIQUE KEY`, `AGGREGATE KEY`
- table `COMMENT`
- `PARTITION BY RANGE/LIST`
- `AUTO PARTITION`
- `DISTRIBUTED BY HASH/RANDOM`
- `BUCKETS` / `BUCKETS AUTO`
- `PROPERTIES (...)`
- Support Doris column options such as `AUTO_INCREMENT`
- Support Doris `LOAD DATA INFILE`
- Support Doris `CREATE ROUTINE LOAD`
- Preserve generic dialect behavior where Doris-only syntax should remain rejected

## Parser / AST Changes

- Add Doris-specific AST structures for key model, partition, distribution, table properties, and load statements
- Extend `CreateTable` with optional Doris-specific fields
- Add `Display` support for canonical SQL rendering
- Add span support for newly introduced AST nodes where applicable

## Tests

Add Doris parser tests covering:

- Positive Doris parsing cases
- Generic/ANSI rejection cases for Doris-only syntax
- AST structure assertions
- Round-trip canonical rendering
- Escaping behavior for table comments containing single quotes

## Implementation Plan
This feature is delivered as a stacked PR series. Each PR builds on the previous one.
- PR 1: Doris dialect skeleton + AUTO_INCREMENT AST cleanup
- PR 2: CREATE TABLE column options
- PR 3: CREATE TABLE key model and distribution
- PR 4: CREATE TABLE partition clauses + ON UPDATE + double-quoted COMMENT
- PR 5: LOAD DATA INFILE
- PR 6: CREATE ROUTINE LOAD

贡献指南

这个仓库没有索引到贡献指南

调研方向

先从计划中的 PR 1 Doris 方言骨架和 AUTO_INCREMENT AST 清理开始,然后按照分层的实现计划继续完成 CREATE TABLE 子句和 Doris 加载语句。完成的标准是覆盖 Doris 专用 AST、CreateTable 字段、Display 和 span 支持、解析器的通过和拒绝测试、AST 断言、往返渲染以及注释转义用例。

由索引模型根据 Issue 内容生成。

评估

技术栈
rust, sql
领域
databases
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。