apache / apache/datafusion-sqlparser-rs

DorisSQL: add Doris Dialect

Đang mở
#2,379 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
3.5k
Fork
772
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
17

Mô tả

# 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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với skeleton Doris dialect đã được lên kế hoạch cho PR 1 và việc dọn dẹp AST của AUTO_INCREMENT, sau đó thực hiện theo kế hoạch triển khai xếp chồng cho đến các mệnh đề CREATE TABLE và các câu lệnh load của Doris. Được xem là hoàn tất khi đã bao phủ AST dành riêng cho Doris, các trường CreateTable, hỗ trợ Display và span, các bài kiểm thử parser chấp nhận và từ chối, các assertion của AST, việc render round-trip và các trường hợp escape comment.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust, sql
Lĩnh vực
databases
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.