OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.mapd.parser.extension.ddl.SqlCreateTable Class Reference
+ Inheritance diagram for com.mapd.parser.extension.ddl.SqlCreateTable:
+ Collaboration diagram for com.mapd.parser.extension.ddl.SqlCreateTable:

Public Member Functions

List< SqlNode > getOperandList ()
 
void unparse (SqlWriter writer, int leftPrec, int rightPrec)
 
String toString ()
 

Public Attributes

final SqlIdentifier name
 
final SqlNodeList columnList
 
final SqlNode query
 

Protected Member Functions

 SqlCreateTable (SqlParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier name, SqlNodeList columnList, OmniSciOptionsMap withOptions, SqlNode query)
 

Private Attributes

final OmniSciOptionsMap options
 

Static Private Attributes

static final SqlOperator OPERATOR
 

Detailed Description

Parse tree for

CREATE TABLE

statement.

Definition at line 41 of file SqlCreateTable.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlCreateTable.SqlCreateTable ( SqlParserPos  pos,
boolean  replace,
boolean  ifNotExists,
SqlIdentifier  name,
SqlNodeList  columnList,
OmniSciOptionsMap  withOptions,
SqlNode  query 
)
inlineprotected

Creates a SqlCreateTable.

Definition at line 51 of file SqlCreateTable.java.

References com.mapd.parser.extension.ddl.SqlCreateTable.columnList, com.mapd.parser.extension.ddl.SqlCreateTable.name, com.mapd.parser.extension.ddl.SqlCreateTable.OPERATOR, and com.mapd.parser.extension.ddl.SqlCreateTable.query.

57  {
58  super(OPERATOR, pos, replace, ifNotExists);
59  this.name = Objects.requireNonNull(name);
60  this.options = withOptions;
61  this.columnList = columnList; // may be null
62  this.query = query; // for "CREATE TABLE ... AS query"; may be null
63  }

Member Function Documentation

List<SqlNode> com.mapd.parser.extension.ddl.SqlCreateTable.getOperandList ( )
inline
String com.mapd.parser.extension.ddl.SqlCreateTable.toString ( )
inline

Definition at line 93 of file SqlCreateTable.java.

References com.mapd.parser.extension.ddl.SqlCreateTable.columnList.

93  {
94  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
95  Map<String, Object> map = jsonBuilder.map();
96 
97  jsonBuilder.put(map, "name", this.name.toString());
98  jsonBuilder.put(
99  map, "query", this.query == null ? this.query : this.query.toString());
100 
101  List<Object> elements_list = jsonBuilder.list();
102  for (SqlNode elementNode : this.columnList) {
103  elements_list.add(elementNode);
104  }
105  jsonBuilder.put(map, "elements", elements_list);
106 
107  jsonBuilder.put(map, "ifNotExists", this.ifNotExists);
108 
109  map.put("command", "CREATE_TABLE");
110  map.put("options", this.options);
111  Map<String, Object> payload = jsonBuilder.map();
112  payload.put("payload", map);
113  return jsonBuilder.toJsonString(payload);
114  }
void com.mapd.parser.extension.ddl.SqlCreateTable.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 70 of file SqlCreateTable.java.

References com.mapd.parser.extension.ddl.SqlCreateTable.columnList, and com.mapd.parser.extension.ddl.SqlCreateTable.query.

70  {
71  writer.keyword("CREATE");
72  writer.keyword("TABLE");
73  if (ifNotExists) {
74  writer.keyword("IF NOT EXISTS");
75  }
76  name.unparse(writer, leftPrec, rightPrec);
77  if (columnList != null) {
78  SqlWriter.Frame frame = writer.startList("(", ")");
79  for (SqlNode c : columnList) {
80  writer.sep(",");
81  c.unparse(writer, 0, 0);
82  }
83  writer.endList(frame);
84  }
85  if (query != null) {
86  writer.keyword("AS");
87  writer.newlineAndIndent();
88  query.unparse(writer, 0, 0);
89  }
90  }

Member Data Documentation

final SqlOperator com.mapd.parser.extension.ddl.SqlCreateTable.OPERATOR
staticprivate
Initial value:
=
new SqlSpecialOperator("CREATE TABLE", SqlKind.CREATE_TABLE)

Definition at line 47 of file SqlCreateTable.java.

Referenced by com.mapd.parser.extension.ddl.SqlCreateTable.SqlCreateTable().

final OmniSciOptionsMap com.mapd.parser.extension.ddl.SqlCreateTable.options
private

Definition at line 45 of file SqlCreateTable.java.


The documentation for this class was generated from the following file: