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

Public Member Functions

 SqlInsertIntoTable (SqlParserPos pos, SqlNode table, SqlNode query, SqlNodeList columnList)
 
List< SqlNode > getOperandList ()
 
void unparse (SqlWriter writer, int leftPrec, int rightPrec)
 
String toString ()
 

Public Attributes

final SqlNode name
 
final SqlNodeList columnList
 
SqlNode query = null
 

Static Private Attributes

static final SqlOperator OPERATOR
 

Detailed Description

Class that encapsulates all information associated with a INSERT INTO TABLE DDL command.

Definition at line 33 of file SqlInsertIntoTable.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlInsertIntoTable.SqlInsertIntoTable ( SqlParserPos  pos,
SqlNode  table,
SqlNode  query,
SqlNodeList  columnList 
)
inline

Member Function Documentation

String com.mapd.parser.extension.ddl.SqlInsertIntoTable.toString ( )
inline

Definition at line 74 of file SqlInsertIntoTable.java.

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

74  {
75  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
76  Map<String, Object> map = jsonBuilder.map();
77 
78  map.put("command", "INSERT_INTO_TABLE_AS_SELECT");
79  map.put("name", this.name.toString());
80 
81  // By default ... toString() seems to single-quote too much stuff
82  // for the SELECT stmt to be executed later
83  // ->
84  // use PrettyWriter to output a cleaner SQL statement
85  //
86  SqlWriterConfig c = SqlPrettyWriter.config()
87  .withDialect(CalciteSqlDialect.DEFAULT)
88  .withQuoteAllIdentifiers(false)
89  .withSelectListItemsOnSeparateLines(false)
90  .withWhereListItemsOnSeparateLines(false)
91  .withValuesListNewline(false);
92  SqlPrettyWriter writer = new SqlPrettyWriter(c);
93  this.query.unparse(writer, 0, 0);
94  map.put("query", writer.toString());
95 
96  if (columnList != null) {
97  List<Object> col_list = jsonBuilder.list();
98  for (SqlNode col : this.columnList) {
99  col_list.add(col.toString());
100  }
101  jsonBuilder.put(map, "columns", col_list);
102  }
103 
104  Map<String, Object> payload = jsonBuilder.map();
105  payload.put("payload", map);
106 
107  return jsonBuilder.toJsonString(payload);
108  }
void com.mapd.parser.extension.ddl.SqlInsertIntoTable.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 55 of file SqlInsertIntoTable.java.

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

55  {
56  writer.keyword("INSERT");
57  writer.keyword("INTO");
58  name.unparse(writer, leftPrec, rightPrec);
59  if (columnList != null) {
60  SqlWriter.Frame frame = writer.startList("(", ")");
61  for (SqlNode c : columnList) {
62  writer.sep(",");
63  c.unparse(writer, 0, 0);
64  }
65  writer.endList(frame);
66  }
67  if (query != null) {
68  writer.newlineAndIndent();
69  query.unparse(writer, 0, 0);
70  }
71  }

Member Data Documentation

final SqlOperator com.mapd.parser.extension.ddl.SqlInsertIntoTable.OPERATOR
staticprivate
Initial value:
=
new SqlSpecialOperator("INSERT_INTO_TABLE_AS_SELECT", SqlKind.OTHER_DDL)

Definition at line 38 of file SqlInsertIntoTable.java.

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


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