diff --git a/.licenserc.yaml b/.licenserc.yaml
index 4244c22a90..d9f95d1fc0 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -37,6 +37,8 @@ header:
- 'tsan_suppressions'
- 'docs/.markdownlintignore'
- 'fe/fe-core/src/test/resources/data/net_snmp_normal'
+ - 'fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaLexer.g4'
+ - 'fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaParser.g4'
- 'be/src/common/signal_handler.h'
- 'be/src/olap/lru_cache.cpp'
- 'be/src/olap/lru_cache.h'
diff --git a/LICENSE.txt b/LICENSE.txt
index 775386b0ff..8ca9617539 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -608,4 +608,70 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------------------
+
+fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaLexer.g4: BSD licence
+
+[The "BSD licence"]
+ Copyright (c) 2013 Terence Parr, Sam Harwell
+ Copyright (c) 2017 Ivan Kochurkin (upgrade to Java 8)
+ Copyright (c) 2021 Michał Lorek (upgrade to Java 11)
+ Copyright (c) 2022 Michał Lorek (upgrade to Java 17)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------------------
+
+fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaParser.g4: BSD licence
+
+ [The "BSD licence"]
+ Copyright (c) 2013 Terence Parr, Sam Harwell
+ Copyright (c) 2017 Ivan Kochurkin (upgrade to Java 8)
+ Copyright (c) 2021 Michał Lorek (upgrade to Java 11)
+ Copyright (c) 2022 Michał Lorek (upgrade to Java 17)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/fe/fe-core/pom.xml b/fe/fe-core/pom.xml
index 6ebb3b0b29..0382b6f4aa 100644
--- a/fe/fe-core/pom.xml
+++ b/fe/fe-core/pom.xml
@@ -643,6 +643,18 @@ under the License.
${antlr4.version}
+
+ javax.annotation
+ javax.annotation-api
+ 1.3.2
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.10.1
+
+
palo-fe
@@ -787,6 +799,65 @@ under the License.
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.10.1
+
+
+
+ compile-describable-processor
+ generate-sources
+
+ compile
+
+
+ none
+
+ org/apache/doris/nereids/pattern/generator/PatternDescribable.java
+ org/apache/doris/nereids/pattern/generator/PatternDescribableProcessor.java
+
+
+
+
+
+
+ generate-patterns
+ generate-sources
+
+ compile
+
+
+ only
+
+ -AoperatorPath=${basedir}/src/main/java/org/apache/doris/nereids
+
+
+ org/apache/doris/nereids/pattern/generator/PatternDescribableProcessPoint.java
+
+
+ org.apache.doris.nereids.pattern.generator.PatternDescribableProcessor
+
+
+
+
+
+
+ default-compile
+ compile
+
+ compile
+
+
+
+ org/apache/doris/nereids/pattern/generator/**
+
+
+
+
+
org.codehaus.mojo
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaLexer.g4 b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaLexer.g4
new file mode 100644
index 0000000000..2cdc0e1a2c
--- /dev/null
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaLexer.g4
@@ -0,0 +1,241 @@
+/*
+ [The "BSD licence"]
+ Copyright (c) 2013 Terence Parr, Sam Harwell
+ Copyright (c) 2017 Ivan Kochurkin (upgrade to Java 8)
+ Copyright (c) 2021 Michał Lorek (upgrade to Java 11)
+ Copyright (c) 2022 Michał Lorek (upgrade to Java 17)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+lexer grammar JavaLexer;
+
+// Keywords
+
+ABSTRACT: 'abstract';
+ASSERT: 'assert';
+BOOLEAN: 'boolean';
+BREAK: 'break';
+BYTE: 'byte';
+CASE: 'case';
+CATCH: 'catch';
+CHAR: 'char';
+CLASS: 'class';
+CONST: 'const';
+CONTINUE: 'continue';
+DEFAULT: 'default';
+DO: 'do';
+DOUBLE: 'double';
+ELSE: 'else';
+ENUM: 'enum';
+EXTENDS: 'extends';
+FINAL: 'final';
+FINALLY: 'finally';
+FLOAT: 'float';
+FOR: 'for';
+IF: 'if';
+GOTO: 'goto';
+IMPLEMENTS: 'implements';
+IMPORT: 'import';
+INSTANCEOF: 'instanceof';
+INT: 'int';
+INTERFACE: 'interface';
+LONG: 'long';
+NATIVE: 'native';
+NEW: 'new';
+PACKAGE: 'package';
+PRIVATE: 'private';
+PROTECTED: 'protected';
+PUBLIC: 'public';
+RETURN: 'return';
+SHORT: 'short';
+STATIC: 'static';
+STRICTFP: 'strictfp';
+SUPER: 'super';
+SWITCH: 'switch';
+SYNCHRONIZED: 'synchronized';
+THIS: 'this';
+THROW: 'throw';
+THROWS: 'throws';
+TRANSIENT: 'transient';
+TRY: 'try';
+VOID: 'void';
+VOLATILE: 'volatile';
+WHILE: 'while';
+
+// Module related keywords
+MODULE: 'module';
+OPEN: 'open';
+REQUIRES: 'requires';
+EXPORTS: 'exports';
+OPENS: 'opens';
+TO: 'to';
+USES: 'uses';
+PROVIDES: 'provides';
+WITH: 'with';
+TRANSITIVE: 'transitive';
+
+// Local Variable Type Inference
+VAR: 'var'; // reserved type name
+
+// Switch Expressions
+YIELD: 'yield';
+
+// Records
+RECORD: 'record';
+
+// Sealed Classes
+SEALED: 'sealed';
+PERMITS: 'permits';
+NON_SEALED: 'non-sealed';
+
+// Literals
+
+DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?;
+HEX_LITERAL: '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])? [lL]?;
+OCT_LITERAL: '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?;
+BINARY_LITERAL: '0' [bB] [01] ([01_]* [01])? [lL]?;
+
+FLOAT_LITERAL: (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]?
+ | Digits (ExponentPart [fFdD]? | [fFdD])
+ ;
+
+HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?;
+
+BOOL_LITERAL: 'true'
+ | 'false'
+ ;
+
+CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\'';
+
+STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"';
+
+TEXT_BLOCK: '"""' [ \t]* [\r\n] (. | EscapeSequence)*? '"""';
+
+NULL_LITERAL: 'null';
+
+// Separators
+
+LPAREN: '(';
+RPAREN: ')';
+LBRACE: '{';
+RBRACE: '}';
+LBRACK: '[';
+RBRACK: ']';
+SEMI: ';';
+COMMA: ',';
+DOT: '.';
+
+// Operators
+
+ASSIGN: '=';
+GT: '>';
+LT: '<';
+BANG: '!';
+TILDE: '~';
+QUESTION: '?';
+COLON: ':';
+EQUAL: '==';
+LE: '<=';
+GE: '>=';
+NOTEQUAL: '!=';
+AND: '&&';
+OR: '||';
+INC: '++';
+DEC: '--';
+ADD: '+';
+SUB: '-';
+MUL: '*';
+DIV: '/';
+BITAND: '&';
+BITOR: '|';
+CARET: '^';
+MOD: '%';
+
+ADD_ASSIGN: '+=';
+SUB_ASSIGN: '-=';
+MUL_ASSIGN: '*=';
+DIV_ASSIGN: '/=';
+AND_ASSIGN: '&=';
+OR_ASSIGN: '|=';
+XOR_ASSIGN: '^=';
+MOD_ASSIGN: '%=';
+LSHIFT_ASSIGN: '<<=';
+RSHIFT_ASSIGN: '>>=';
+URSHIFT_ASSIGN: '>>>=';
+
+// Java 8 tokens
+
+ARROW: '->';
+COLONCOLON: '::';
+
+// Additional symbols not defined in the lexical specification
+
+AT: '@';
+ELLIPSIS: '...';
+
+// Whitespace and comments
+
+WS: [ \t\r\n\u000C]+ -> channel(HIDDEN);
+COMMENT: '/*' .*? '*/' -> channel(HIDDEN);
+LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN);
+
+// Identifiers
+
+IDENTIFIER: Letter LetterOrDigit*;
+
+// Fragment rules
+
+fragment ExponentPart
+ : [eE] [+-]? Digits
+ ;
+
+fragment EscapeSequence
+ : '\\' [btnfr"'\\]
+ | '\\' ([0-3]? [0-7])? [0-7]
+ | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
+ ;
+
+fragment HexDigits
+ : HexDigit ((HexDigit | '_')* HexDigit)?
+ ;
+
+fragment HexDigit
+ : [0-9a-fA-F]
+ ;
+
+fragment Digits
+ : [0-9] ([0-9_]* [0-9])?
+ ;
+
+fragment LetterOrDigit
+ : Letter
+ | [0-9]
+ ;
+
+fragment Letter
+ : [a-zA-Z$_] // these are the "java letters" below 0x7F
+ | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
+ | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
+ ;
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaParser.g4 b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaParser.g4
new file mode 100644
index 0000000000..afb8b3549b
--- /dev/null
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/JavaParser.g4
@@ -0,0 +1,762 @@
+/*
+ [The "BSD licence"]
+ Copyright (c) 2013 Terence Parr, Sam Harwell
+ Copyright (c) 2017 Ivan Kochurkin (upgrade to Java 8)
+ Copyright (c) 2021 Michał Lorek (upgrade to Java 11)
+ Copyright (c) 2022 Michał Lorek (upgrade to Java 17)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+parser grammar JavaParser;
+
+options { tokenVocab=JavaLexer; }
+
+compilationUnit
+ : packageDeclaration? importDeclaration* typeDeclaration*
+ | moduleDeclaration EOF
+ ;
+
+packageDeclaration
+ : annotation* PACKAGE qualifiedName ';'
+ ;
+
+importDeclaration
+ : IMPORT STATIC? qualifiedName importStar? ';'
+ ;
+
+importStar
+ : '.' '*'
+ ;
+
+typeDeclaration
+ : classOrInterfaceModifier*
+ (classDeclaration | enumDeclaration | interfaceDeclaration | annotationTypeDeclaration | recordDeclaration)
+ | ';'
+ ;
+
+modifier
+ : classOrInterfaceModifier
+ | NATIVE
+ | SYNCHRONIZED
+ | TRANSIENT
+ | VOLATILE
+ ;
+
+classOrInterfaceModifier
+ : annotation
+ | PUBLIC
+ | PROTECTED
+ | PRIVATE
+ | STATIC
+ | ABSTRACT
+ | FINAL // FINAL for class only -- does not apply to interfaces
+ | STRICTFP
+ | SEALED // Java17
+ | NON_SEALED // Java17
+ ;
+
+variableModifier
+ : FINAL
+ | annotation
+ ;
+
+classDeclaration
+ : CLASS identifier typeParameters?
+ (EXTENDS typeType)?
+ (IMPLEMENTS typeList)?
+ (PERMITS typeList)? // Java17
+ classBody
+ ;
+
+typeParameters
+ : '<' typeParameter (',' typeParameter)* '>'
+ ;
+
+typeParameter
+ : annotation* identifier (EXTENDS annotation* typeBound)?
+ ;
+
+typeBound
+ : typeType ('&' typeType)*
+ ;
+
+enumDeclaration
+ : ENUM identifier (IMPLEMENTS typeList)? '{' enumConstants? ','? enumBodyDeclarations? '}'
+ ;
+
+enumConstants
+ : enumConstant (',' enumConstant)*
+ ;
+
+enumConstant
+ : annotation* identifier arguments? classBody?
+ ;
+
+enumBodyDeclarations
+ : ';' classBodyDeclaration*
+ ;
+
+interfaceDeclaration
+ : INTERFACE identifier typeParameters? (EXTENDS typeList)? (PERMITS typeList)? interfaceBody
+ ;
+
+classBody
+ : '{' classBodyDeclaration* '}'
+ ;
+
+interfaceBody
+ : '{' interfaceBodyDeclaration* '}'
+ ;
+
+classBodyDeclaration
+ : ';'
+ | STATIC? block
+ | modifier* memberDeclaration
+ ;
+
+memberDeclaration
+ : methodDeclaration
+ | genericMethodDeclaration
+ | fieldDeclaration
+ | constructorDeclaration
+ | genericConstructorDeclaration
+ | interfaceDeclaration
+ | annotationTypeDeclaration
+ | classDeclaration
+ | enumDeclaration
+ | recordDeclaration //Java17
+ ;
+
+/* We use rule this even for void methods which cannot have [] after parameters.
+ This simplifies grammar and we can consider void to be a type, which
+ renders the [] matching as a context-sensitive issue or a semantic check
+ for invalid return type after parsing.
+ */
+methodDeclaration
+ : typeTypeOrVoid identifier formalParameters ('[' ']')*
+ (THROWS qualifiedNameList)?
+ methodBody
+ ;
+
+methodBody
+ : block
+ | ';'
+ ;
+
+typeTypeOrVoid
+ : typeType
+ | VOID
+ ;
+
+genericMethodDeclaration
+ : typeParameters methodDeclaration
+ ;
+
+genericConstructorDeclaration
+ : typeParameters constructorDeclaration
+ ;
+
+constructorDeclaration
+ : identifier formalParameters (THROWS qualifiedNameList)? constructorBody=block
+ ;
+
+fieldDeclaration
+ : typeType variableDeclarators ';'
+ ;
+
+interfaceBodyDeclaration
+ : modifier* interfaceMemberDeclaration
+ | ';'
+ ;
+
+interfaceMemberDeclaration
+ : constDeclaration
+ | interfaceMethodDeclaration
+ | genericInterfaceMethodDeclaration
+ | interfaceDeclaration
+ | annotationTypeDeclaration
+ | classDeclaration
+ | enumDeclaration
+ | recordDeclaration // Java17
+ ;
+
+constDeclaration
+ : typeType constantDeclarator (',' constantDeclarator)* ';'
+ ;
+
+constantDeclarator
+ : identifier ('[' ']')* '=' variableInitializer
+ ;
+
+// Early versions of Java allows brackets after the method name, eg.
+// public int[] return2DArray() [] { ... }
+// is the same as
+// public int[][] return2DArray() { ... }
+interfaceMethodDeclaration
+ : interfaceMethodModifier* interfaceCommonBodyDeclaration
+ ;
+
+// Java8
+interfaceMethodModifier
+ : annotation
+ | PUBLIC
+ | ABSTRACT
+ | DEFAULT
+ | STATIC
+ | STRICTFP
+ ;
+
+genericInterfaceMethodDeclaration
+ : interfaceMethodModifier* typeParameters interfaceCommonBodyDeclaration
+ ;
+
+interfaceCommonBodyDeclaration
+ : annotation* typeTypeOrVoid identifier formalParameters ('[' ']')* (THROWS qualifiedNameList)? methodBody
+ ;
+
+variableDeclarators
+ : variableDeclarator (',' variableDeclarator)*
+ ;
+
+variableDeclarator
+ : variableDeclaratorId ('=' variableInitializer)?
+ ;
+
+variableDeclaratorId
+ : identifier arrayDeclarator*
+ ;
+
+arrayDeclarator
+ : '[' ']'
+ ;
+
+variableInitializer
+ : arrayInitializer
+ | expression
+ ;
+
+arrayInitializer
+ : '{' (variableInitializer (',' variableInitializer)* (',')? )? '}'
+ ;
+
+classOrInterfaceType
+ : identifierAndTypeArguments ('.' identifierAndTypeArguments)*
+ ;
+
+identifierAndTypeArguments
+ : identifier typeArguments?
+ ;
+
+typeArgument
+ : typeType
+ | annotation* '?' ((EXTENDS | SUPER) typeType)?
+ ;
+
+qualifiedNameList
+ : qualifiedName (',' qualifiedName)*
+ ;
+
+formalParameters
+ : '(' ( receiverParameter?
+ | receiverParameter (',' formalParameterList)?
+ | formalParameterList?
+ ) ')'
+ ;
+
+receiverParameter
+ : typeType (identifier '.')* THIS
+ ;
+
+formalParameterList
+ : formalParameter (',' formalParameter)* (',' lastFormalParameter)?
+ | lastFormalParameter
+ ;
+
+formalParameter
+ : variableModifier* typeType variableDeclaratorId
+ ;
+
+lastFormalParameter
+ : variableModifier* typeType annotation* '...' variableDeclaratorId
+ ;
+
+// local variable type inference
+lambdaLVTIList
+ : lambdaLVTIParameter (',' lambdaLVTIParameter)*
+ ;
+
+lambdaLVTIParameter
+ : variableModifier* VAR identifier
+ ;
+
+qualifiedName
+ : identifier ('.' identifier)*
+ ;
+
+literal
+ : integerLiteral
+ | floatLiteral
+ | CHAR_LITERAL
+ | STRING_LITERAL
+ | BOOL_LITERAL
+ | NULL_LITERAL
+ | TEXT_BLOCK // Java17
+ ;
+
+integerLiteral
+ : DECIMAL_LITERAL
+ | HEX_LITERAL
+ | OCT_LITERAL
+ | BINARY_LITERAL
+ ;
+
+floatLiteral
+ : FLOAT_LITERAL
+ | HEX_FLOAT_LITERAL
+ ;
+
+// ANNOTATIONS
+altAnnotationQualifiedName
+ : (identifier DOT)* '@' identifier
+ ;
+
+annotation
+ : ('@' qualifiedName | altAnnotationQualifiedName) ('(' ( elementValuePairs | elementValue )? ')')?
+ ;
+
+elementValuePairs
+ : elementValuePair (',' elementValuePair)*
+ ;
+
+elementValuePair
+ : identifier '=' elementValue
+ ;
+
+elementValue
+ : expression
+ | annotation
+ | elementValueArrayInitializer
+ ;
+
+elementValueArrayInitializer
+ : '{' (elementValue (',' elementValue)*)? (',')? '}'
+ ;
+
+annotationTypeDeclaration
+ : '@' INTERFACE identifier annotationTypeBody
+ ;
+
+annotationTypeBody
+ : '{' (annotationTypeElementDeclaration)* '}'
+ ;
+
+annotationTypeElementDeclaration
+ : modifier* annotationTypeElementRest
+ | ';' // this is not allowed by the grammar, but apparently allowed by the actual compiler
+ ;
+
+annotationTypeElementRest
+ : typeType annotationMethodOrConstantRest ';'
+ | classDeclaration ';'?
+ | interfaceDeclaration ';'?
+ | enumDeclaration ';'?
+ | annotationTypeDeclaration ';'?
+ | recordDeclaration ';'? // Java17
+ ;
+
+annotationMethodOrConstantRest
+ : annotationMethodRest
+ | annotationConstantRest
+ ;
+
+annotationMethodRest
+ : identifier '(' ')' defaultValue?
+ ;
+
+annotationConstantRest
+ : variableDeclarators
+ ;
+
+defaultValue
+ : DEFAULT elementValue
+ ;
+
+// MODULES - Java9
+
+moduleDeclaration
+ : OPEN? MODULE qualifiedName moduleBody
+ ;
+
+moduleBody
+ : '{' moduleDirective* '}'
+ ;
+
+moduleDirective
+ : REQUIRES requiresModifier* qualifiedName ';'
+ | EXPORTS qualifiedName (TO qualifiedName)? ';'
+ | OPENS qualifiedName (TO qualifiedName)? ';'
+ | USES qualifiedName ';'
+ | PROVIDES qualifiedName WITH qualifiedName ';'
+ ;
+
+requiresModifier
+ : TRANSITIVE
+ | STATIC
+ ;
+
+// RECORDS - Java 17
+
+recordDeclaration
+ : RECORD identifier typeParameters? recordHeader
+ (IMPLEMENTS typeList)?
+ recordBody
+ ;
+
+recordHeader
+ : '(' recordComponentList? ')'
+ ;
+
+recordComponentList
+ : recordComponent (',' recordComponent)*
+ ;
+
+recordComponent
+ : typeType identifier
+ ;
+
+recordBody
+ : '{' classBodyDeclaration* '}'
+ ;
+
+// STATEMENTS / BLOCKS
+
+block
+ : '{' blockStatement* '}'
+ ;
+
+blockStatement
+ : localVariableDeclaration ';'
+ | statement
+ | localTypeDeclaration
+ ;
+
+localVariableDeclaration
+ : variableModifier* (typeType variableDeclarators | VAR identifier '=' expression)
+ ;
+
+identifier
+ : IDENTIFIER
+ | MODULE
+ | OPEN
+ | REQUIRES
+ | EXPORTS
+ | OPENS
+ | TO
+ | USES
+ | PROVIDES
+ | WITH
+ | TRANSITIVE
+ | YIELD
+ | SEALED
+ | PERMITS
+ | RECORD
+ | VAR
+ ;
+
+localTypeDeclaration
+ : classOrInterfaceModifier*
+ (classDeclaration | interfaceDeclaration | recordDeclaration)
+ | ';'
+ ;
+
+statement
+ : blockLabel=block
+ | ASSERT expression (':' expression)? ';'
+ | IF parExpression statement (ELSE statement)?
+ | FOR '(' forControl ')' statement
+ | WHILE parExpression statement
+ | DO statement WHILE parExpression ';'
+ | TRY block (catchClause+ finallyBlock? | finallyBlock)
+ | TRY resourceSpecification block catchClause* finallyBlock?
+ | SWITCH parExpression '{' switchBlockStatementGroup* switchLabel* '}'
+ | SYNCHRONIZED parExpression block
+ | RETURN expression? ';'
+ | THROW expression ';'
+ | BREAK identifier? ';'
+ | CONTINUE identifier? ';'
+ | YIELD expression ';' // Java17
+ | SEMI
+ | statementExpression=expression ';'
+ | switchExpression ';'? // Java17
+ | identifierLabel=identifier ':' statement
+ ;
+
+catchClause
+ : CATCH '(' variableModifier* catchType identifier ')' block
+ ;
+
+catchType
+ : qualifiedName ('|' qualifiedName)*
+ ;
+
+finallyBlock
+ : FINALLY block
+ ;
+
+resourceSpecification
+ : '(' resources ';'? ')'
+ ;
+
+resources
+ : resource (';' resource)*
+ ;
+
+resource
+ : variableModifier* ( classOrInterfaceType variableDeclaratorId | VAR identifier ) '=' expression
+ | identifier
+ ;
+
+/** Matches cases then statements, both of which are mandatory.
+ * To handle empty cases at the end, we add switchLabel* to statement.
+ */
+switchBlockStatementGroup
+ : switchLabel+ blockStatement+
+ ;
+
+switchLabel
+ : CASE (constantExpression=expression | enumConstantName=IDENTIFIER | typeType varName=identifier) ':'
+ | DEFAULT ':'
+ ;
+
+forControl
+ : enhancedForControl
+ | forInit? ';' expression? ';' forUpdate=expressionList?
+ ;
+
+forInit
+ : localVariableDeclaration
+ | expressionList
+ ;
+
+enhancedForControl
+ : variableModifier* (typeType | VAR) variableDeclaratorId ':' expression
+ ;
+
+// EXPRESSIONS
+
+parExpression
+ : '(' expression ')'
+ ;
+
+expressionList
+ : expression (',' expression)*
+ ;
+
+methodCall
+ : identifier '(' expressionList? ')'
+ | THIS '(' expressionList? ')'
+ | SUPER '(' expressionList? ')'
+ ;
+
+expression
+ : primary
+ | expression bop='.'
+ (
+ identifier
+ | methodCall
+ | THIS
+ | NEW nonWildcardTypeArguments? innerCreator
+ | SUPER superSuffix
+ | explicitGenericInvocation
+ )
+ | expression '[' expression ']'
+ | methodCall
+ | NEW creator
+ | '(' annotation* typeType ('&' typeType)* ')' expression
+ | expression postfix=('++' | '--')
+ | prefix=('+'|'-'|'++'|'--') expression
+ | prefix=('~'|'!') expression
+ | expression bop=('*'|'/'|'%') expression
+ | expression bop=('+'|'-') expression
+ | expression ('<' '<' | '>' '>' '>' | '>' '>') expression
+ | expression bop=('<=' | '>=' | '>' | '<') expression
+ | expression bop=INSTANCEOF (typeType | pattern)
+ | expression bop=('==' | '!=') expression
+ | expression bop='&' expression
+ | expression bop='^' expression
+ | expression bop='|' expression
+ | expression bop='&&' expression
+ | expression bop='||' expression
+ | expression bop='?' expression ':' expression
+ | expression
+ bop=('=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '>>=' | '>>>=' | '<<=' | '%=')
+ expression
+ | lambdaExpression // Java8
+ | switchExpression // Java17
+
+ // Java 8 methodReference
+ | expression '::' typeArguments? identifier
+ | typeType '::' (typeArguments? identifier | NEW)
+ | classType '::' typeArguments? NEW
+ ;
+
+// Java17
+pattern
+ : variableModifier* typeType annotation* identifier
+ ;
+
+// Java8
+lambdaExpression
+ : lambdaParameters '->' lambdaBody
+ ;
+
+// Java8
+lambdaParameters
+ : identifier
+ | '(' formalParameterList? ')'
+ | '(' identifier (',' identifier)* ')'
+ | '(' lambdaLVTIList? ')'
+ ;
+
+// Java8
+lambdaBody
+ : expression
+ | block
+ ;
+
+primary
+ : '(' expression ')'
+ | THIS
+ | SUPER
+ | literal
+ | identifier
+ | typeTypeOrVoid '.' CLASS
+ | nonWildcardTypeArguments (explicitGenericInvocationSuffix | THIS arguments)
+ ;
+
+// Java17
+switchExpression
+ : SWITCH parExpression '{' switchLabeledRule* '}'
+ ;
+
+// Java17
+switchLabeledRule
+ : CASE (expressionList | NULL_LITERAL | guardedPattern) (ARROW | COLON) switchRuleOutcome
+ | DEFAULT (ARROW | COLON) switchRuleOutcome
+ ;
+
+// Java17
+guardedPattern
+ : '(' guardedPattern ')'
+ | variableModifier* typeType annotation* identifier ('&&' expression)*
+ | guardedPattern '&&' expression
+ ;
+
+// Java17
+switchRuleOutcome
+ : block
+ | blockStatement*
+ ;
+
+classType
+ : (classOrInterfaceType '.')? annotation* identifier typeArguments?
+ ;
+
+creator
+ : nonWildcardTypeArguments createdName classCreatorRest
+ | createdName (arrayCreatorRest | classCreatorRest)
+ ;
+
+createdName
+ : identifier typeArgumentsOrDiamond? ('.' identifier typeArgumentsOrDiamond?)*
+ | primitiveType
+ ;
+
+innerCreator
+ : identifier nonWildcardTypeArgumentsOrDiamond? classCreatorRest
+ ;
+
+arrayCreatorRest
+ : '[' (']' ('[' ']')* arrayInitializer | expression ']' ('[' expression ']')* ('[' ']')*)
+ ;
+
+classCreatorRest
+ : arguments classBody?
+ ;
+
+explicitGenericInvocation
+ : nonWildcardTypeArguments explicitGenericInvocationSuffix
+ ;
+
+typeArgumentsOrDiamond
+ : '<' '>'
+ | typeArguments
+ ;
+
+nonWildcardTypeArgumentsOrDiamond
+ : '<' '>'
+ | nonWildcardTypeArguments
+ ;
+
+nonWildcardTypeArguments
+ : '<' typeList '>'
+ ;
+
+typeList
+ : typeType (',' typeType)*
+ ;
+
+typeType
+ : annotation* (classOrInterfaceType | primitiveType) (annotation* '[' ']')*
+ ;
+
+primitiveType
+ : BOOLEAN
+ | CHAR
+ | BYTE
+ | SHORT
+ | INT
+ | LONG
+ | FLOAT
+ | DOUBLE
+ ;
+
+typeArguments
+ : '<' typeArgument (',' typeArgument)* '>'
+ ;
+
+superSuffix
+ : arguments
+ | '.' typeArguments? identifier arguments?
+ ;
+
+explicitGenericInvocationSuffix
+ : SUPER superSuffix
+ | identifier arguments
+ ;
+
+arguments
+ : '(' expressionList? ')'
+ ;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/OptimizerContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/OptimizerContext.java
index 9956aacaef..d5ac07f27f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/OptimizerContext.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/OptimizerContext.java
@@ -29,7 +29,7 @@ import org.apache.doris.nereids.trees.TreeNode;
/**
* Context used in memo.
*/
-public class OptimizerContext {
+public class OptimizerContext> {
private final Memo memo;
private RuleSet ruleSet;
private JobPool jobPool;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/PlanOperatorVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/PlanOperatorVisitor.java
index 063f92aae7..bd69b5a230 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/PlanOperatorVisitor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/PlanOperatorVisitor.java
@@ -17,7 +17,6 @@
package org.apache.doris.nereids;
-import org.apache.doris.nereids.operators.Operator;
import org.apache.doris.nereids.operators.plans.physical.PhysicalAggregation;
import org.apache.doris.nereids.operators.plans.physical.PhysicalFilter;
import org.apache.doris.nereids.operators.plans.physical.PhysicalHashJoin;
@@ -25,7 +24,9 @@ import org.apache.doris.nereids.operators.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.operators.plans.physical.PhysicalProject;
import org.apache.doris.nereids.operators.plans.physical.PhysicalSort;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalBinaryPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalLeafPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
/**
* Base class for the processing of logical and physical plan.
@@ -36,35 +37,29 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
@SuppressWarnings("rawtypes")
public abstract class PlanOperatorVisitor {
- public abstract R visit(Plan extends Plan, ? extends Operator> plan, C context);
+ public abstract R visit(Plan plan, C context);
- public R visitPhysicalAggregationPlan(PhysicalPlan extends PhysicalPlan, PhysicalAggregation> aggPlan,
- C context) {
+ public R visitPhysicalAggregationPlan(PhysicalUnaryPlan aggPlan, C context) {
return null;
}
- public R visitPhysicalOlapScanPlan(PhysicalPlan extends PhysicalPlan, PhysicalOlapScan> olapScanPlan,
- C context) {
+ public R visitPhysicalOlapScanPlan(PhysicalLeafPlan olapScanPlan, C context) {
return null;
}
- public R visitPhysicalSortPlan(PhysicalPlan extends PhysicalPlan, PhysicalSort> sortPlan,
- C context) {
+ public R visitPhysicalSortPlan(PhysicalUnaryPlan sortPlan, C context) {
return null;
}
- public R visitPhysicalHashJoinPlan(PhysicalPlan extends PhysicalPlan, PhysicalHashJoin> hashJoinPlan,
- C context) {
+ public R visitPhysicalHashJoinPlan(PhysicalBinaryPlan hashJoinPlan, C context) {
return null;
}
- public R visitPhysicalProject(PhysicalPlan extends PhysicalPlan, PhysicalProject> projectPlan,
- C context) {
+ public R visitPhysicalProject(PhysicalUnaryPlan projectPlan, C context) {
return null;
}
- public R visitPhysicalFilter(PhysicalPlan extends PhysicalPlan, PhysicalFilter> filterPlan,
- C context) {
+ public R visitPhysicalFilter(PhysicalUnaryPlan filterPlan, C context) {
return null;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
index 23272aaf7e..d7140292f4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
@@ -29,8 +29,9 @@ import java.util.List;
/**
* Expression for unbound alias.
*/
-public class UnboundAlias extends NamedExpression>
- implements UnaryExpression, CHILD_TYPE> {
+public class UnboundAlias
+ extends NamedExpression
+ implements UnaryExpression {
public UnboundAlias(CHILD_TYPE child) {
super(NodeType.UNBOUND_ALIAS, child);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
index ca69806022..550894126d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
@@ -32,7 +32,7 @@ import java.util.List;
/**
* Represent a relation plan node that has not been bound.
*/
-public class UnboundRelation extends LogicalLeafOperator {
+public class UnboundRelation extends LogicalLeafOperator {
private final List nameParts;
public UnboundRelation(List nameParts) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
index c0a20a529f..5d1d4d7cbb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
@@ -28,7 +28,7 @@ import java.util.List;
/**
* Slot has not been bound.
*/
-public class UnboundSlot extends Slot {
+public class UnboundSlot extends Slot {
private final List nameParts;
public UnboundSlot(List nameParts) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundStar.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundStar.java
index ce4c9c1ca4..11b8a54d3d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundStar.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundStar.java
@@ -29,7 +29,7 @@ import java.util.List;
/**
* Star expression.
*/
-public class UnboundStar extends NamedExpression implements LeafExpression {
+public class UnboundStar extends NamedExpression implements LeafExpression {
private final List target;
public UnboundStar(List target) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/Job.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/Job.java
index 28b3e01dcd..9ab88961cb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/Job.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/Job.java
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
/**
* Abstract class for all job using for analyze and optimize query plan in Nereids.
*/
-public abstract class Job {
+public abstract class Job> {
protected JobType type;
protected PlannerContext context;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteBottomUpJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteBottomUpJob.java
index fcada408a7..b82ca9f280 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteBottomUpJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteBottomUpJob.java
@@ -35,7 +35,7 @@ import java.util.Objects;
/**
* Bottom up job for rewrite, use pattern match.
*/
-public class RewriteBottomUpJob extends Job {
+public class RewriteBottomUpJob> extends Job {
private final Group group;
private final List> rules;
private final boolean childrenOptimized;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java
index 9ea29d7bd2..64b348510d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java
@@ -34,7 +34,7 @@ import java.util.Objects;
/**
* Top down job for rewrite, use pattern match.
*/
-public class RewriteTopDownJob extends Job {
+public class RewriteTopDownJob> extends Job {
private final Group group;
private final List> rules;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
index f2bf9aac37..1158e6550e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
@@ -33,7 +33,7 @@ import java.util.Map;
*
* @param should be {@link Plan} or {@link Expression}
*/
-public class Memo {
+public class Memo> {
private final List groups = Lists.newArrayList();
// we could not use Set, because Set has no get method.
private final Map groupExpressions = Maps.newHashMap();
@@ -59,12 +59,11 @@ public class Memo {
public GroupExpression copyIn(NODE_TYPE node, Group target, boolean rewrite) {
Preconditions.checkArgument(!rewrite || target != null);
List childrenGroups = Lists.newArrayList();
- for (Object object : node.children()) {
- NODE_TYPE child = (NODE_TYPE) object;
+ for (NODE_TYPE child : node.children()) {
childrenGroups.add(copyIn(child, null, rewrite).getParent());
}
- if (node.getGroupExpression() != null && groupExpressions.containsKey(node.getGroupExpression())) {
- return node.getGroupExpression();
+ if (node.getGroupExpression().isPresent() && groupExpressions.containsKey(node.getGroupExpression().get())) {
+ return node.getGroupExpression().get();
}
GroupExpression newGroupExpression = new GroupExpression(node.getOperator());
newGroupExpression.setChildren(childrenGroups);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/AbstractOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/AbstractOperator.java
index 137317cbeb..6363fbcae4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/AbstractOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/AbstractOperator.java
@@ -25,7 +25,7 @@ import java.util.Objects;
/**
* Abstract class for all concrete operator.
*/
-public abstract class AbstractOperator> implements Operator {
+public abstract class AbstractOperator implements Operator {
protected final OperatorType type;
protected final long limited;
@@ -52,7 +52,7 @@ public abstract class AbstractOperator> impl
* (PhysicalPlan extends PhysicalPlan, PhysicalOlapScan>) plan, context);
*
*/
- public R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
return null;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/Operator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/Operator.java
index efecb3a201..b391ff24a5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/Operator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/Operator.java
@@ -25,11 +25,11 @@ import org.apache.doris.nereids.trees.plans.Plan;
/**
* interface for all concrete operator.
*/
-public interface Operator> {
+public interface Operator {
OperatorType getType();
- NODE_TYPE toTreeNode(GroupExpression groupExpression);
+ > NODE_TYPE toTreeNode(GroupExpression groupExpression);
- public R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context);
+ R accept(PlanOperatorVisitor visitor, Plan plan, C context);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/OperatorType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/OperatorType.java
index f1a183521f..f2ddc06716 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/OperatorType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/OperatorType.java
@@ -46,6 +46,7 @@ public enum OperatorType {
PHYSICAL_EXCHANGE,
// pattern
+ NORMAL_PATTERN,
ANY,
MULTI,
FIXED,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/BinaryPlanOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/BinaryPlanOperator.java
index aa46862efc..30fea7cbac 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/BinaryPlanOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/BinaryPlanOperator.java
@@ -17,13 +17,8 @@
package org.apache.doris.nereids.operators.plans;
-import org.apache.doris.nereids.trees.plans.Plan;
-
/**
* interface for all concrete binary plan operator.
*/
-public interface BinaryPlanOperator<
- TYPE extends BinaryPlanOperator,
- LEFT_INPUT_TYPE extends Plan,
- RIGHT_INPUT_TYPE extends Plan> extends PlanOperator {
+public interface BinaryPlanOperator extends PlanOperator {
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/LeafPlanOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/LeafPlanOperator.java
index 3fc89d8d26..9efe4c0386 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/LeafPlanOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/LeafPlanOperator.java
@@ -20,5 +20,5 @@ package org.apache.doris.nereids.operators.plans;
/**
* interface for all concrete leaf plan operator.
*/
-public interface LeafPlanOperator> extends PlanOperator {
+public interface LeafPlanOperator extends PlanOperator {
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/PlanOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/PlanOperator.java
index 43adb3a4bf..b2b0342ebc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/PlanOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/PlanOperator.java
@@ -22,5 +22,5 @@ import org.apache.doris.nereids.operators.Operator;
/**
* interface for all concrete plan operator.
*/
-public interface PlanOperator> extends Operator {
+public interface PlanOperator extends Operator {
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/UnaryPlanOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/UnaryPlanOperator.java
index 8dfa3f19c4..321f7a6f78 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/UnaryPlanOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/UnaryPlanOperator.java
@@ -17,12 +17,8 @@
package org.apache.doris.nereids.operators.plans;
-import org.apache.doris.nereids.trees.plans.Plan;
-
/**
* interface for all concrete unary plan operator.
*/
-public interface UnaryPlanOperator<
- TYPE extends UnaryPlanOperator,
- INPUT_TYPE extends Plan> extends PlanOperator {
+public interface UnaryPlanOperator extends PlanOperator {
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalBinaryOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalBinaryOperator.java
index 1b35a686d1..228ee08358 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalBinaryOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalBinaryOperator.java
@@ -25,19 +25,15 @@ import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.PlaceHolderPlan;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.logical.LogicalBinary;
+import org.apache.doris.nereids.trees.plans.logical.LogicalBinaryPlan;
import java.util.List;
/**
* Abstract class for all logical binary operator that have two inputs.
*/
-public abstract class LogicalBinaryOperator<
- TYPE extends LogicalBinaryOperator,
- LEFT_INPUT_TYPE extends Plan,
- RIGHT_INPUT_TYPE extends Plan>
- extends AbstractOperator
- implements LogicalOperator, BinaryPlanOperator {
+public abstract class LogicalBinaryOperator extends AbstractOperator
+ implements LogicalOperator, BinaryPlanOperator {
public LogicalBinaryOperator(OperatorType type) {
super(type);
@@ -45,15 +41,15 @@ public abstract class LogicalBinaryOperator<
@Override
public final List computeOutput(Plan... inputs) {
- return doComputeOutput((LEFT_INPUT_TYPE) inputs[0], (RIGHT_INPUT_TYPE) inputs[1]);
+ return doComputeOutput(inputs[0], inputs[1]);
}
- public abstract List doComputeOutput(LEFT_INPUT_TYPE left, RIGHT_INPUT_TYPE right);
+ public abstract List doComputeOutput(Plan left, Plan right);
@Override
- public LogicalBinary toTreeNode(GroupExpression groupExpression) {
+ public LogicalBinaryPlan toTreeNode(GroupExpression groupExpression) {
LogicalProperties logicalProperties = groupExpression.getParent().getLogicalProperties();
- return new LogicalBinary(this, groupExpression, logicalProperties,
+ return new LogicalBinaryPlan(this, groupExpression, logicalProperties,
new PlaceHolderPlan(), new PlaceHolderPlan());
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalFilter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalFilter.java
index 4d5ffd6862..c7d579898c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalFilter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalFilter.java
@@ -28,8 +28,7 @@ import java.util.Objects;
/**
* Logical filter plan operator.
*/
-public class LogicalFilter
- extends LogicalUnaryOperator, INPUT_TYPE> {
+public class LogicalFilter extends LogicalUnaryOperator {
private final Expression predicates;
@@ -44,7 +43,7 @@ public class LogicalFilter
@Override
- public List doComputeOutput(INPUT_TYPE input) {
+ public List doComputeOutput(Plan input) {
return input.getOutput();
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalJoin.java
index 2ecdbafb4c..b1672627bd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalJoin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalJoin.java
@@ -33,9 +33,7 @@ import java.util.Optional;
/**
* Logical join plan operator.
*/
-public class LogicalJoin
- extends LogicalBinaryOperator,
- LEFT_INPUT_TYPE, RIGHT_INPUT_TYPE> {
+public class LogicalJoin extends LogicalBinaryOperator {
private final JoinType joinType;
private final Optional onClause;
@@ -73,7 +71,7 @@ public class LogicalJoin doComputeOutput(LEFT_INPUT_TYPE leftInput, RIGHT_INPUT_TYPE rightInput) {
+ public List doComputeOutput(Plan leftInput, Plan rightInput) {
switch (joinType) {
case LEFT_SEMI_JOIN:
return ImmutableList.copyOf(leftInput.getOutput());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalLeafOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalLeafOperator.java
index 9ce54fee3a..44c72f06e6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalLeafOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalLeafOperator.java
@@ -23,16 +23,15 @@ import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.operators.plans.LeafPlanOperator;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.logical.LogicalLeaf;
+import org.apache.doris.nereids.trees.plans.logical.LogicalLeafPlan;
import java.util.List;
/**
* Abstract class for all logical operator that have no input.
*/
-public abstract class LogicalLeafOperator>
- extends AbstractOperator
- implements LogicalOperator, LeafPlanOperator {
+public abstract class LogicalLeafOperator extends AbstractOperator
+ implements LogicalOperator, LeafPlanOperator {
public LogicalLeafOperator(OperatorType type) {
super(type);
@@ -46,7 +45,7 @@ public abstract class LogicalLeafOperator
public abstract List doComputeOutput();
@Override
- public LogicalLeaf toTreeNode(GroupExpression groupExpression) {
- return new LogicalLeaf(this, groupExpression, groupExpression.getParent().getLogicalProperties());
+ public LogicalLeafPlan toTreeNode(GroupExpression groupExpression) {
+ return new LogicalLeafPlan(this, groupExpression, groupExpression.getParent().getLogicalProperties());
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalOperator.java
index 4c22b7371d..0421f8f159 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalOperator.java
@@ -26,6 +26,6 @@ import java.util.List;
/**
* interface for all concrete logical plan operator.
*/
-public interface LogicalOperator> extends PlanOperator {
+public interface LogicalOperator extends PlanOperator {
List computeOutput(Plan... inputs);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalProject.java
index 9428a69121..5554542443 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalProject.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalProject.java
@@ -32,8 +32,7 @@ import java.util.Objects;
/**
* Logical project plan operator.
*/
-public class LogicalProject
- extends LogicalUnaryOperator, INPUT_TYPE> {
+public class LogicalProject extends LogicalUnaryOperator {
private final List extends NamedExpression> projects;
@@ -57,7 +56,7 @@ public class LogicalProject
}
@Override
- public List doComputeOutput(INPUT_TYPE input) {
+ public List doComputeOutput(Plan input) {
// fixme: not throw a checked exception
return projects.stream()
.map(namedExpr -> {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalRelation.java
index 61048e994b..6f01817b82 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalRelation.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalRelation.java
@@ -31,7 +31,7 @@ import java.util.Objects;
/**
* Logical relation plan operator.
*/
-public class LogicalRelation extends LogicalLeafOperator {
+public class LogicalRelation extends LogicalLeafOperator {
private final Table table;
private final List qualifier;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalUnaryOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalUnaryOperator.java
index 5c2345a69d..b04f2ae8f3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalUnaryOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/logical/LogicalUnaryOperator.java
@@ -25,18 +25,15 @@ import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.PlaceHolderPlan;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.logical.LogicalUnary;
+import org.apache.doris.nereids.trees.plans.logical.LogicalUnaryPlan;
import java.util.List;
/**
* Abstract class for all logical operator that have one input.
*/
-public abstract class LogicalUnaryOperator<
- TYPE extends LogicalUnaryOperator,
- INPUT_TYPE extends Plan>
- extends AbstractOperator
- implements LogicalOperator, UnaryPlanOperator {
+public abstract class LogicalUnaryOperator extends AbstractOperator
+ implements LogicalOperator, UnaryPlanOperator {
public LogicalUnaryOperator(OperatorType type) {
super(type);
@@ -44,14 +41,14 @@ public abstract class LogicalUnaryOperator<
@Override
public final List computeOutput(Plan... inputs) {
- return doComputeOutput((INPUT_TYPE) inputs[0]);
+ return doComputeOutput(inputs[0]);
}
- public abstract List doComputeOutput(INPUT_TYPE input);
+ public abstract List doComputeOutput(Plan input);
@Override
- public LogicalUnary toTreeNode(GroupExpression groupExpression) {
+ public LogicalUnaryPlan toTreeNode(GroupExpression groupExpression) {
LogicalProperties logicalProperties = groupExpression.getParent().getLogicalProperties();
- return new LogicalUnary(this, groupExpression, logicalProperties, new PlaceHolderPlan());
+ return new LogicalUnaryPlan(this, groupExpression, logicalProperties, new PlaceHolderPlan());
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalAggregation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalAggregation.java
index feb72bd837..3240435917 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalAggregation.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalAggregation.java
@@ -22,14 +22,14 @@ import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.operators.plans.AggPhase;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
import java.util.List;
/**
* Physical aggregation plan operator.
*/
-public class PhysicalAggregation extends PhysicalUnaryOperator {
+public class PhysicalAggregation extends PhysicalUnaryOperator {
private final List groupByExprList;
@@ -80,8 +80,7 @@ public class PhysicalAggregation extends PhysicalUnaryOperator R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalAggregationPlan(
- (PhysicalPlan extends PhysicalPlan, PhysicalAggregation>) plan, context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalAggregationPlan((PhysicalUnaryPlan) plan, context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBinaryOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBinaryOperator.java
index 40c7774680..813cb3d445 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBinaryOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBinaryOperator.java
@@ -25,19 +25,15 @@ import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.PlaceHolderPlan;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalBinary;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalBinaryPlan;
import java.util.List;
/**
* Abstract class for all physical operator that have two inputs.
*/
-public abstract class PhysicalBinaryOperator<
- TYPE extends PhysicalBinaryOperator,
- LEFT_INPUT_TYPE extends Plan,
- RIGHT_INPUT_TYPE extends Plan>
- extends AbstractOperator
- implements PhysicalOperator, BinaryPlanOperator {
+public abstract class PhysicalBinaryOperator extends AbstractOperator
+ implements PhysicalOperator, BinaryPlanOperator {
public PhysicalBinaryOperator(OperatorType type) {
super(type);
@@ -45,18 +41,17 @@ public abstract class PhysicalBinaryOperator<
@Override
public final List computeOutputs(LogicalProperties logicalProperties, Plan... inputs) {
- return doComputeOutput(logicalProperties, (LEFT_INPUT_TYPE) inputs[0], (RIGHT_INPUT_TYPE) inputs[1]);
+ return doComputeOutput(logicalProperties, inputs[0], inputs[1]);
}
- public List doComputeOutput(LogicalProperties logicalProperties,
- LEFT_INPUT_TYPE left, RIGHT_INPUT_TYPE right) {
+ public List doComputeOutput(LogicalProperties logicalProperties, Plan left, Plan right) {
return logicalProperties.getOutput();
}
@Override
- public PhysicalBinary toTreeNode(GroupExpression groupExpression) {
+ public PhysicalBinaryPlan toTreeNode(GroupExpression groupExpression) {
LogicalProperties logicalProperties = groupExpression.getParent().getLogicalProperties();
- return new PhysicalBinary(this, groupExpression, logicalProperties,
+ return new PhysicalBinaryPlan(this, groupExpression, logicalProperties,
new PlaceHolderPlan(), new PlaceHolderPlan());
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBroadcastHashJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBroadcastHashJoin.java
index cf03bf55f9..3ccbf70657 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBroadcastHashJoin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalBroadcastHashJoin.java
@@ -28,9 +28,7 @@ import java.util.Optional;
/**
* Physical operator represents broadcast hash join.
*/
-public class PhysicalBroadcastHashJoin
- extends PhysicalBinaryOperator,
- LEFT_INPUT_TYPE, RIGHT_INPUT_TYPE> {
+public class PhysicalBroadcastHashJoin extends PhysicalBinaryOperator {
private final JoinType joinType;
private final Optional onClause;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalFilter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalFilter.java
index f62b69e3ad..aa54b67caa 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalFilter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalFilter.java
@@ -21,15 +21,14 @@ import org.apache.doris.nereids.PlanOperatorVisitor;
import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
import java.util.Objects;
/**
* Physical filter plan operator.
*/
-public class PhysicalFilter
- extends PhysicalUnaryOperator, INPUT_TYPE> {
+public class PhysicalFilter extends PhysicalUnaryOperator {
private final Expression predicates;
@@ -54,8 +53,7 @@ public class PhysicalFilter
}
@Override
- public R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalFilter((PhysicalPlan extends PhysicalPlan, PhysicalFilter>) plan,
- context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalFilter((PhysicalUnaryPlan) plan, context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalHashJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalHashJoin.java
index 41785dbab8..94eb6f9147 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalHashJoin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalHashJoin.java
@@ -22,12 +22,12 @@ import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.operators.plans.JoinType;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalBinaryPlan;
/**
* Physical hash join plan operator.
*/
-public class PhysicalHashJoin extends PhysicalBinaryOperator {
+public class PhysicalHashJoin extends PhysicalBinaryOperator {
private final JoinType joinType;
@@ -54,9 +54,8 @@ public class PhysicalHashJoin extends PhysicalBinaryOperator R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalHashJoinPlan(
- (PhysicalPlan extends PhysicalPlan, PhysicalHashJoin>) plan, context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalHashJoinPlan((PhysicalBinaryPlan) plan, context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalLeafOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalLeafOperator.java
index 1093e6086d..6cf64ede7c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalLeafOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalLeafOperator.java
@@ -24,16 +24,15 @@ import org.apache.doris.nereids.operators.plans.LeafPlanOperator;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLeaf;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalLeafPlan;
import java.util.List;
/**
* Abstract class for all physical operator that have no input.
*/
-public abstract class PhysicalLeafOperator>
- extends AbstractOperator
- implements PhysicalOperator, LeafPlanOperator {
+public abstract class PhysicalLeafOperator extends AbstractOperator
+ implements PhysicalOperator, LeafPlanOperator {
public PhysicalLeafOperator(OperatorType type) {
super(type);
@@ -49,7 +48,7 @@ public abstract class PhysicalLeafOperator {
+public class PhysicalOlapScan extends PhysicalScan {
private final long selectedIndexId;
private final List selectedTabletId;
private final List selectedPartitionId;
@@ -80,9 +80,8 @@ public class PhysicalOlapScan extends PhysicalScan {
}
@Override
- public R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalOlapScanPlan(
- (PhysicalPlan extends PhysicalPlan, PhysicalOlapScan>) plan, context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalOlapScanPlan((PhysicalLeafPlan) plan, context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalOperator.java
index dd5aa79a9f..8414f6356d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalOperator.java
@@ -27,7 +27,7 @@ import java.util.List;
/**
* interface for all concrete physical operator.
*/
-public interface PhysicalOperator> extends PlanOperator {
+public interface PhysicalOperator extends PlanOperator {
List computeOutputs(LogicalProperties logicalProperties, Plan... inputs);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalProject.java
index d5046083bf..5de5fc8c01 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalProject.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalProject.java
@@ -21,7 +21,7 @@ import org.apache.doris.nereids.PlanOperatorVisitor;
import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
import org.apache.commons.lang3.StringUtils;
@@ -31,8 +31,7 @@ import java.util.Objects;
/**
* Physical project plan operator.
*/
-public class PhysicalProject
- extends PhysicalUnaryOperator, INPUT_TYPE> {
+public class PhysicalProject extends PhysicalUnaryOperator {
private final List extends NamedExpression> projects;
@@ -51,8 +50,7 @@ public class PhysicalProject
}
@Override
- public R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalProject(
- (PhysicalPlan extends PhysicalPlan, PhysicalProject>) plan, context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalProject(((PhysicalUnaryPlan) plan), context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalScan.java
index 10d434c7e2..63ffef9b0f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalScan.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalScan.java
@@ -25,7 +25,7 @@ import java.util.Objects;
/**
* Abstract class for all physical scan operator.
*/
-public abstract class PhysicalScan> extends PhysicalLeafOperator {
+public abstract class PhysicalScan extends PhysicalLeafOperator {
protected final List qualifier;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalSort.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalSort.java
index 1dcb3d6540..dc1ab43b70 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalSort.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalSort.java
@@ -21,14 +21,14 @@ import org.apache.doris.nereids.PlanOperatorVisitor;
import org.apache.doris.nereids.operators.OperatorType;
import org.apache.doris.nereids.properties.OrderKey;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
import java.util.List;
/**
* Physical sort plan operator.
*/
-public class PhysicalSort extends PhysicalUnaryOperator {
+public class PhysicalSort extends PhysicalUnaryOperator {
private final int offset;
@@ -70,8 +70,7 @@ public class PhysicalSort extends PhysicalUnaryOperator R accept(PlanOperatorVisitor visitor, Plan, ?> plan, C context) {
- return visitor.visitPhysicalSortPlan((PhysicalPlan extends PhysicalPlan, PhysicalSort>) plan,
- context);
+ public R accept(PlanOperatorVisitor visitor, Plan plan, C context) {
+ return visitor.visitPhysicalSortPlan((PhysicalUnaryPlan) plan, context);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalUnaryOperator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalUnaryOperator.java
index 80f54d3ab6..daecac8191 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalUnaryOperator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/operators/plans/physical/PhysicalUnaryOperator.java
@@ -25,18 +25,15 @@ import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.PlaceHolderPlan;
import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalUnary;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalUnaryPlan;
import java.util.List;
/**
* Abstract class for all physical operator that have one input.
*/
-public abstract class PhysicalUnaryOperator<
- TYPE extends PhysicalUnaryOperator,
- INPUT_TYPE extends Plan>
- extends AbstractOperator
- implements PhysicalOperator, UnaryPlanOperator {
+public abstract class PhysicalUnaryOperator extends AbstractOperator
+ implements PhysicalOperator, UnaryPlanOperator {
public PhysicalUnaryOperator(OperatorType type) {
super(type);
@@ -44,16 +41,16 @@ public abstract class PhysicalUnaryOperator<
@Override
public final List computeOutputs(LogicalProperties logicalProperties, Plan... inputs) {
- return doComputeOutput(logicalProperties, (INPUT_TYPE) inputs[0]);
+ return doComputeOutput(logicalProperties, inputs[0]);
}
- public List doComputeOutput(LogicalProperties logicalProperties, INPUT_TYPE input) {
+ public List doComputeOutput(LogicalProperties logicalProperties, Plan input) {
return logicalProperties.getOutput();
}
@Override
- public PhysicalUnary toTreeNode(GroupExpression groupExpression) {
+ public PhysicalUnaryPlan toTreeNode(GroupExpression groupExpression) {
LogicalProperties logicalProperties = groupExpression.getParent().getLogicalProperties();
- return new PhysicalUnary(this, groupExpression, logicalProperties, new PlaceHolderPlan());
+ return new PhysicalUnaryPlan(this, groupExpression, logicalProperties, new PlaceHolderPlan());
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 77c827433e..c70b8a4dc4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -66,10 +66,10 @@ import org.apache.doris.nereids.trees.expressions.Literal;
import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.expressions.Not;
import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
-import org.apache.doris.nereids.trees.plans.logical.LogicalBinary;
-import org.apache.doris.nereids.trees.plans.logical.LogicalLeaf;
+import org.apache.doris.nereids.trees.plans.logical.LogicalBinaryPlan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalLeafPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
-import org.apache.doris.nereids.trees.plans.logical.LogicalUnary;
+import org.apache.doris.nereids.trees.plans.logical.LogicalUnaryPlan;
import com.google.common.collect.Lists;
import org.antlr.v4.runtime.ParserRuleContext;
@@ -95,7 +95,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor