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

Public Member Functions

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

Public Attributes

final SqlIdentifier modelType
 
final SqlIdentifier name
 
final SqlNode query
 

Protected Member Functions

 SqlCreateModel (SqlParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier modelType, SqlIdentifier name, HeavyDBOptionsMap withOptions, SqlNode query)
 

Private Attributes

final HeavyDBOptionsMap options
 

Static Private Attributes

static final SqlOperator OPERATOR
 

Detailed Description

Parse tree for

CREATE MODEL

statement.

Definition at line 46 of file SqlCreateModel.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlCreateModel.SqlCreateModel ( SqlParserPos  pos,
boolean  replace,
boolean  ifNotExists,
SqlIdentifier  modelType,
SqlIdentifier  name,
HeavyDBOptionsMap  withOptions,
SqlNode  query 
)
inlineprotected

Creates a SqlCreateModel.

Definition at line 56 of file SqlCreateModel.java.

References com.mapd.parser.extension.ddl.SqlCreateModel.modelType, com.mapd.parser.extension.ddl.SqlCreateModel.name, com.mapd.parser.extension.ddl.SqlCreateModel.OPERATOR, and com.mapd.parser.extension.ddl.SqlCreateModel.query.

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

Member Function Documentation

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

Definition at line 96 of file SqlCreateModel.java.

References com.mapd.parser.extension.ddl.SqlCreateModel.query.

96  {
97  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
98  Map<String, Object> map = jsonBuilder.map();
99 
100  jsonBuilder.put(map, "command", "CREATE_MODEL");
101  jsonBuilder.put(map, "type", this.modelType.toString());
102  jsonBuilder.put(map, "name", this.name.toString());
103 
104  if (query != null) {
105  // By default ... toString() seems to single-quote too much stuff
106  // for the SELECT stmt to be executed later
107  // ->
108  // use PrettyWriter to output a cleaner SQL statement
109  //
110  SqlWriterConfig c = SqlPrettyWriter.config()
111  .withDialect(CalciteSqlDialect.DEFAULT)
112  .withQuoteAllIdentifiers(false)
113  .withSelectListItemsOnSeparateLines(false)
114  .withWhereListItemsOnSeparateLines(false)
115  .withValuesListNewline(false);
116  SqlPrettyWriter writer = new SqlPrettyWriter(c);
117  this.query.unparse(writer, 0, 0);
118  jsonBuilder.put(map, "query", writer.toString());
119  }
120 
121  jsonBuilder.put(map, "replace", getReplace());
122  jsonBuilder.put(map, "ifNotExists", this.ifNotExists);
123 
124  map.put("options", this.options);
125 
126  Map<String, Object> payload = jsonBuilder.map();
127  payload.put("payload", map);
128 
129  // To Debug:
130  // System.out.println(jsonBuilder.toJsonString(payload))
131 
132  return jsonBuilder.toJsonString(payload);
133  }
void com.mapd.parser.extension.ddl.SqlCreateModel.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 75 of file SqlCreateModel.java.

References com.mapd.parser.extension.ddl.SqlCreateModel.query.

75  {
76  if (getReplace()) {
77  writer.keyword("CREATE OR REPLACE");
78  } else {
79  writer.keyword("CREATE");
80  }
81  writer.keyword("MODEL");
82  if (ifNotExists) {
83  writer.keyword("IF NOT EXISTS");
84  }
85  writer.keyword("OF TYPE");
86  modelType.unparse(writer, leftPrec, rightPrec);
87  name.unparse(writer, leftPrec, rightPrec);
88  if (query != null) {
89  writer.keyword("AS");
90  writer.newlineAndIndent();
91  query.unparse(writer, 0, 0);
92  }
93  }

Member Data Documentation

final SqlIdentifier com.mapd.parser.extension.ddl.SqlCreateModel.modelType
final SqlOperator com.mapd.parser.extension.ddl.SqlCreateModel.OPERATOR
staticprivate
Initial value:
=
new SqlSpecialOperator("CREATE MODEL", SqlKind.OTHER_DDL)

Definition at line 52 of file SqlCreateModel.java.

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

final HeavyDBOptionsMap com.mapd.parser.extension.ddl.SqlCreateModel.options
private

Definition at line 50 of file SqlCreateModel.java.


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