[feature](Nereids) support Literal collate syntax (#23600)
Support such sql grammar, Just for compatibility ```sql select table_name from information_schema.tables where table_schema collate utf8_general_ci = 'information_schema' and table_name collate utf8_general_ci = 'parameters'; ```
This commit is contained in:
@ -389,6 +389,7 @@ primaryExpression
|
||||
| KEY (dbName=identifier DOT)? keyName=identifier #encryptKey
|
||||
| EXTRACT LEFT_PAREN field=identifier FROM (DATE | TIMESTAMP)?
|
||||
source=valueExpression RIGHT_PAREN #extract
|
||||
| primaryExpression COLLATE (identifier | STRING_LITERAL | DEFAULT) #collate
|
||||
;
|
||||
|
||||
functionIdentifier
|
||||
|
||||
@ -33,6 +33,7 @@ import org.apache.doris.nereids.DorisParser.BooleanExpressionContext;
|
||||
import org.apache.doris.nereids.DorisParser.BooleanLiteralContext;
|
||||
import org.apache.doris.nereids.DorisParser.BracketJoinHintContext;
|
||||
import org.apache.doris.nereids.DorisParser.BracketRelationHintContext;
|
||||
import org.apache.doris.nereids.DorisParser.CollateContext;
|
||||
import org.apache.doris.nereids.DorisParser.ColumnReferenceContext;
|
||||
import org.apache.doris.nereids.DorisParser.CommentJoinHintContext;
|
||||
import org.apache.doris.nereids.DorisParser.CommentRelationHintContext;
|
||||
@ -2054,4 +2055,9 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
}
|
||||
return context.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitCollate(CollateContext ctx) {
|
||||
return visit(ctx.primaryExpression());
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,6 +348,7 @@ public class NereidsParserTest extends ParserTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
void testParseExprDepthWidth() {
|
||||
String sql = "SELECT 1+2 = 3 from t";
|
||||
NereidsParser nereidsParser = new NereidsParser();
|
||||
@ -357,4 +358,11 @@ public class NereidsParserTest extends ParserTestBase {
|
||||
Assertions.assertEquals(4, logicalPlan.getExpressions().get(0).getDepth());
|
||||
Assertions.assertEquals(3, logicalPlan.getExpressions().get(0).getWidth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseCollate() {
|
||||
String sql = "SELECT * FROM t1 WHERE col COLLATE utf8 = 'test'";
|
||||
NereidsParser nereidsParser = new NereidsParser();
|
||||
nereidsParser.parseSingle(sql);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user