forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDeltaLakeMetadataDeltaKernel.cpp
More file actions
76 lines (64 loc) · 2.21 KB
/
DeltaLakeMetadataDeltaKernel.cpp
File metadata and controls
76 lines (64 loc) · 2.21 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "config.h"
#if USE_PARQUET && USE_DELTA_KERNEL_RS
#include <Storages/ObjectStorage/DataLakes/DeltaLakeMetadataDeltaKernel.h>
#include <Storages/ObjectStorage/DataLakes/DeltaLake/TableSnapshot.h>
namespace DB
{
DeltaLakeMetadataDeltaKernel::DeltaLakeMetadataDeltaKernel(
ObjectStoragePtr object_storage,
ConfigurationObserverPtr configuration_,
bool read_schema_same_as_table_schema_)
: log(getLogger("DeltaLakeMetadata"))
, table_snapshot(
std::make_shared<DeltaLake::TableSnapshot>(
getKernelHelper(configuration_.lock(), object_storage),
object_storage,
read_schema_same_as_table_schema_,
log))
{
}
bool DeltaLakeMetadataDeltaKernel::operator ==(const IDataLakeMetadata & metadata) const
{
const auto & delta_lake_metadata = dynamic_cast<const DeltaLakeMetadataDeltaKernel &>(metadata);
return table_snapshot->getVersion() == delta_lake_metadata.table_snapshot->getVersion();
}
bool DeltaLakeMetadataDeltaKernel::update(const ContextPtr &)
{
return table_snapshot->update();
}
Strings DeltaLakeMetadataDeltaKernel::getDataFiles() const
{
throwNotImplemented("getDataFiles()");
}
ObjectIterator DeltaLakeMetadataDeltaKernel::iterate(
const ActionsDAG * filter_dag,
FileProgressCallback callback,
size_t list_batch_size) const
{
return table_snapshot->iterate(filter_dag, callback, list_batch_size);
}
NamesAndTypesList DeltaLakeMetadataDeltaKernel::getTableSchema() const
{
return table_snapshot->getTableSchema();
}
NamesAndTypesList DeltaLakeMetadataDeltaKernel::getReadSchema() const
{
auto schema = table_snapshot->getReadSchema();
/// Read schema does not contain partition columns
/// because they are not present in the actual data.
/// We have to add them here.
auto partition_columns = table_snapshot->getPartitionColumns();
if (!partition_columns.empty())
{
auto table_schema = getTableSchema();
for (const auto & column : partition_columns)
{
auto name_and_type = table_schema.tryGetByName(column);
if (name_and_type.has_value())
schema.insert(schema.end(), name_and_type.value());
}
}
return schema;
}
}
#endif