001package gudusoft.gsqlparser.stmt;
002
003import gudusoft.gsqlparser.EDbVendor;
004import gudusoft.gsqlparser.ESqlStatementType;
005import gudusoft.gsqlparser.TCustomSqlStatement;
006import gudusoft.gsqlparser.nodes.*;
007
008/**
009 * Statement class for StarRocks REFRESH DICTIONARY and CANCEL REFRESH DICTIONARY statements.
010 *
011 * Syntax:
012 * REFRESH DICTIONARY dictionary_object_name
013 * CANCEL REFRESH DICTIONARY dictionary_object_name
014 */
015public class TStarrocksRefreshDictionaryStmt extends TCustomSqlStatement {
016
017    private TObjectName dictionaryName;
018    private boolean cancelRefresh;
019
020    public TStarrocksRefreshDictionaryStmt(EDbVendor dbVendor) {
021        super(dbVendor);
022        sqlstatementtype = ESqlStatementType.sststarrocksRefreshDictionary;
023    }
024
025    public TObjectName getDictionaryName() {
026        return dictionaryName;
027    }
028
029    public boolean isCancelRefresh() {
030        return cancelRefresh;
031    }
032
033    @Override
034    public void accept(TParseTreeVisitor v) {
035        v.preVisit(this);
036        v.postVisit(this);
037    }
038
039    @Override
040    public void acceptChildren(TParseTreeVisitor v) {
041        if (this.dictionaryName != null) {
042            this.dictionaryName.accept(v);
043        }
044    }
045
046    @Override
047    public int doParseStatement(TCustomSqlStatement psql) {
048        if (rootNode == null) return -1;
049        super.doParseStatement(psql);
050
051        if (rootNode instanceof TRefreshDictionarySqlNode) {
052            TRefreshDictionarySqlNode node = (TRefreshDictionarySqlNode) rootNode;
053            this.dictionaryName = node.getDictionaryName();
054            this.cancelRefresh = node.isCancelRefresh();
055        }
056        return 0;
057    }
058}