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 SHOW DICTIONARY statement.
010 *
011 * Syntax:
012 * SHOW DICTIONARY [dictionary_object_name]
013 */
014public class TStarrocksShowDictionaryStmt extends TCustomSqlStatement {
015
016    private TObjectName dictionaryName;
017
018    public TStarrocksShowDictionaryStmt(EDbVendor dbVendor) {
019        super(dbVendor);
020        sqlstatementtype = ESqlStatementType.sststarrocksShowDictionary;
021    }
022
023    public TObjectName getDictionaryName() {
024        return dictionaryName;
025    }
026
027    @Override
028    public void accept(TParseTreeVisitor v) {
029        v.preVisit(this);
030        v.postVisit(this);
031    }
032
033    @Override
034    public void acceptChildren(TParseTreeVisitor v) {
035        if (this.dictionaryName != null) {
036            this.dictionaryName.accept(v);
037        }
038    }
039
040    @Override
041    public int doParseStatement(TCustomSqlStatement psql) {
042        if (rootNode == null) return -1;
043        super.doParseStatement(psql);
044
045        if (rootNode instanceof TShowDictionarySqlNode) {
046            TShowDictionarySqlNode node = (TShowDictionarySqlNode) rootNode;
047            this.dictionaryName = node.getDictionaryName();
048        }
049        return 0;
050    }
051}