LucaCappelletti94 commented on code in PR #2380:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2380#discussion_r4091233804


##########
src/dialect/doris.rs:
##########
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::{
+    ast::Expr,
+    dialect::{Dialect, MySqlDialect},
+    parser::{Parser, ParserError},
+};
+
+/// A [`Dialect`] for [Apache Doris](https://doris.apache.org/).
+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub struct DorisDialect {}
+
+impl Dialect for DorisDialect {

Review Comment:
   You should enable `supports_nested_comments`, since Doris nests bracketed 
comments 
([`BRACKETED_COMMENT`](https://github.com/apache/doris/blob/fd4f4b57fc3a9ee6a1693788b57a9c1711d000ed/fe/fe-sql-parser/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4#L764-L766)
 recurses) while MySQL does not. `SELECT 1 /* a /* b */ c */, 2` currently 
fails with `Expected: end of statement, found: *`.
   
   ```suggestion
   impl Dialect for DorisDialect {
       fn supports_nested_comments(&self) -> bool {
           true
       }
   
   ```



##########
tests/sqlparser_doris.rs:
##########
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#![warn(clippy::all)]
+//! Test SQL syntax specific to Apache Doris.
+
+#[macro_use]
+mod test_utils;
+
+use sqlparser::dialect::DorisDialect;
+use test_utils::*;
+
+fn doris() -> TestedDialects {
+    TestedDialects::new(vec![Box::new(DorisDialect {})])
+}
+
+#[test]
+fn parse_doris_strings_and_identifiers() {
+    doris().verified_only_select(
+        r#"SELECT "double quoted string", 'single quoted string', `select` 
FROM `db`.`table`"#,
+    );
+}
+
+#[test]
+fn parse_doris_limit_comma() {
+    doris().verified_only_select("SELECT * FROM t LIMIT 5, 10");
+}
+
+#[test]
+fn parse_doris_div_infix() {
+    doris().verified_only_select("SELECT 5 DIV 2");
+}
+
+#[test]
+fn parse_doris_group_by_with_rollup() {
+    doris().verified_only_select("SELECT * FROM t GROUP BY col1, col2 WITH 
ROLLUP");
+}

Review Comment:
   This is currently a red test:
   
   ```suggestion
   }
   
   #[test]
   fn parse_doris_nested_comments() {
       doris().one_statement_parses_to("SELECT 1 /* a /* b */ c */, 2", "SELECT 
1, 2");
   }
   ```



##########
src/dialect/doris.rs:
##########
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::{
+    ast::Expr,
+    dialect::{Dialect, MySqlDialect},
+    parser::{Parser, ParserError},
+};
+
+/// A [`Dialect`] for [Apache Doris](https://doris.apache.org/).
+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub struct DorisDialect {}
+
+impl Dialect for DorisDialect {

Review Comment:
   You should also add `DorisDialect` to the dialect arrays in 
`fuzz/fuzz_targets/fuzz_parse_sql.rs` and 
`fuzz/fuzz_targets/fuzz_parse_roundtrip.rs`, and bump the `[&dyn Dialect; 16]` 
length. Without that, Doris is the only dialect that is never fuzzed.



##########
src/dialect/doris.rs:
##########
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::{
+    ast::Expr,
+    dialect::{Dialect, MySqlDialect},
+    parser::{Parser, ParserError},
+};
+
+/// A [`Dialect`] for [Apache Doris](https://doris.apache.org/).
+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub struct DorisDialect {}
+
+impl Dialect for DorisDialect {

Review Comment:
   You should add a `{ label: "Doris", stems: ["doris"], pattern: /\bdoris\b/i 
}` entry to `DIALECTS` in `.github/workflows/labeler/label_dialects.js`. 
Otherwise the follow-up PRs titled `Doris: ...` get no dialect label and the 
bot asks their author for one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to