Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ set(ICEBERG_SOURCES
expression/expression.cc
file_reader.cc
json_internal.cc
manifest_entry.cc
manifest_list.cc
metadata_columns.cc
name_mapping.cc
partition_field.cc
Expand Down
11 changes: 11 additions & 0 deletions src/iceberg/file_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string_view>

#include "iceberg/iceberg_export.h"
#include "iceberg/result.h"

namespace iceberg {

Expand All @@ -50,4 +51,14 @@ ICEBERG_EXPORT inline std::string_view ToString(FileFormatType format_type) {
}
}

/// \brief Convert a string to a FileFormatType
ICEBERG_EXPORT constexpr Result<FileFormatType> FileFormatTypeFromString(
std::string_view str) noexcept {
if (str == "parquet") return FileFormatType::kParquet;
if (str == "avro") return FileFormatType::kAvro;
if (str == "orc") return FileFormatType::kOrc;
if (str == "puffin") return FileFormatType::kPuffin;
return InvalidArgument("Invalid file format type: {}", str);
}

} // namespace iceberg
66 changes: 66 additions & 0 deletions src/iceberg/manifest_entry.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 "iceberg/manifest_entry.h"

#include <memory>
#include <vector>

#include "iceberg/schema_field.h"
#include "iceberg/type.h"

namespace iceberg {

std::shared_ptr<StructType> DataFile::Type(std::shared_ptr<StructType> partition_type) {
return std::make_shared<StructType>(std::vector<SchemaField>{
kContent,
kFilePath,
kFileFormat,
SchemaField::MakeRequired(102, "partition", std::move(partition_type)),
kRecordCount,
kFileSize,
kColumnSizes,
kValueCounts,
kNullValueCounts,
kNanValueCounts,
kLowerBounds,
kUpperBounds,
kKeyMetadata,
kSplitOffsets,
kEqualityIds,
kSortOrderId,
kFirstRowId,
kReferencedDataFile,
kContentOffset,
kContentSize});
}

std::shared_ptr<StructType> ManifestEntry::TypeFromPartitionType(
std::shared_ptr<StructType> partition_type) {
return TypeFromDataFileType(DataFile::Type(std::move(partition_type)));
}

std::shared_ptr<StructType> ManifestEntry::TypeFromDataFileType(
std::shared_ptr<StructType> datafile_type) {
return std::make_shared<StructType>(std::vector<SchemaField>{
kStatus, kSnapshotId, kSequenceNumber, kFileSequenceNumber,
SchemaField::MakeRequired(2, "data_file", std::move(datafile_type))});
}

} // namespace iceberg
Loading
Loading