MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / readRow

Method readRow

src/Processors/Formats/Impl/JSONEachRowRowInputFormat.cpp:213–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211
212
213bool JSONEachRowRowInputFormat::readRow(MutableColumns & columns, RowReadExtension & ext)
214{
215 if (!allow_new_rows)
216 return false;
217 skipWhitespaceIfAny(*in);
218
219 bool is_first_row = getRowNum() == 0;
220 if (checkEndOfData(is_first_row))
221 return false;
222
223 size_t num_columns = columns.size();
224 total_columns = num_columns;
225 seen_columns_count = 0;
226
227 read_columns.assign(num_columns, false);
228 seen_columns.assign(num_columns, false);
229
230 nested_prefix_length = 0;
231 readRowStart(columns);
232 readJSONObject(columns);
233
234 const auto & header = getPort().getHeader();
235 /// Fill non-visited columns with the default values.
236 for (size_t i = 0; i < num_columns; ++i)
237 if (!seen_columns[i])
238 {
239 const auto & type = header.getByPosition(i).type;
240 if (format_settings.force_null_for_omitted_fields && !isNullableOrLowCardinalityNullable(type))
241 throw Exception(ErrorCodes::TYPE_MISMATCH, "Cannot insert NULL value into a column `{}` of type '{}'", columnName(i), type->getName());
242 type->insertDefaultInto(*columns[i]);
243 }
244
245
246 /// Return info about defaults set.
247 /// If defaults_for_omitted_fields is set to 0, we should just leave already inserted defaults.
248 if (format_settings.defaults_for_omitted_fields)
249 ext.read_columns = read_columns;
250 else
251 ext.read_columns.assign(read_columns.size(), true);
252
253 return true;
254}
255
256bool JSONEachRowRowInputFormat::checkEndOfData(bool is_first_row)
257{

Callers

nothing calls this directly

Calls 8

skipWhitespaceIfAnyFunction · 0.85
ExceptionClass · 0.50
sizeMethod · 0.45
assignMethod · 0.45
getHeaderMethod · 0.45
getNameMethod · 0.45
insertDefaultIntoMethod · 0.45

Tested by

no test coverage detected