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