Skip to content

Doris SQL: add Doris Dialect - #2380

Open
finchxxia wants to merge 2 commits into
apache:mainfrom
finchxxia:draft/doris-dialect-support
Open

Doris SQL: add Doris Dialect#2380
finchxxia wants to merge 2 commits into
apache:mainfrom
finchxxia:draft/doris-dialect-support

Conversation

@finchxxia

@finchxxia finchxxia commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Doris SQL dialect support to close #2379

This is PR 1 of a stacked Doris SQL support series. It contains only the shared AUTO_INCREMENT AST cleanup and the Doris dialect skeleton. Follow-up draft PRs add CREATE TABLE table models, LOAD DATA INFILE, and CREATE ROUTINE LOAD support.

This PR introduces DorisDialect and parser/AST support for common Doris SQL syntax, especially Doris CREATE TABLE clauses, partition/distribution definitions, table properties, Doris column options, and Doris load statements.

Changes

  • Add DorisDialect

    • backtick-delimited identifiers
    • Doris-style identifiers
    • backslash string escapes
    • Doris-specific parser capability gates
  • Add Doris CREATE TABLE support

    • ENGINE = OLAP
    • DUPLICATE KEY, UNIQUE KEY, AGGREGATE KEY
    • table-level COMMENT
    • PARTITION BY RANGE/LIST
    • AUTO PARTITION
    • partition values including MAXVALUE / MAX_VALUE
    • fixed and batch range partitions
    • DISTRIBUTED BY HASH/RANDOM
    • BUCKETS <n> and BUCKETS AUTO
    • PROPERTIES (...)
  • Add Doris AST structures

    • key model
    • partition model
    • distribution model
    • bucket declarations
    • Doris load statements
  • Add Doris-specific statement parsing

    • LOAD DATA INFILE
    • CREATE ROUTINE LOAD
  • Extend tests

    • Doris round-trip parser tests
    • structured AST assertions
    • generic/ANSI rejection cases for Doris-only syntax
    • table comment escaping
    • compatibility checks for surrounding dialect behavior

Testing

cargo fmt --check
cargo test --test sqlparser_doris

@finchxxia
finchxxia marked this pull request as draft June 17, 2026 08:28
@finchxxia
finchxxia force-pushed the draft/doris-dialect-support branch from fc16163 to a55690c Compare June 17, 2026 08:35
@LucaCappelletti94

Copy link
Copy Markdown
Contributor

2500 lines of a PR are a bit too many, could you fracture this down into smaller reviewable units?

@finchxxia

Copy link
Copy Markdown
Contributor Author

2500 lines of a PR are a bit too many, could you fracture this down into smaller reviewable units?

@LucaCappelletti94 Of course, I would do that later and add more info in issue link #2379

@finchxxia
finchxxia force-pushed the draft/doris-dialect-support branch from ecca2d6 to bffa3fd Compare June 18, 2026 05:21
@finchxxia
finchxxia marked this pull request as ready for review June 18, 2026 06:15
@finchxxia

Copy link
Copy Markdown
Contributor Author

2500 lines of a PR are a bit too many, could you fracture this down into smaller reviewable units?

@LucaCappelletti94 Done. Could you please take a look?

@finchxxia
finchxxia force-pushed the draft/doris-dialect-support branch from 8f0906f to 7ff24be Compare July 3, 2026 06:47
@finchxxia

Copy link
Copy Markdown
Contributor Author

@alamb @benesch @LucaCappelletti94 Hi team, any improvement should I have?

@LucaCappelletti94 LucaCappelletti94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sort of PR that would really benefit from GitHub stabilizing stacked PR also for forks' branches. Let's hope that happens soon. In the meantime, here are a few notes on this first PR in the chain.

Comment thread src/dialect/doris.rs
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DorisDialect {}

impl Dialect for DorisDialect {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are still currently missing:

  • supports_limit_comma
  • parse_infix (the DIV)
  • supports_group_by_with_modifier

I am not familiar enough with Doris to say anything about the other methods, but I suggest you audit them against the engine.

Comment thread src/dialect/doris.rs
}

fn is_identifier_start(&self, ch: char) -> bool {
ch.is_ascii_alphabetic() || ch == '_' || !ch.is_ascii()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these methods at this time are extensively identical and meant to be identical to the MySqlDialect, I suggest they are kept aligned by using the same approach used with redshift and postgres and dispatch the method call to MySqlDialect. When they are strictly distinct, a comment with a documentation link may be desirable.

Comment thread tests/sqlparser_doris.rs
}

#[test]
fn doris_identifier_and_string_literal_gates() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure such a test is necessary

Comment thread tests/sqlparser_doris.rs

#[test]
fn parse_doris_strings_and_identifiers() {
doris().verified_stmt(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe here you may want to use verified_only_select

Comment thread tests/sqlparser_doris.rs

#[test]
fn doris_and_generic_parse_common_sql_identically() {
doris_and_generic().verified_stmt("SELECT 1 AS properties FROM t");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this will be more relevant in a later PR in this series where you add the keyword PROPERTIES?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DorisSQL: add Doris Dialect

2 participants