OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 26 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

List<SqlNode> com.mapd.parser.extension.ddl.SqlInsertIntoTable.getOperandList ( )
inline

Definition at line 43 of file SqlInsertIntoTable.java.

43  {
44  return null;
45  }
String com.mapd.parser.extension.ddl.SqlInsertIntoTable.toString ( )
inline

Definition at line 67 of file SqlInsertIntoTable.java.

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

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

Definition at line 48 of file SqlInsertIntoTable.java.

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

48  {
49  writer.keyword("INSERT");
50  writer.keyword("INTO");
51  name.unparse(writer, leftPrec, rightPrec);
52  if (columnList != null) {
53  SqlWriter.Frame frame = writer.startList("(", ")");
54  for (SqlNode c : columnList) {
55  writer.sep(",");
56  c.unparse(writer, 0, 0);
57  }
58  writer.endList(frame);
59  }
60  if (query != null) {
61  writer.newlineAndIndent();
62  query.unparse(writer, 0, 0);
63  }
64  }

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 31 of file SqlInsertIntoTable.java.

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


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