001package gudusoft.gsqlparser.stmt;
002
003import gudusoft.gsqlparser.*;
004import gudusoft.gsqlparser.nodes.*;
005import gudusoft.gsqlparser.nodes.hive.*;
006import gudusoft.gsqlparser.nodes.netezza.TExternalTableOption;
007import gudusoft.gsqlparser.nodes.oracle.TPhysicalProperties;
008import gudusoft.gsqlparser.nodes.postgresql.TInheritsClause;
009import gudusoft.gsqlparser.nodes.postgresql.TPartitionBoundSpecSqlNode;
010import gudusoft.gsqlparser.nodes.teradata.TIndexDefinition;
011
012import java.util.*;
013
014/**
015 * SQL create table statement.
016 * <br>
017 * {@link #getTargetTable} returns the created table. {@link #getColumnList()} returns columns created in the table.
018 * <br> {@link #getTableConstraints()} returns table level constraints if any.
019 * <br> {@link #getSubQuery()} returns select statement that generate data for this table.
020 * <br><br>Example:
021 * <pre>
022 *     CREATE TABLE dbo.Employee (EmployeeID int PRIMARY KEY CLUSTERED);
023 * </pre>
024 * Table:dbo.Employee can be fetched from {@link #getTargetTable} or the first element of {@link #tables}
025 * <br> column definitions: can be fetched from {@link #getColumnList}
026 * <br>
027 * table constraints: {@link #getTableConstraints}
028 *
029 */
030public class TCreateTableSqlStatement extends TCustomSqlStatement {
031
032
033    public TInheritsClause getInheritsClause() {
034        return inheritsClause;
035    }
036
037    private TInheritsClause inheritsClause;
038
039    private TBaseTablePartition tablePartition;
040
041
042    public TBaseTablePartition getTablePartition() {
043        return tablePartition;
044    }
045
046    public void setPartitionBoundSpec(TPartitionBoundSpecSqlNode partitionBoundSpec) {
047        this.partitionBoundSpec = partitionBoundSpec;
048    }
049
050    public TPartitionBoundSpecSqlNode getPartitionBoundSpec() {
051        return partitionBoundSpec;
052    }
053
054    /**
055     * postgresql PartitionBoundSpec
056     * https://www.postgresql.org/docs/current/sql-createtable.html
057     */
058    private TPartitionBoundSpecSqlNode partitionBoundSpec;
059
060    public TTableProperties getTableProperties() {
061        return tableProperties;
062    }
063
064    public void setTableProperties(TTableProperties tableProperties) {
065        this.tableProperties = tableProperties;
066    }
067
068    private TTableProperties tableProperties;
069
070    public enum TableSourceType  {normal,subquery,like,clone,copy,partitionOf,forExchangeWith};
071    private TableSourceType tableSourceType = TableSourceType.normal;
072
073    private List<String> externalTableOptionList = null;
074
075    /**
076     * sql server create external table with options
077     * @return
078     */
079    public  List<String> getExternalTableOptionNames(){
080        return  TBaseType.getOptionNames(externalTableOptionList);
081    }
082
083    /**
084     * sql server create external table with option.
085     *
086     * @param optionName
087     * @return
088     */
089    public String getExternalTableOption(String optionName){
090        return TBaseType.getOption(externalTableOptionList,optionName);
091    }
092
093    public TableSourceType getTableSourceType() {
094        return tableSourceType;
095    }
096
097    private TObjectName cloneSourceTable = null;
098
099    public TObjectName getCloneSourceTable() {
100        return cloneSourceTable;
101    }
102
103    private TExternalTableOption externalTableOption = null;
104
105    public TExternalTableOption getExternalTableOption() {
106        return externalTableOption;
107    }
108
109    private TExpression partitionByExpr;
110
111    public void setPartitionByExpr(TExpression partitionByExpr) {
112        this.partitionByExpr = partitionByExpr;
113    }
114
115    /**
116     * Bigquery partition by expr
117     *
118     * @return expr
119     */
120    public TExpression getPartitionByExpr() {
121        return partitionByExpr;
122    }
123
124    private String awsSnsTopic = null;
125
126    public void setAwsSnsTopic(String awsSnsTopic) {
127        this.awsSnsTopic = awsSnsTopic;
128    }
129
130    public String getAwsSnsTopic() {
131        return awsSnsTopic;
132    }
133
134    private TObjectNameList partitionColumnList;
135
136    public void setPartitionColumnList(TObjectNameList partitionColumnList) {
137        this.partitionColumnList = partitionColumnList;
138    }
139
140    public TObjectNameList getPartitionColumnList() {
141        return partitionColumnList;
142    }
143
144    public void setFileFormatName(String fileFormatName) {
145        this.fileFormatName = fileFormatName;
146    }
147
148    public void setFileFormatType(String fileFormatType) {
149        this.fileFormatType = fileFormatType;
150    }
151
152    public String getFileFormatName() {
153        return fileFormatName;
154    }
155
156    public String getFileFormatType() {
157        return fileFormatType;
158    }
159
160    private String fileFormatName = null;
161    private String fileFormatType = null;
162
163    private String regex_pattern;
164
165    public void setRegex_pattern(String regex_pattern) {
166        this.regex_pattern = regex_pattern;
167    }
168
169    public String getRegex_pattern() {
170        return regex_pattern;
171    }
172
173    private TStageLocation stageLocation;
174
175    public void setStageLocation(TStageLocation stageLocation) {
176        this.stageLocation = stageLocation;
177    }
178
179    public TStageLocation getStageLocation() {
180        return stageLocation;
181    }
182
183    public void setTableOptions(ArrayList<TCreateTableOption> tableOptions) {
184        this.tableOptions = tableOptions;
185    }
186
187    public ArrayList<TCreateTableOption> getTableOptions() {
188        return tableOptions;
189    }
190
191    private ArrayList<TCreateTableOption> tableOptions;
192
193    public void setOnFilegroup(TDummy onFilegroup) {
194        this.onFilegroup = onFilegroup;
195    }
196
197    public TDummy getOnFilegroup() {
198        return onFilegroup;
199    }
200
201    private TDummy onFilegroup = null;
202
203    /**
204     * Oracle physical properties
205     * @return Oracle physical properties
206     */
207    public TPhysicalProperties getPhysicalProperties() {
208        return physicalProperties;
209    }
210
211    private TPhysicalProperties physicalProperties;
212
213    private EnumSet<ETableKind> tableKinds = EnumSet.noneOf(ETableKind.class);
214
215    public void setTableKinds(EnumSet<ETableKind> tableKinds) {
216        this.tableKinds = tableKinds;
217    }
218
219    /**
220     * Type of this table
221     * @return Type of this table
222     */
223    public EnumSet<ETableKind> getTableKinds() {
224        return tableKinds;
225    }
226
227    private TTable asTable;
228
229    /**
230     * Netezza, Teradata, as table name.
231     * @return as table name
232     */
233    public TTable getAsTable() {
234        return asTable;
235    }
236
237    private boolean externalTable;
238
239    /**
240     * @deprecated As of v1.9.7.2 , replace by {@link #isExternal}
241     * <br>
242     * Netezza, whether it is a external table
243     * @return true if it's netezza create external table
244     */
245    public boolean isExternalTable() {
246        return externalTable;
247    }
248
249    private ArrayList <TIndexDefinition> indexDefinitions;
250
251    /**
252     * Teradata index definition
253     *
254     * <pre>UNIQUE PRIMARY INDEX (storeid, productid, salesdate)</pre>
255     * @return  list of index definition
256     */
257    public ArrayList<TIndexDefinition> getIndexDefinitions() {
258        return indexDefinitions;
259    }
260
261
262    private boolean external;
263    private boolean ifNotExists;
264    private TObjectName tableLocation;
265    private TObjectName tableComment;
266    private THiveTableProperties hiveTableProperties;
267    private THiveTablePartition hiveTablePartition;
268    private THiveTableBuckets hiveTableBuckets;
269    private THiveTableSkewed hiveTableSkewed;
270    private THiveRowFormat hiveRowFormat;
271    private THiveTableFileFormat hiveTableFileFormat;
272    private TObjectName likeTableName;
273
274    /**
275     * Hive, Impala,Netezza,snowflake whether it is an external table
276     * @return whether it is an external table
277     */
278    public boolean isExternal() {
279        return external;
280    }
281
282    /**
283     * Hive, impala table row format
284     * @return table row format
285     */
286    public THiveRowFormat getHiveRowFormat() {
287        return hiveRowFormat;
288    }
289
290    /**
291     * Hive, Impala table buckets
292     * @return table buckets
293     */
294    public THiveTableBuckets getHiveTableBuckets() {
295        return hiveTableBuckets;
296    }
297
298    /**
299     * Hive, Impala table file format
300     * @return table file format
301     */
302    public THiveTableFileFormat getHiveTableFileFormat() {
303        return hiveTableFileFormat;
304    }
305
306    /**
307     * Hive, Impala table partition
308     * @return table partition
309     */
310    public THiveTablePartition getHiveTablePartition() {
311        return hiveTablePartition;
312    }
313
314    /**
315     * Hive, Impala table properties
316     * @return table properties
317     */
318    public THiveTableProperties getHiveTableProperties() {
319        return hiveTableProperties;
320    }
321
322    /**
323     * Hive, Impala skewed by clause.
324     * @return skewed by clause.
325     */
326    public THiveTableSkewed getHiveTableSkewed() {
327        return hiveTableSkewed;
328    }
329
330    /**
331     * Hive, Impala, if not exists clause
332     * @return true if not exists clause is used in create table statement
333     */
334    public boolean isIfNotExists() {
335        return ifNotExists;
336    }
337
338    /**
339     * Greenplum, table used in like clause.
340     * <br>Hive, Impala, table used in like clause.
341     * @return table used in like clause.
342     */
343    public TObjectName getLikeTableName() {
344        return likeTableName;
345    }
346
347    /**
348     * Hive, Impala, comment of the table.
349     * @return comment of the table.
350     */
351    public TObjectName getTableComment() {
352        return tableComment;
353    }
354
355    /**
356     * Hive, Impala, location of the table.
357     * @return location of the table.
358     */
359    public TObjectName getTableLocation() {
360        return tableLocation;
361    }
362
363    private TObjectName rowTypeName;
364    private TObjectName superTableName;
365
366    /**
367     * Informix, typename used in of type clause.
368     *
369     * @return row type name
370     */
371    public TObjectName getRowTypeName() {
372        return rowTypeName;
373    }
374
375    /**
376     * Informix, table name used in the under clause.
377     * @return table name used in the under clause.
378     */
379    public TObjectName getSuperTableName() {
380        return superTableName;
381    }
382
383    /**
384     * Data of the created table is derived from this select statement.
385     *
386     * @return {@link gudusoft.gsqlparser.stmt.TSelectSqlStatement} used in create table.
387     */
388    public TSelectSqlStatement getSubQuery() {
389        return subQuery;
390    }
391
392    private TSelectSqlStatement subQuery = null;
393    private TExecuteSqlStatement executePreparedStatement = null;//greenplum
394
395    public TExecuteSqlStatement getExecutePreparedStatement() {
396        return executePreparedStatement;
397    }
398
399
400
401    private TPTNodeList <TMySQLCreateTableOption> mySQLTableOptionList;
402
403    /**
404     * MySQL, option used in create table such as engine, auto_increment and etc.
405     * @return option used in create table such as engine, auto_increment and etc.
406     */
407    public TPTNodeList<TMySQLCreateTableOption> getMySQLTableOptionList() {
408        return mySQLTableOptionList;
409    }
410
411    public TCreateTableSqlStatement(EDbVendor dbvendor) {
412        super(dbvendor);
413        sqlstatementtype = ESqlStatementType.sstcreatetable;
414    }
415
416    void buildsql() {
417    }
418
419    void clear() {
420    }
421
422    String getasprettytext() {
423        return "";
424    }
425
426    void iterate(TVisitorAbs pvisitor) {
427    }
428
429    private TObjectName tableName = null;
430
431    /**
432     * The first table in {@link #tables}, this is the same table as {@link #getTargetTable}
433     *
434     * @return The first table in {@link #tables}
435     */
436    public TObjectName getTableName() {
437        return tables.getTable(0).getTableName();
438    }
439
440    private boolean webTable = false;
441
442    public boolean isWebTable() {
443        return webTable;
444    }
445
446
447    private boolean readable;
448
449    public boolean isReadable() {
450        return readable;
451    }
452
453    public boolean isWritable() {
454        return writable;
455    }
456
457    private boolean writable;
458
459    private TConstant executeCmd;
460
461
462    public TConstant getExecuteCmd() {
463        return executeCmd;
464    }
465
466
467    private ArrayList<TConstant> locationFiles;
468
469    public void setLocationFiles(ArrayList<TConstant> locationFiles) {
470        this.locationFiles = locationFiles;
471    }
472
473    public ArrayList<TConstant> getLocationFiles() {
474        return locationFiles;
475    }
476
477    public int doParseStatement(TCustomSqlStatement psql) {
478       if (rootNode == null) return -1;
479       TCreateTableSqlNode createTableNode = (TCreateTableSqlNode)rootNode;
480       super.doParseStatement(psql);
481       this.tableKinds = createTableNode.getTableKinds();
482       this.tableSourceType = createTableNode.getTableSourceType();
483       this.setTargetTable(createTableNode.getTable());
484
485
486       // move to TMetadataCollector
487
488//       TSQLTable sqlTable = null;
489//        if (getSqlEnv() != null)  {
490//            if (createTableNode.getTable() != null){
491//                sqlTable = getSqlEnv().addTable(createTableNode.getTable().getFullName(),true);
492//            }
493//
494//            if (getSqlEnv().getDefaultCatalogName() != null){
495//                if (createTableNode.getTable().getTableName().getDatabaseToken() == null){
496//                    createTableNode.getTable().getTableName().setDatabaseToken(new TSourceToken(getSqlEnv().getDefaultCatalogName()),true);
497//                }
498//            }
499//
500//            createTableNode.getTable().getTableName().setSqlEnv(getSqlEnv());
501//        }
502
503        // end of move to TMetadataCollector
504
505       externalTable = createTableNode.isExternalTable();
506       physicalProperties = createTableNode.getPhysicalProperties();
507       tableProperties = createTableNode.getTableProperties();
508       this.tablePartition = createTableNode.getTablePartition();
509
510       if (createTableNode.getNetezzaExternalTableOption() != null){
511           this.externalTableOption = new TExternalTableOption(createTableNode.getNetezzaExternalTableOption().toString());
512       }
513
514       mySQLTableOptionList = createTableNode.getMySQLTableOptionList();
515       tableOptions = createTableNode.getTableOptions();
516       if (tableOptions != null){
517           for(int i=0;i<tableOptions.size();i++){
518               tableOptions.get(i).doParse(this,ESqlClause.unknown);
519           }
520       }
521
522       superTableName = createTableNode.getSuperTableName();
523       rowTypeName = createTableNode.getRowTypeName();
524       onFilegroup = createTableNode.getOnFilegroup();
525       cloneSourceTable = createTableNode.getCloneSourceTable();
526       likeTableName = createTableNode.getLikeTableName();
527       if (likeTableName != null){
528           likeTableName.setDbObjectType(this.dbvendor,EDbObjectType.table);
529       }
530       partitionBoundSpec = createTableNode.getPartitionBoundSpec();
531
532       tables.addTable(createTableNode.getTable());
533       asTable = createTableNode.getAsTable();
534        if (asTable != null) tables.addTable(asTable);
535       if ((createTableNode.getTableElementList() != null)&&(createTableNode.getTableElementList().size() >0 )){
536           TTableElement te;
537           TColumnDefinition cd;
538           Set<String> columnNames = new LinkedHashSet<String>();
539           for(int i=0; i<createTableNode.getTableElementList().size();i++){
540              te = createTableNode.getTableElementList().getTableElement(i);
541               if (te.getType() == TTableElement.type_column_def) {
542                   cd = te.getColumnDefinition();
543                   this.getColumnList().addColumn(cd);
544
545                   cd.doParse(this, ESqlClause.createTable);
546                   this.getTargetTable().getObjectNameReferences().addObjectName(cd.getColumnName());
547                   cd.getColumnName().setLocation(ESqlClause.createTable);
548                   cd.getColumnName().setLinkedColumnDef(cd);
549                   getTargetTable().getLinkedColumns().addObjectName(cd.getColumnName());
550                   cd.getColumnName().setSourceTable(getTargetTable());
551                   // move to TMetadataCollector
552//                   if (sqlTable != null){
553//                       sqlTable.addColumn(cd.getColumnName().toString(),cd.getDatatype());
554//                       //getTargetTable().setSqlTable(sqlTable);
555//                   }
556                   if (!columnNames.add(cd.getColumnName().toString())){
557                       // find duplicate colum name
558                       TSourceToken st = cd.getColumnName().getStartToken();
559                       this.parseerrormessagehandle(new TSyntaxError(st.getAstext(), st.lineNo, st.columnNo
560                               ,"duplicate column name", EErrorType.spfatalerror
561                               , TBaseType.MSG_ERROR_DUPLICATED_COLUMN_NAME,this,st.posinlist));
562
563                   }
564               }
565               else  if (te.getType() == TTableElement.type_table_like){
566                   likeTableName = te.getParentTable();
567               }else  if (te.getType() == TTableElement.type_supplemental_logging){
568
569               }else{
570                   te.getConstraint().doParse(this,ESqlClause.unknown);
571                   this.getTableConstraints().addConstraint(te.getConstraint());
572               }
573           }
574       }
575
576       // column name list used when create table using a subquery.
577       TColumnDefinition t = null;
578       if ((createTableNode.getColumnList() != null)&&(createTableNode.getColumnList().size() > 0)){
579           for(int i=0;i<createTableNode.getColumnList().size();i++){
580               t = new TColumnDefinition(createTableNode.getColumnList().getObjectName(i));
581               t.setStartToken(t.getColumnName().getStartToken());
582               t.setEndToken(t.getColumnName().getEndToken());
583               this.getColumnList().addColumn(t);
584               this.getTargetTable().getObjectNameReferences().addObjectName(createTableNode.getColumnList().getObjectName(i));
585               getTargetTable().getLinkedColumns().addObjectName(createTableNode.getColumnList().getObjectName(i));
586               createTableNode.getColumnList().getObjectName(i).setSourceTable(getTargetTable());
587               // move to TMetadataCollector
588//               if (sqlTable != null){
589//                   sqlTable.addColumn(createTableNode.getColumnList().getObjectName(i).toString());
590//               }
591           }
592       }
593
594       if((subQuery == null) && (createTableNode.getSubQueryNode() != null) && (createTableNode.getSubQueryNode().getRelationExpr() == null)){
595           subQuery = new TSelectSqlStatement(this.dbvendor);
596           subQuery.rootNode = createTableNode.getSubQueryNode();
597           subQuery.doParseStatement(this);
598
599
600           // link column alias in subquery to table in create statement if columnList is not specified
601           if (createTableNode.getColumnList() == null){
602               TSelectSqlStatement viewQuery = subQuery;
603               if (subQuery.isCombinedQuery()){
604                   viewQuery = subQuery.getRightStmt();
605               }
606
607                        if (viewQuery.getResultColumnList() != null) {
608               for(int i=0;i<viewQuery.getResultColumnList().size();i++){
609                   TResultColumn resultColumn = viewQuery.getResultColumnList().getResultColumn(i);
610                   TObjectName aliasName = null;
611                   if (resultColumn.getAliasClause() != null){
612                       if (resultColumn.getAliasClause().getColumns() != null){
613                           // select explode(str_to_map(regexp_replace(regexp_replace(regexp_replace(lower(t.input), '', ''), '',''), '', ''), '', '')) as (`key`, `value`) from B t1
614                            for (int j=0;j<resultColumn.getAliasClause().getColumns().size();j++){
615                                TObjectName aliasName1 =  resultColumn.getAliasClause().getColumns().getObjectName(j);
616                                aliasName1.setLocation(ESqlClause.columnAlias);
617                                resultColumn.getAliasNameList().add(aliasName1);
618                            }
619                       }else {
620                           aliasName = TObjectName.createObjectName (this.dbvendor, EDbObjectType.column,resultColumn.getAliasClause().getAliasName().getStartToken());
621                           aliasName.getReferencedObjects().addObjectName(resultColumn.getAliasClause().getAliasName());
622                           aliasName.setLocation(resultColumn.getAliasClause().getAliasName().getLocation());
623                       }
624                   }else{
625                       if (resultColumn.getExpr().getObjectOperand() != null){
626                           aliasName =  TObjectName.createObjectName (this.dbvendor, EDbObjectType.column,resultColumn.getExpr().getObjectOperand().getPartToken());
627                           aliasName.getReferencedObjects().addObjectName(resultColumn.getExpr().getObjectOperand());
628                           aliasName.setLocation(resultColumn.getExpr().getObjectOperand().getLocation());
629                       }
630                   }
631
632                   if (aliasName != null){
633                       if (aliasName.getLocation() == ESqlClause.unknown){
634                           aliasName.setLocation(ESqlClause.columnAlias);
635                       }
636                       getTargetTable().getLinkedColumns().addObjectName(aliasName);
637                       aliasName.setSourceTable(getTargetTable());
638                       resultColumn.setAliasName(aliasName.toString());
639
640                       // move to TMetadataCollector
641//                       if (sqlTable != null){
642//                           sqlTable.addColumn(TSQLEnv.getObjectName(aliasName.toString()));
643//                       }
644                   }
645               }
646                        }
647           }
648       }else if ((createTableNode.getSubQueryNode() != null) && (createTableNode.getSubQueryNode().getRelationExpr() != null)){
649            // CREATE TABLE a AS TABLE b
650           asTable = new TTable(createTableNode.getSubQueryNode().getRelationExpr().getRelationName());
651           tables.addTable(asTable);
652       }
653
654       if (createTableNode.getExecuteSqlNode() != null){
655           executePreparedStatement = new TExecuteSqlStatement(this.dbvendor);
656           executePreparedStatement.rootNode = createTableNode.getExecuteSqlNode();
657           executePreparedStatement.doParseStatement(this);
658       }
659
660        external = createTableNode.isExternal();
661       if (external){
662           if (createTableNode.getOptionStartParenthesis() != null){
663               externalTableOptionList = TBaseType.getArrayListBetweenTokens(createTableNode.getOptionStartParenthesis(),createTableNode.getOptionEndParenthesis(),false);
664           }
665       }
666        ifNotExists = createTableNode.isIfNotExists();
667        if (createTableNode.getTableComment() != null){
668            tableComment = createTableNode.getTableComment();
669        }
670
671        locationFiles = createTableNode.getLocationFiles();
672        readable = createTableNode.isReadable();
673        writable = createTableNode.isWritable();
674        executeCmd = createTableNode.getExecuteCmd();
675        webTable = createTableNode.isWebTable();
676
677        tableLocation = createTableNode.getTableLocation();
678        hiveTableProperties = createTableNode.getHiveTableProperties();
679        hiveTablePartition = createTableNode.getHiveTablePartition();
680        hiveTableBuckets = createTableNode.getHiveTableBuckets();
681        hiveRowFormat = createTableNode.getHiveRowFormat();
682        hiveTableSkewed = createTableNode.getHiveTableSkewed();
683        hiveTableFileFormat = createTableNode.getHiveTableFileFormat();
684        if (likeTableName == null){
685            likeTableName = createTableNode.getLikeTableName();
686        }
687        indexDefinitions = createTableNode.getIndexDefinitions();
688        if (indexDefinitions != null){
689            for(int i=0;i<indexDefinitions.size();i++){
690                indexDefinitions.get(i).doParse(this,ESqlClause.tableIndexOption);
691            }
692        }
693
694        inheritsClause = createTableNode.getInheritsClause();
695        if (inheritsClause != null) {
696            for(int i=0;i<inheritsClause.getParentTables().size();i++){
697                inheritsClause.getParentTables().getObjectName(i).setDbObjectType(this.dbvendor, EDbObjectType.table);
698            }
699        }
700        return 0;
701    }
702
703    /**
704     * table level constraints.
705     * @return List of table constraints of this table.
706     */
707    public TConstraintList getTableConstraints() {
708        if (this.tableConstraints == null){
709            this.tableConstraints = new TConstraintList();
710
711        }
712        
713        return tableConstraints;
714    }
715
716    /**
717     *  columns created in create table statement.
718     *
719     * @return List of column definitions of this table.
720     */
721    public TColumnDefinitionList getColumnList() {
722        if (this.columnList == null){
723            this.columnList = new TColumnDefinitionList();
724
725        }
726        return columnList;
727    }
728
729    private TColumnDefinitionList columnList = null;
730    private TConstraintList tableConstraints = null;
731
732    public void accept(TParseTreeVisitor v){
733        v.preVisit(this);
734        v.postVisit(this);
735    }
736
737    public void acceptChildren(TParseTreeVisitor v){
738        v.preVisit(this);
739        //tables.acceptChildren(v);
740        if (getTargetTable() != null) {
741            getTargetTable().acceptChildren(v);
742        }
743        this.getColumnList().acceptChildren(v);
744        if ((this.getTableConstraints() != null)&&(this.getTableConstraints().size()>0)){
745            this.getTableConstraints().acceptChildren(v);
746        }
747        if (this.getSubQuery() != null){
748            this.getSubQuery().acceptChildren(v);
749        }
750        if (getHiveTablePartition() != null){
751            getHiveTablePartition().acceptChildren(v);
752        }
753        v.postVisit(this);
754    }
755
756    public void setColumnList(TColumnDefinitionList columnList) {
757        this.columnList = columnList;
758    }
759
760    public void setAsTable(TTable asTable) {
761        this.asTable = asTable;
762    }
763
764    public void setExternalTable(boolean externalTable) {
765        this.externalTable = externalTable;
766    }
767
768    public void setIndexDefinitions(ArrayList<TIndexDefinition> indexDefinitions) {
769        this.indexDefinitions = indexDefinitions;
770    }
771
772    public void setExternal(boolean external) {
773        this.external = external;
774    }
775
776    public void setIfNotExists(boolean ifNotExists) {
777        this.ifNotExists = ifNotExists;
778    }
779
780    public void setTableLocation(TObjectName tableLocation) {
781        this.tableLocation = tableLocation;
782    }
783
784    public void setTableComment(TObjectName tableComment) {
785        this.tableComment = tableComment;
786    }
787
788    public void setHiveTableProperties(THiveTableProperties hiveTableProperties) {
789        this.hiveTableProperties = hiveTableProperties;
790    }
791
792    public void setHiveTablePartition(THiveTablePartition hiveTablePartition) {
793        this.hiveTablePartition = hiveTablePartition;
794    }
795
796    public void setHiveTableBuckets(THiveTableBuckets hiveTableBuckets) {
797        this.hiveTableBuckets = hiveTableBuckets;
798    }
799
800    public void setHiveTableSkewed(THiveTableSkewed hiveTableSkewed) {
801        this.hiveTableSkewed = hiveTableSkewed;
802    }
803
804    public void setHiveRowFormat(THiveRowFormat hiveRowFormat) {
805        this.hiveRowFormat = hiveRowFormat;
806    }
807
808    public void setHiveTableFileFormat(THiveTableFileFormat hiveTableFileFormat) {
809        this.hiveTableFileFormat = hiveTableFileFormat;
810    }
811
812    public void setLikeTableName(TObjectName likeTableName) {
813        this.likeTableName = likeTableName;
814    }
815
816    public void setRowTypeName(TObjectName rowTypeName) {
817        this.rowTypeName = rowTypeName;
818    }
819
820    public void setSuperTableName(TObjectName superTableName) {
821        this.superTableName = superTableName;
822    }
823
824    public void setSubQuery(TSelectSqlStatement subQuery) {
825        this.subQuery = subQuery;
826    }
827
828    public void setExecutePreparedStatement(TExecuteSqlStatement executePreparedStatement) {
829        this.executePreparedStatement = executePreparedStatement;
830    }
831
832    public void setMySQLTableOptionList(TPTNodeList<TMySQLCreateTableOption> mySQLTableOptionList) {
833        this.mySQLTableOptionList = mySQLTableOptionList;
834    }
835
836    public void setTableName(TObjectName tableName) {
837        this.tableName = tableName;
838    }
839
840    public void setTableConstraints(TConstraintList tableConstraints) {
841        this.tableConstraints = tableConstraints;
842    }
843}