001package gudusoft.gsqlparser.stmt; 002 003import gudusoft.gsqlparser.EDbVendor; 004import gudusoft.gsqlparser.ESqlStatementType; 005import gudusoft.gsqlparser.TCustomSqlStatement; 006import gudusoft.gsqlparser.nodes.*; 007import gudusoft.gsqlparser.nodes.flink.TFlinkTableProperty; 008 009/** 010 * Statement class for StarRocks CREATE DICTIONARY statement. 011 * 012 * Syntax: 013 * CREATE DICTIONARY dictionary_object_name USING dictionary_source 014 * ( 015 * column_name KEY, [..., column_name KEY,] 016 * column_name VALUE[, ..., column_name VALUE] 017 * ) 018 * [PROPERTIES ("key"="value", ...)] 019 */ 020public class TStarrocksCreateDictionaryStmt extends TCustomSqlStatement { 021 022 private TObjectName dictionaryName; 023 private TObjectName sourceName; 024 private TPTNodeList<TParseTreeNode> columnDefinitions; 025 private TPTNodeList<TFlinkTableProperty> properties; 026 027 public TStarrocksCreateDictionaryStmt(EDbVendor dbVendor) { 028 super(dbVendor); 029 sqlstatementtype = ESqlStatementType.sststarrocksCreateDictionary; 030 } 031 032 public TObjectName getDictionaryName() { 033 return dictionaryName; 034 } 035 036 public TObjectName getSourceName() { 037 return sourceName; 038 } 039 040 public TPTNodeList<TParseTreeNode> getColumnDefinitions() { 041 return columnDefinitions; 042 } 043 044 public TPTNodeList<TFlinkTableProperty> getProperties() { 045 return properties; 046 } 047 048 @Override 049 public void accept(TParseTreeVisitor v) { 050 v.preVisit(this); 051 v.postVisit(this); 052 } 053 054 @Override 055 public void acceptChildren(TParseTreeVisitor v) { 056 if (this.dictionaryName != null) { 057 this.dictionaryName.accept(v); 058 } 059 if (this.sourceName != null) { 060 this.sourceName.accept(v); 061 } 062 } 063 064 @Override 065 public int doParseStatement(TCustomSqlStatement psql) { 066 if (rootNode == null) return -1; 067 super.doParseStatement(psql); 068 069 if (rootNode instanceof TCreateDictionarySqlNode) { 070 TCreateDictionarySqlNode node = (TCreateDictionarySqlNode) rootNode; 071 this.dictionaryName = node.getDictionaryName(); 072 this.sourceName = node.getSourceName(); 073 this.columnDefinitions = node.getColumnDefinitions(); 074 this.properties = node.getProperties(); 075 } 076 return 0; 077 } 078}