blob: 14df8e624f0ae71ba5eb116957268c384d827fc7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <Core/Block.h>
#include <Processors/Formats/Impl/JSONEachRowRowInputFormat.h>
#include <Processors/Formats/ISchemaReader.h>
#include <Formats/FormatSettings.h>
#include <Formats/SchemaInferenceUtils.h>
#include <Common/HashTable/HashMap.h>
namespace DB
{
class ReadBuffer;
class JSONObjectEachRowInputFormat final : public JSONEachRowRowInputFormat
{
public:
JSONObjectEachRowInputFormat(
ReadBuffer & in_,
const Block & header_,
Params params_,
const FormatSettings & format_settings_);
String getName() const override { return "JSONObjectEachRowInputFormat"; }
private:
void readPrefix() override;
void readSuffix() override {}
void readRowStart(MutableColumns & columns) override;
void skipRowStart() override;
bool checkEndOfData(bool is_first_row) override;
std::optional<size_t> field_index_for_object_name;
};
class JSONObjectEachRowSchemaReader : public IRowWithNamesSchemaReader
{
public:
JSONObjectEachRowSchemaReader(ReadBuffer & in_, const FormatSettings & format_settings_);
private:
NamesAndTypesList readRowAndGetNamesAndDataTypes(bool & eof) override;
NamesAndTypesList getStaticNamesAndTypes() override;
void transformTypesIfNeeded(DataTypePtr & type, DataTypePtr & new_type) override;
void transformFinalTypeIfNeeded(DataTypePtr & type) override;
bool first_row = true;
JSONInferenceInfo inference_info;
};
std::optional<size_t> getColumnIndexForJSONObjectEachRowObjectName(const Block & header, const FormatSettings & settings);
}
|