branch-2.1: [fix](export) Make enable_outfile_to_local available for export command #45241 (#45515)

Cherry-picked from #45241

Co-authored-by: Siyang Tang <tangsiyang@selectdb.com>
This commit is contained in:
github-actions[bot]
2024-12-19 14:08:33 +08:00
committed by GitHub
parent 7957e6fe0f
commit 7f8ec3e679
2 changed files with 10 additions and 0 deletions

View File

@ -47,6 +47,7 @@ import lombok.Getter;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
@ -146,6 +147,11 @@ public class ExportStmt extends StatementBase {
public void analyze(Analyzer analyzer) throws UserException {
super.analyze(analyzer);
if (!Config.enable_outfile_to_local && Objects.requireNonNull(path)
.startsWith(OutFileClause.LOCAL_FILE_PREFIX)) {
throw new AnalysisException("`enable_outfile_to_local` = false, exporting file to local fs is disabled.");
}
tableRef = analyzer.resolveTableRef(tableRef);
Preconditions.checkNotNull(tableRef);
tableRef.analyze(analyzer);

View File

@ -139,6 +139,10 @@ public class ExportCommand extends Command implements ForwardWithSync {
tblName.getDb() + ": " + tblName.getTbl());
}
if (!Config.enable_outfile_to_local && path.startsWith(OutFileClause.LOCAL_FILE_PREFIX)) {
throw new AnalysisException("`enable_outfile_to_local` = false, exporting file to local fs is disabled.");
}
// check phases
checkAllParameters(ctx, tblName, fileProperties);