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

Public Member Functions

 SqlInsertValues (SqlParserPos pos, SqlNode name, SqlNode values, SqlNodeList columnList)
 
List< SqlNode > getOperandList ()
 
void unparse (SqlWriter writer, int leftPrec, int rightPrec)
 
String toString ()
 

Public Attributes

final SqlNode name
 
SqlNode values
 
final SqlNodeList columnList
 

Private Member Functions

Object toJson (SqlNode node, JsonBuilder jsonBuilder)
 
Object toJson (SqlLiteral literal, JsonBuilder jsonBuilder)
 
Object toJson (SqlBasicCall call, JsonBuilder jsonBuilder)
 
Object rowToJson (SqlBasicCall row, JsonBuilder jsonBuilder)
 
Object arrayToJson (SqlBasicCall array, JsonBuilder jsonBuilder)
 

Static Private Attributes

static final SqlOperator OPERATOR
 

Detailed Description

Definition at line 18 of file SqlInsertValues.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlInsertValues.SqlInsertValues ( SqlParserPos  pos,
SqlNode  name,
SqlNode  values,
SqlNodeList  columnList 
)
inline

Member Function Documentation

Object com.mapd.parser.extension.ddl.SqlInsertValues.arrayToJson ( SqlBasicCall  array,
JsonBuilder  jsonBuilder 
)
inlineprivate

Definition at line 127 of file SqlInsertValues.java.

References com.mapd.parser.extension.ddl.SqlInsertValues.toJson().

Referenced by com.mapd.parser.extension.ddl.SqlInsertValues.toJson().

127  {
128  final Map<String, @Nullable Object> map = jsonBuilder.map();
129  List<Object> elements = jsonBuilder.list();
130  for (SqlNode operand : array.getOperands()) {
131  elements.add(toJson(operand, jsonBuilder));
132  }
133  map.put("array", elements);
134  return map;
135  }
Object toJson(SqlNode node, JsonBuilder jsonBuilder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

List<SqlNode> com.mapd.parser.extension.ddl.SqlInsertValues.getOperandList ( )
inline
Object com.mapd.parser.extension.ddl.SqlInsertValues.rowToJson ( SqlBasicCall  row,
JsonBuilder  jsonBuilder 
)
inlineprivate

Definition at line 119 of file SqlInsertValues.java.

References com.mapd.parser.extension.ddl.SqlInsertValues.toJson(), and com.mapd.parser.extension.ddl.SqlInsertValues.values.

Referenced by com.mapd.parser.extension.ddl.SqlInsertValues.toJson().

119  {
120  List<Object> values = jsonBuilder.list();
121  for (SqlNode operand : row.getOperands()) {
122  values.add(toJson(operand, jsonBuilder));
123  }
124  return values;
125  }
Object toJson(SqlNode node, JsonBuilder jsonBuilder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Object com.mapd.parser.extension.ddl.SqlInsertValues.toJson ( SqlNode  node,
JsonBuilder  jsonBuilder 
)
inlineprivate

Definition at line 85 of file SqlInsertValues.java.

Referenced by com.mapd.parser.extension.ddl.SqlInsertValues.arrayToJson(), com.mapd.parser.extension.ddl.SqlInsertValues.rowToJson(), and com.mapd.parser.extension.ddl.SqlInsertValues.toString().

85  {
86  if (node instanceof SqlLiteral) {
87  return toJson((SqlLiteral) node, jsonBuilder);
88  } else if (node instanceof SqlBasicCall) {
89  return toJson((SqlBasicCall) node, jsonBuilder);
90  } else {
91  throw new RuntimeException(
92  "Unexpected node in values statement: " + node.toString());
93  }
94  }
Object toJson(SqlNode node, JsonBuilder jsonBuilder)

+ Here is the caller graph for this function:

Object com.mapd.parser.extension.ddl.SqlInsertValues.toJson ( SqlLiteral  literal,
JsonBuilder  jsonBuilder 
)
inlineprivate

Definition at line 96 of file SqlInsertValues.java.

References com.mapd.parser.extension.ddl.SqlInsertValues.toString().

96  {
97  final Map<String, @Nullable Object> map = jsonBuilder.map();
98  map.put("literal", literal.toValue());
99  map.put("type", literal.getTypeName().toString());
100  if (literal instanceof SqlNumericLiteral) {
101  SqlNumericLiteral numeric = (SqlNumericLiteral) literal;
102  map.put("scale", numeric.getScale());
103  map.put("precision", numeric.getPrec());
104  }
105  return map;
106  }

+ Here is the call graph for this function:

Object com.mapd.parser.extension.ddl.SqlInsertValues.toJson ( SqlBasicCall  call,
JsonBuilder  jsonBuilder 
)
inlineprivate

Definition at line 108 of file SqlInsertValues.java.

References com.mapd.parser.extension.ddl.SqlInsertValues.arrayToJson(), and com.mapd.parser.extension.ddl.SqlInsertValues.rowToJson().

108  {
109  if (call.getOperator().kind == SqlKind.ARRAY_VALUE_CONSTRUCTOR) {
110  return arrayToJson(call, jsonBuilder);
111  } else if (call.getOperator().kind == SqlKind.ROW) {
112  return rowToJson(call, jsonBuilder);
113  } else {
114  throw new RuntimeException(
115  "Unexpected sql call: " + call.getOperator().kind.toString());
116  }
117  }
Object rowToJson(SqlBasicCall row, JsonBuilder jsonBuilder)
Object arrayToJson(SqlBasicCall array, JsonBuilder jsonBuilder)

+ Here is the call graph for this function:

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

Definition at line 60 of file SqlInsertValues.java.

References com.mapd.parser.extension.ddl.SqlInsertValues.columnList, com.mapd.parser.extension.ddl.SqlInsertValues.toJson(), and com.mapd.parser.extension.ddl.SqlInsertValues.values.

Referenced by com.mapd.parser.extension.ddl.SqlInsertValues.toJson().

60  {
61  JsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
62  Map<String, Object> map = jsonBuilder.map();
63 
64  map.put("command", "INSERT_VALUES_INTO_TABLE");
65  map.put("name", this.name.toString());
66 
67  if (columnList != null) {
68  List<Object> col_list = jsonBuilder.list();
69  for (SqlNode col : this.columnList) {
70  col_list.add(col.toString());
71  }
72  jsonBuilder.put(map, "columns", col_list);
73  }
74 
75  List<Object> rows = jsonBuilder.list();
76  for (SqlNode row_node : ((SqlBasicCall) values).getOperands()) {
77  rows.add(toJson(row_node, jsonBuilder));
78  }
79  jsonBuilder.put(map, "values", rows);
80  Map<String, Object> payload = jsonBuilder.map();
81  payload.put("payload", map);
82  return jsonBuilder.toJsonString(payload);
83  }
Object toJson(SqlNode node, JsonBuilder jsonBuilder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void com.mapd.parser.extension.ddl.SqlInsertValues.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 41 of file SqlInsertValues.java.

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

41  {
42  writer.keyword("INSERT");
43  writer.keyword("INTO");
44  name.unparse(writer, leftPrec, rightPrec);
45  if (columnList != null) {
46  SqlWriter.Frame frame = writer.startList("(", ")");
47  for (SqlNode c : columnList) {
48  writer.sep(",");
49  c.unparse(writer, 0, 0);
50  }
51  writer.endList(frame);
52  }
53  writer.keyword("VALUES");
54  SqlWriter.Frame frame = writer.startList("(", ")");
55  values.unparse(writer, leftPrec, rightPrec);
56  writer.endList(frame);
57  }

Member Data Documentation

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

Definition at line 23 of file SqlInsertValues.java.

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


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