Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[opt](Nereids) add job, analyze, load and cancel statements syntax #40203

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 151 additions & 20 deletions fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ unsupportedStatement
| unsupportedAdminStatement
| unsupportedTransactionStatement
| unsupportedRecoverStatement
| unsupportedCancelStatement
| unsupportedJobStatement
| unsupportedCleanStatement
| unsupportedRefreshStatement
| unsupportedLoadStatement
| unsupportedOtherStatement
;

Expand Down Expand Up @@ -121,14 +126,11 @@ supportedDmlStatement
partitionSpec? tableAlias
(USING relations)?
whereClause? #delete
| LOAD LABEL lableName=identifier
| LOAD LABEL lableName=multipartIdentifier
LEFT_PAREN dataDescs+=dataDesc (COMMA dataDescs+=dataDesc)* RIGHT_PAREN
(withRemoteStorageSystem)?
(PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)?
propertyClause?
(commentSpec)? #load
| LOAD mysqlDataDesc
(PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)?
(commentSpec)? #mysqlLoad
| EXPORT TABLE tableName=multipartIdentifier
(PARTITION partition=identifierList)?
(whereClause)?
Expand Down Expand Up @@ -200,6 +202,130 @@ lockTable
(READ (LOCAL)? | (LOW_PRIORITY)? WRITE)
;

unsupportedLoadStatement
: LOAD mysqlDataDesc
(PROPERTIES LEFT_PAREN properties=propertyItemList RIGHT_PAREN)?
(commentSpec)? #mysqlLoad
| CREATE SYNC label=multipartIdentifier
LEFT_PAREN channelDescriptions RIGHT_PAREN
FROM BINLOG LEFT_PAREN propertyItemList RIGHT_PAREN
properties=propertyClause? #createDataSyncJob
| STOP SYNC JOB name=multipartIdentifier #stopDataSyncJob
| RESUME SYNC JOB name=multipartIdentifier #resumeDataSyncJob
| PAUSE SYNC JOB name=multipartIdentifier #pauseDataSyncJob
| CREATE ROUTINE LOAD label=multipartIdentifier (ON table=identifier)?
(WITH (APPEND | DELETE | MERGE))?
(loadProperty (COMMA loadProperty)*)? propertyClause? FROM type=identifier
LEFT_PAREN customProperties=propertyItemList RIGHT_PAREN
commentSpec? #createRoutineLoadJob
| PAUSE ROUTINE LOAD FOR label=multipartIdentifier #pauseRoutineLoad
| PAUSE ALL ROUTINE LOAD #pauseAllRoutineLoad
| RESUME ROUTINE LOAD FOR label=multipartIdentifier #resumeRoutineLoad
| RESUME ALL ROUTINE LOAD #resumeAllRoutineLoad
| STOP ROUTINE LOAD FOR label=multipartIdentifier #stopRoutineLoad
| SHOW ALL? ROUTINE LOAD ((FOR label=multipartIdentifier) | wildWhere?) #showRoutineLoad
| SHOW ROUTINE LOAD TASK ((FROM | IN) database=identifier)? wildWhere? #showRoutineLoadTask
| SHOW ALL? CREATE ROUTINE LOAD FOR label=multipartIdentifier #showCreateRoutineLoad
| SHOW CREATE LOAD FOR label=multipartIdentifier #showCreateLoad
| SYNC #sync
| importSequenceStatement #importSequenceStatementAlias
| importPrecedingFilterStatement #importPrecedingFilterStatementAlias
| importWhereStatement #importWhereStatementAlias
| importDeleteOnStatement #importDeleteOnStatementAlias
| importColumnsStatement #importColumnsStatementAlias
;

loadProperty
: COLUMNS TERMINATED BY STRING_LITERAL #separator
| importColumnsStatement #importColumns
| importPrecedingFilterStatement #importPrecedingFilter
| importWhereStatement #importWhere
| importDeleteOnStatement #importDeleteOn
| importSequenceStatement #importSequence
| partitionSpec #importPartitions
;

importSequenceStatement
: ORDER BY identifier
;

importDeleteOnStatement
: DELETE ON booleanExpression
;

importWhereStatement
: WHERE booleanExpression
;

importPrecedingFilterStatement
: PRECEDING FILTER booleanExpression
;

importColumnsStatement
: COLUMNS LEFT_PAREN importColumnDesc (COMMA importColumnDesc)* RIGHT_PAREN
;

importColumnDesc
: name=identifier (EQ booleanExpression)?
| LEFT_PAREN name=identifier (EQ booleanExpression)? RIGHT_PAREN
;

channelDescriptions
: channelDescription (COMMA channelDescription)*
;

channelDescription
: FROM source=multipartIdentifier INTO destination=multipartIdentifier
partitionSpec? columnList=identifierList?
;

unsupportedRefreshStatement
: REFRESH TABLE name=multipartIdentifier #refreshTable
| REFRESH DATABASE name=multipartIdentifier propertyClause? #refreshDatabase
| REFRESH CATALOG name=identifier propertyClause? #refreshCatalog
| REFRESH LDAP (ALL | (FOR user=identifierOrText)) #refreshLdap
;

unsupportedCleanStatement
: CLEAN LABEL label=identifier? (FROM | IN) database=identifier #cleanLabel
| CLEAN ALL PROFILE #cleanAllProfile
| CLEAN QUERY STATS ((FOR database=identifier)
| ((FROM | IN) table=multipartIdentifier)) #cleanQueryStats
| CLEAN ALL QUERY STATS #cleanAllQueryStats
;

unsupportedJobStatement
: CREATE JOB label=multipartIdentifier ON SCHEDULE
(
(EVERY timeInterval=INTEGER_VALUE timeUnit=identifier
(STARTS (startTime=STRING_LITERAL | CURRENT_TIMESTAMP))?
(ENDS endsTime=STRING_LITERAL)?)
|
(AT (atTime=STRING_LITERAL | CURRENT_TIMESTAMP)))
commentSpec?
DO statement #createJob
| PAUSE JOB wildWhere? #pauseJob
| DROP JOB (IF EXISTS)? wildWhere? #dropJob
| RESUME JOB wildWhere? #resumeJob
| CANCEL TASK wildWhere? #cancelJobTask
;

unsupportedCancelStatement
: CANCEL LOAD ((FROM | IN) database=identifier)? wildWhere? #cancelLoad
| CANCEL EXPORT ((FROM | IN) database=identifier)? wildWhere? #cancelExport
| CANCEL ALTER TABLE (ROLLUP | (MATERIALIZED VIEW) | COLUMN)
FROM tableName=multipartIdentifier (LEFT_PAREN jobIds+=INTEGER_VALUE
(COMMA jobIds+=INTEGER_VALUE)* RIGHT_PAREN)? #cancelAlterTable
| CANCEL BUILD INDEX ON tableName=multipartIdentifier
(LEFT_PAREN jobIds+=INTEGER_VALUE
(COMMA jobIds+=INTEGER_VALUE)* RIGHT_PAREN)? #cancelBuildIndex
| CANCEL DECOMMISSION BACKEND hostPorts+=STRING_LITERAL
(COMMA hostPorts+=STRING_LITERAL)* #cancelDecommisionBackend
| CANCEL BACKUP ((FROM | IN) database=identifier)? #cancelBackup
| CANCEL RESTORE ((FROM | IN) database=identifier)? #cancelRestore
| CANCEL WARM UP JOB wildWhere? #cancelWarmUp
;

unsupportedRecoverStatement
: RECOVER DATABASE name=identifier id=INTEGER_VALUE? (AS alias=identifier)? #recoverDatabase
| RECOVER TABLE name=multipartIdentifier
Expand Down Expand Up @@ -421,7 +547,11 @@ unsupportedDropStatement
;

unsupportedStatsStatement
: ALTER TABLE name=multipartIdentifier SET STATS
: ANALYZE TABLE name=multipartIdentifier partitionSpec?
columns=identifierList? (WITH analyzeProperties)* propertyClause? #analyzeTable
| ANALYZE DATABASE name=multipartIdentifier
(WITH analyzeProperties)* propertyClause? #analyzeDatabase
| ALTER TABLE name=multipartIdentifier SET STATS
LEFT_PAREN propertyItemList RIGHT_PAREN partitionSpec? #alterTableStats
| ALTER TABLE name=multipartIdentifier (INDEX indexName=identifier)?
MODIFY COLUMN columnName=identifier
Expand All @@ -431,6 +561,19 @@ unsupportedStatsStatement
| DROP CACHED STATS tableName=multipartIdentifier #dropCachedStats
| DROP EXPIRED STATS #dropExpiredStats
| DROP ANALYZE JOB INTEGER_VALUE #dropAanalyzeJob
| KILL ANALYZE jobId=INTEGER_VALUE #killAnalyzeJob
;

analyzeProperties
: SYNC
| INCREMENTAL
| FULL
| SQL
| HISTOGRAM
| (SAMPLE ((ROWS rows=INTEGER_VALUE) | (PERCENT percent=INTEGER_VALUE)) )
| (BUCKETS bucket=INTEGER_VALUE)
| (PERIOD periodInSecond=INTEGER_VALUE)
| (CRON crontabExpr=STRING_LITERAL)
;

unsupportedCreateStatement
Expand Down Expand Up @@ -470,10 +613,6 @@ unsupportedCreateStatement
(ACTIONS LEFT_PAREN workloadPolicyActions RIGHT_PAREN)?
properties=propertyClause? #createWorkloadPolicy
| CREATE ENCRYPTKEY (IF NOT EXISTS)? multipartIdentifier AS STRING_LITERAL #createEncryptkey
| CREATE SYNC dbName=identifier DOT jobName=identifierOrText
LEFT_PAREN channelDescriptions RIGHT_PAREN
FROM BINLOG LEFT_PAREN propertyItemList RIGHT_PAREN
properties=propertyClause? #createDataSyncJob
| CREATE SQL_BLOCK_RULE (IF NOT EXISTS)?
name=identifier properties=propertyClause? #createSqlBlockRule
| CREATE STORAGE POLICY (IF NOT EXISTS)?
Expand All @@ -483,15 +622,6 @@ unsupportedCreateStatement
| CREATE STAGE (IF NOT EXISTS)? name=identifier properties=propertyClause? #createStage
;

channelDescriptions
: channelDescription (COMMA channelDescription)*
;

channelDescription
: FROM source=multipartIdentifier INTO destination=multipartIdentifier
partitionSpec? columnList=identifierList?
;

workloadPolicyActions
: workloadPolicyAction (COMMA workloadPolicyAction)*
;
Expand Down Expand Up @@ -646,6 +776,7 @@ dataDesc
(COLUMNS TERMINATED BY comma=STRING_LITERAL)?
(LINES TERMINATED BY separator=STRING_LITERAL)?
(FORMAT AS format=identifierOrText)?
(COMPRESS_TYPE AS compressType=identifierOrText)?
(columns=identifierList)?
(columnsFromPath=colFromPath)?
(columnMapping=colMappingList)?
Expand Down Expand Up @@ -791,7 +922,7 @@ resourceDesc
;

mysqlDataDesc
: DATA (LOCAL booleanValue)?
: DATA LOCAL?
INFILE filePath=STRING_LITERAL
INTO TABLE tableName=multipartIdentifier
(PARTITION partition=identifierList)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.google.common.base.Strings;
import lombok.Getter;

public class AlterJobStatusStmt extends DdlStmt {
public class AlterJobStatusStmt extends DdlStmt implements NotFallbackInParser {

private Expr expr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.doris.common.UserException;
import org.apache.doris.datasource.CatalogIf;

public class AnalyzeDBStmt extends AnalyzeStmt {
public class AnalyzeDBStmt extends AnalyzeStmt implements NotFallbackInParser {

private final String ctlName;
private final String dbName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* - 'sample.rows' = '1000'
* - 'num.buckets' = 10
*/
public class AnalyzeTblStmt extends AnalyzeStmt {
public class AnalyzeTblStmt extends AnalyzeStmt implements NotFallbackInParser {
// The properties passed in by the user through "with" or "properties('K', 'V')"

private final TableName tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import java.util.List;

public class CancelAlterSystemStmt extends CancelStmt {
public class CancelAlterSystemStmt extends CancelStmt implements NotFallbackInParser {

protected List<String> params;
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/*
* CANCEL ALTER COLUMN|ROLLUP FROM db_name.table_name
*/
public class CancelAlterTableStmt extends CancelStmt {
public class CancelAlterTableStmt extends CancelStmt implements NotFallbackInParser {

private AlterType alterType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import com.google.common.base.Strings;

public class CancelBackupStmt extends CancelStmt {
public class CancelBackupStmt extends CancelStmt implements NotFallbackInParser {

private String dbName;
private boolean isRestore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;

public class CancelCloudWarmUpStmt extends CancelStmt {
public class CancelCloudWarmUpStmt extends CancelStmt implements NotFallbackInParser {
private Expr whereClause;
private long jobId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* CANCEL EXPORT [FROM db]
* WHERE [LABEL = "export_label" | LABEL like "label_pattern" | STATE = "PENDING/IN_QUEUE/EXPORTING"]
**/
public class CancelExportStmt extends DdlStmt {
public class CancelExportStmt extends DdlStmt implements NotFallbackInParser {

private static final ImmutableSet<String> SUPPORT_COLUMNS = new ImmutableSet.Builder<String>()
.add("label")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import lombok.Getter;

public class CancelJobTaskStmt extends DdlStmt {
public class CancelJobTaskStmt extends DdlStmt implements NotFallbackInParser {

@Getter
private String jobName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* syntax:
* CANCEL LOAD [FROM db] WHERE load_label (= "xxx" | LIKE "xxx")
**/
public class CancelLoadStmt extends DdlStmt {
public class CancelLoadStmt extends DdlStmt implements NotFallbackInParser {

private static final Set<String> SUPPORT_COLUMNS = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* CLEAN LABEL FROM db;
* CLEAN LABEL my_label FROM db;
*/
public class CleanLabelStmt extends DdlStmt {
public class CleanLabelStmt extends DdlStmt implements NotFallbackInParser {
private String db;
private String label;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* CLEAN ALL PROFILE;
*/
public class CleanProfileStmt extends DdlStmt {
public class CleanProfileStmt extends DdlStmt implements NotFallbackInParser {
public CleanProfileStmt() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* CLEAN DATABASE QUERY STATS FROM db;
* CLEAN TABLE QUERY STATS FROM db.table;
*/
public class CleanQueryStatsStmt extends DdlStmt {
public class CleanQueryStatsStmt extends DdlStmt implements NotFallbackInParser {
private String dbName;
private TableName tableName;
private Scope scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* WEEK | SECOND }
*/
@Slf4j
public class CreateJobStmt extends DdlStmt {
public class CreateJobStmt extends DdlStmt implements NotFallbackInParser {

@Getter
private StatementBase doStmt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
type of routine load:
KAFKA
*/
public class CreateRoutineLoadStmt extends DdlStmt {
public class CreateRoutineLoadStmt extends DdlStmt implements NotFallbackInParser {
private static final Logger LOG = LogManager.getLogger(CreateRoutineLoadStmt.class);

// routine load properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.util.List;

public class ImportColumnsStmt extends StatementBase {
public class ImportColumnsStmt extends StatementBase implements NotFallbackInParser {
private List<ImportColumnDesc> columns;

public ImportColumnsStmt(List<ImportColumnDesc> columns) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.doris.analysis;

public class ImportDeleteOnStmt extends StatementBase {
public class ImportDeleteOnStmt extends StatementBase implements NotFallbackInParser {
private Expr expr;

public ImportDeleteOnStmt(Expr expr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.doris.analysis;

public class ImportSequenceStmt extends StatementBase {
public class ImportSequenceStmt extends StatementBase implements NotFallbackInParser {
private String sequenceColName;

public ImportSequenceStmt(String sequenceColName) {
Expand Down
Loading
Loading