MCPcopy Create free account
hub / github.com/apache/impala / _write_insert_statement

Method _write_insert_statement

tests/comparison/model_translator.py:133–156  ·  view source on GitHub ↗

Taking in a InsertStatement object with some attributes set, return a string representation of the query in the correct dialect.

(self, insert_statement)

Source from the content-addressed store, hash-verified

131 return sql
132
133 def _write_insert_statement(self, insert_statement):
134 """
135 Taking in a InsertStatement object with some attributes set, return a string
136 representation of the query in the correct dialect.
137 """
138 sql = list()
139
140 if insert_statement.with_clause:
141 sql.append(self._write(insert_statement.with_clause))
142
143 if insert_statement.insert_clause:
144 sql.append(self._write(insert_statement.insert_clause))
145 else:
146 raise Exception('InsertStatement is missing insert_clause attribute')
147
148 if insert_statement.select_query and not insert_statement.values_clause:
149 sql.append(self._write(insert_statement.select_query))
150 elif not insert_statement.select_query and insert_statement.values_clause:
151 sql.append(self._write(insert_statement.values_clause))
152 else:
153 raise Exception('InsertStatement must have a select_query xor a values clause')
154
155 sql = '\n'.join(sql)
156 return sql
157
158 def make_pretty_sql(self, sql):
159 try:

Callers 1

Calls 3

_writeMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected