OmniSciDB  a575cb28ea
 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 43 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 53 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.

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

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 95 of file SqlCreateTable.java.

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

95  {
96  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
97  Map<String, Object> map = jsonBuilder.map();
98 
99  jsonBuilder.put(map, "name", this.name.toString());
100  jsonBuilder.put(
101  map, "query", this.query == null ? this.query : this.query.toString());
102 
103  List<Object> elements_list = jsonBuilder.list();
104  for (SqlNode elementNode : this.columnList) {
105  if (!(elementNode instanceof SqlCall)) {
106  throw new CalciteException("Column definition for table " + this.name.toString()
107  + " is invalid: " + elementNode.toString(),
108  null);
109  }
110  elements_list.add(elementNode);
111  }
112  jsonBuilder.put(map, "elements", elements_list);
113 
114  jsonBuilder.put(map, "ifNotExists", this.ifNotExists);
115 
116  map.put("command", "CREATE_TABLE");
117  map.put("options", this.options);
118  Map<String, Object> payload = jsonBuilder.map();
119  payload.put("payload", map);
120  return jsonBuilder.toJsonString(payload);
121  }
void com.mapd.parser.extension.ddl.SqlCreateTable.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 72 of file SqlCreateTable.java.

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

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

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 49 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 47 of file SqlCreateTable.java.


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