File tree Expand file tree Collapse file tree
antlr4/org/apache/doris/nereids
java/org/apache/doris/nereids/parser
test/java/org/apache/doris/nereids/parser
regression-test/suites/nereids_syntax_p0 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -389,6 +389,7 @@ primaryExpression
389389 | KEY (dbName=identifier DOT )? keyName=identifier #encryptKey
390390 | EXTRACT LEFT_PAREN field=identifier FROM (DATE | TIMESTAMP )?
391391 source=valueExpression RIGHT_PAREN #extract
392+ | primaryExpression COLLATE (identifier | STRING_LITERAL | DEFAULT ) #collate
392393 ;
393394
394395functionIdentifier
Original file line number Diff line number Diff line change 3333import org .apache .doris .nereids .DorisParser .BooleanLiteralContext ;
3434import org .apache .doris .nereids .DorisParser .BracketJoinHintContext ;
3535import org .apache .doris .nereids .DorisParser .BracketRelationHintContext ;
36+ import org .apache .doris .nereids .DorisParser .CollateContext ;
3637import org .apache .doris .nereids .DorisParser .ColumnReferenceContext ;
3738import org .apache .doris .nereids .DorisParser .CommentJoinHintContext ;
3839import org .apache .doris .nereids .DorisParser .CommentRelationHintContext ;
@@ -2054,4 +2055,9 @@ private String parseConstant(ConstantContext context) {
20542055 }
20552056 return context .getText ();
20562057 }
2058+
2059+ @ Override
2060+ public Object visitCollate (CollateContext ctx ) {
2061+ return visit (ctx .primaryExpression ());
2062+ }
20572063}
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ public void testParseCast() {
348348 }
349349
350350 @ Test
351+
351352 void testParseExprDepthWidth () {
352353 String sql = "SELECT 1+2 = 3 from t" ;
353354 NereidsParser nereidsParser = new NereidsParser ();
@@ -357,4 +358,11 @@ void testParseExprDepthWidth() {
357358 Assertions .assertEquals (4 , logicalPlan .getExpressions ().get (0 ).getDepth ());
358359 Assertions .assertEquals (3 , logicalPlan .getExpressions ().get (0 ).getWidth ());
359360 }
361+
362+ @ Test
363+ public void testParseCollate () {
364+ String sql = "SELECT * FROM t1 WHERE col COLLATE utf8 = 'test'" ;
365+ NereidsParser nereidsParser = new NereidsParser ();
366+ nereidsParser .parseSingle (sql );
367+ }
360368}
Original file line number Diff line number Diff line change 1+ // Licensed to the Apache Software Foundation (ASF) under one
2+ // or more contributor license agreements. See the NOTICE file
3+ // distributed with this work for additional information
4+ // regarding copyright ownership. The ASF licenses this file
5+ // to you under the Apache License, Version 2.0 (the
6+ // "License"); you may not use this file except in compliance
7+ // with the License. You may obtain a copy of the License at
8+ //
9+ // http://www.apache.org/licenses/LICENSE-2.0
10+ //
11+ // Unless required by applicable law or agreed to in writing,
12+ // software distributed under the License is distributed on an
13+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ // KIND, either express or implied. See the License for the
15+ // specific language governing permissions and limitations
16+ // under the License.
17+
18+ suite(" collate_grammar_test" ) {
19+ sql " set enable_nereids_planner=true;"
20+ sql " set enable_fallback_to_original_planner=false;"
21+ sql """
22+ select table_name from information_schema.tables where table_schema collate utf8_general_ci = 'information_schema' and table_name collate utf8_general_ci = 'parameters';
23+ """
24+
25+ }
You can’t perform that action at this time.
0 commit comments