Skip to content

Commit

Permalink
[Enhancement] (nereids)implement syncCommand in nereids
Browse files Browse the repository at this point in the history
  • Loading branch information
Vallishp committed Nov 21, 2024
1 parent 045f590 commit b4ff7dd
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ statementBase
| supportedRefreshStatement #supportedRefreshStatementAlias
| supportedShowStatement #supportedShowStatementAlias
| supportedRecoverStatement #supportedRecoverStatementAlias
| supportedLoadStatement #supportedLoadfStatementAlias
| unsupportedStatement #unsupported
;

Expand Down Expand Up @@ -229,6 +230,10 @@ supportedShowStatement
tabletIds+=INTEGER_VALUE (COMMA tabletIds+=INTEGER_VALUE)* #showTabletsBelong
;

supportedLoadStatement
: SYNC #sync
;

unsupportedOtherStatement
: HELP mark=identifierOrText #help
| INSTALL PLUGIN FROM source=identifierOrText properties=propertyClause? #installPlugin
Expand Down Expand Up @@ -370,7 +375,6 @@ unsupportedLoadStatement
| 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
import org.apache.doris.nereids.DorisParser.SubqueryContext;
import org.apache.doris.nereids.DorisParser.SubqueryExpressionContext;
import org.apache.doris.nereids.DorisParser.SupportedUnsetStatementContext;
import org.apache.doris.nereids.DorisParser.SyncContext;
import org.apache.doris.nereids.DorisParser.SystemVariableContext;
import org.apache.doris.nereids.DorisParser.TableAliasContext;
import org.apache.doris.nereids.DorisParser.TableNameContext;
Expand Down Expand Up @@ -487,6 +488,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowVariablesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowViewCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowWhiteListCommand;
import org.apache.doris.nereids.trees.plans.commands.SyncCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsetDefaultStorageVaultCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsetVariableCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsupportedCommand;
Expand Down Expand Up @@ -4323,6 +4325,11 @@ public LogicalPlan visitShowTableId(ShowTableIdContext ctx) {
return new ShowTableIdCommand(tableId);
}

@Override
public LogicalPlan visitSync(SyncContext ctx) {
return new SyncCommand();
}

@Override
public LogicalPlan visitShowPrivileges(ShowPrivilegesContext ctx) {
return new ShowPrivilegesCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public enum PlanType {
SHOW_VIEW_COMMAND,
SHOW_WHITE_LIST_COMMAND,
SHOW_TABLETS_BELONG_COMMAND,
SYNC_COMMAND,
RECOVER_DATABASE_COMMAND,
RECOVER_TABLE_COMMAND,
RECOVER_PARTITION_COMMAND,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.

package org.apache.doris.nereids.trees.plans.commands;

import org.apache.doris.analysis.RedirectStatus;
import org.apache.doris.analysis.StmtType;
import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.StmtExecutor;

/**
* sync command
*/
public class SyncCommand extends Command implements Redirect {

/**
* constructor
*/
public SyncCommand() {
super(PlanType.SYNC_COMMAND);
}

@Override
public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
// nothing to do
}

@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
return visitor.visitSyncCommand(this, context);
}

@Override
public RedirectStatus toRedirectStatus() {
return RedirectStatus.FORWARD_WITH_SYNC;
}

@Override
public StmtType stmtType() {
return StmtType.SYNC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowVariablesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowViewCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowWhiteListCommand;
import org.apache.doris.nereids.trees.plans.commands.SyncCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsetDefaultStorageVaultCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsetVariableCommand;
import org.apache.doris.nereids.trees.plans.commands.UnsupportedCommand;
Expand Down Expand Up @@ -396,6 +397,10 @@ default R visitShowTrashCommand(ShowTrashCommand showTrashCommand, C context) {
return visitCommand(showTrashCommand, context);
}

default R visitSyncCommand(SyncCommand syncCommand, C context) {
return visitCommand(syncCommand, context);
}

default R visitShowPrivilegesCommand(ShowPrivilegesCommand showPrivilegesCommand, C context) {
return visitCommand(showPrivilegesCommand, context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

suite("test_nereids_other_commands") {
checkNereidsExecute("sync;")
}

0 comments on commit b4ff7dd

Please sign in to comment.