forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this commit we introduces IcebergSplitReader which supports reading Iceberg splits with positional delete files. Add subfield filter for the delete file path column
- Loading branch information
Showing
16 changed files
with
1,165 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
add_library( | ||
velox_hive_iceberg_splitreader IcebergSplitReader.cpp IcebergSplit.cpp | ||
PositionalDeleteFileReader.cpp) | ||
|
||
target_link_libraries( | ||
velox_hive_iceberg_splitreader | ||
Folly::folly | ||
gflags::gflags | ||
glog::glog | ||
gtest | ||
gtest_main | ||
xsimd) | ||
|
||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
#include "velox/dwio/common/Options.h" | ||
|
||
namespace facebook::velox::connector::hive::iceberg { | ||
|
||
enum class FileContent { | ||
kData, | ||
kPositionalDeletes, | ||
kEqualityDeletes, | ||
}; | ||
|
||
struct IcebergDeleteFile { | ||
FileContent content; | ||
const std::string filePath; | ||
dwio::common::FileFormat fileFormat; | ||
uint64_t recordCount; | ||
uint64_t fileSizeInBytes; | ||
// The field ids for the delete columns for equality delete files | ||
std::vector<int32_t> equalityFieldIds; | ||
// The lower bounds of the in-file positions for the deleted rows, identified | ||
// by each column's field id. E.g. The deleted rows for a column with field id | ||
// 1 is in range [10, 50], where 10 and 50 are the deleted row positions in | ||
// the data file, then lowerBounds would contain entry <1, "10"> | ||
std::unordered_map<int32_t, std::string> lowerBounds; | ||
// The upper bounds of the in-file positions for the deleted rows, identified | ||
// by each column's field id. E.g. The deleted rows for a column with field id | ||
// 1 is in range [10, 50], then upperBounds will contain entry <1, "50"> | ||
std::unordered_map<int32_t, std::string> upperBounds; | ||
|
||
IcebergDeleteFile( | ||
FileContent _content, | ||
const std::string& _filePath, | ||
dwio::common::FileFormat _fileFormat, | ||
uint64_t _recordCount, | ||
uint64_t _fileSizeInBytes, | ||
std::vector<int32_t> _equalityFieldIds = {}, | ||
std::unordered_map<int32_t, std::string> _lowerBounds = {}, | ||
std::unordered_map<int32_t, std::string> _upperBounds = {}) | ||
: content(_content), | ||
filePath(_filePath), | ||
fileFormat(_fileFormat), | ||
recordCount(_recordCount), | ||
fileSizeInBytes(_fileSizeInBytes), | ||
equalityFieldIds(_equalityFieldIds), | ||
lowerBounds(_lowerBounds), | ||
upperBounds(_upperBounds) {} | ||
}; | ||
|
||
} // namespace facebook::velox::connector::hive::iceberg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "velox/type/Type.h" | ||
|
||
namespace facebook::velox::connector::hive::iceberg { | ||
|
||
struct IcebergMetadataColumn { | ||
int id; | ||
std::string name; | ||
std::shared_ptr<const Type> type; | ||
std::string doc; | ||
|
||
IcebergMetadataColumn( | ||
int _id, | ||
const std::string& _name, | ||
std::shared_ptr<const Type> _type, | ||
const std::string& _doc) | ||
: id(_id), name(_name), type(_type), doc(_doc) {} | ||
|
||
static std::shared_ptr<IcebergMetadataColumn> icebergDeleteFilePathColumn() { | ||
return std::make_shared<IcebergMetadataColumn>( | ||
2147483546, | ||
"file_path", | ||
VARCHAR(), | ||
"Path of a file in which a deleted row is stored"); | ||
} | ||
|
||
static std::shared_ptr<IcebergMetadataColumn> icebergDeletePosColumn() { | ||
return std::make_shared<IcebergMetadataColumn>( | ||
2147483545, | ||
"pos", | ||
BIGINT(), | ||
"Ordinal position of a deleted row in the data file"); | ||
} | ||
}; | ||
|
||
} // namespace facebook::velox::connector::hive::iceberg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "velox/connectors/hive/iceberg/IcebergSplit.h" | ||
|
||
#include "velox/connectors/hive/iceberg/IcebergDeleteFile.h" | ||
|
||
namespace facebook::velox::connector::hive::iceberg { | ||
|
||
HiveIcebergSplit::HiveIcebergSplit( | ||
const std::string& _connectorId, | ||
const std::string& _filePath, | ||
dwio::common::FileFormat _fileFormat, | ||
uint64_t _start, | ||
uint64_t _length, | ||
const std::unordered_map<std::string, std::optional<std::string>>& | ||
_partitionKeys, | ||
std::optional<int32_t> _tableBucketNumber, | ||
const std::unordered_map<std::string, std::string>& _customSplitInfo, | ||
const std::shared_ptr<std::string>& _extraFileInfo) | ||
: HiveConnectorSplit( | ||
_connectorId, | ||
_filePath, | ||
_fileFormat, | ||
_start, | ||
_length, | ||
_partitionKeys, | ||
_tableBucketNumber) { | ||
// TODO: Deserialize _extraFileInfo to get deleteFiles; | ||
} | ||
|
||
// For tests only | ||
HiveIcebergSplit::HiveIcebergSplit( | ||
const std::string& _connectorId, | ||
const std::string& _filePath, | ||
dwio::common::FileFormat _fileFormat, | ||
uint64_t _start, | ||
uint64_t _length, | ||
const std::unordered_map<std::string, std::optional<std::string>>& | ||
_partitionKeys, | ||
std::optional<int32_t> _tableBucketNumber, | ||
const std::unordered_map<std::string, std::string>& _customSplitInfo, | ||
const std::shared_ptr<std::string>& _extraFileInfo, | ||
std::vector<IcebergDeleteFile> _deletes) | ||
: HiveConnectorSplit( | ||
_connectorId, | ||
_filePath, | ||
_fileFormat, | ||
_start, | ||
_length, | ||
_partitionKeys, | ||
_tableBucketNumber, | ||
_customSplitInfo, | ||
_extraFileInfo), | ||
deleteFiles(_deletes) {} | ||
} // namespace facebook::velox::connector::hive::iceberg |
Oops, something went wrong.