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

[Enhancement] (nereids)implement syncCommand in nereids #44335

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ statementBase
| supportedRefreshStatement #supportedRefreshStatementAlias
| supportedShowStatement #supportedShowStatementAlias
| supportedRecoverStatement #supportedRecoverStatementAlias
| supportedLoadStatement #supportedLoadfStatementAlias
| unsupportedStatement #unsupported
;

Expand Down Expand Up @@ -231,6 +232,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 @@ -371,7 +376,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 @@ -241,6 +241,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 @@ -491,6 +492,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 @@ -4342,6 +4344,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 @@ -207,6 +207,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 @@ -87,6 +87,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 @@ -406,6 +407,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;")
}
Loading