Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion cmake_modules/IcebergThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ function(resolve_arrow_dependency)
set(ARROW_BUILD_STATIC
ON
CACHE BOOL "" FORCE)
# Work around undefined symbol: arrow::ipc::ReadSchema(arrow::io::InputStream*, arrow::ipc::DictionaryMemo*)
set(ARROW_IPC
OFF
ON
CACHE BOOL "" FORCE)
set(ARROW_FILESYSTEM
ON
Expand Down
6 changes: 5 additions & 1 deletion src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ if(ICEBERG_BUILD_BUNDLE)
avro/avro_reader.cc
avro/avro_schema_util.cc
avro/avro_register.cc
avro/avro_stream_internal.cc)
avro/avro_stream_internal.cc
parquet/parquet_data_util.cc
parquet/parquet_reader.cc
parquet/parquet_schema_util.cc)

# Libraries to link with exported libiceberg_bundle.{so,a}.
set(ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS)
Expand Down Expand Up @@ -161,6 +164,7 @@ if(ICEBERG_BUILD_BUNDLE)

add_subdirectory(arrow)
add_subdirectory(avro)
add_subdirectory(parquet)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_bundle_export.h
DESTINATION ${ICEBERG_INSTALL_INCLUDEDIR}/iceberg)
Expand Down
23 changes: 12 additions & 11 deletions src/iceberg/arrow/arrow_error_transform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ inline ErrorKind ToErrorKind(const ::arrow::Status& status) {
} \
lhs = std::move(result_name).ValueOrDie();

#define ICEBERG_ARROW_ASSIGN_OR_RETURN(lhs, rexpr) \
ICEBERG_ARROW_ASSIGN_OR_RETURN_IMPL( \
ARROW_ASSIGN_OR_RAISE_NAME(_error_or_value, __COUNTER__), lhs, rexpr, ToErrorKind)

#define ICEBERG_ARROW_RETURN_NOT_OK(expr) \
do { \
auto&& _status = (expr); \
if (!_status.ok()) { \
return std::unexpected<Error>{ \
{.kind = ToErrorKind(_status), .message = _status.ToString()}}; \
} \
#define ICEBERG_ARROW_ASSIGN_OR_RETURN(lhs, rexpr) \
ICEBERG_ARROW_ASSIGN_OR_RETURN_IMPL( \
ARROW_ASSIGN_OR_RAISE_NAME(_error_or_value, __COUNTER__), lhs, rexpr, \
::iceberg::arrow::ToErrorKind)

#define ICEBERG_ARROW_RETURN_NOT_OK(expr) \
do { \
auto&& _status = (expr); \
if (!_status.ok()) { \
return std::unexpected<Error>{{.kind = ::iceberg::arrow::ToErrorKind(_status), \
.message = _status.ToString()}}; \
} \
} while (0)

} // namespace iceberg::arrow
18 changes: 18 additions & 0 deletions src/iceberg/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

iceberg_install_all_headers(iceberg/parquet)
31 changes: 31 additions & 0 deletions src/iceberg/parquet/parquet_data_util.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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/parquet/parquet_data_util_internal.h"

namespace iceberg::parquet {

Result<std::shared_ptr<::arrow::RecordBatch>> ProjectRecordBatch(
std::shared_ptr<::arrow::RecordBatch> record_batch,
const std::shared_ptr<::arrow::Schema>& output_arrow_schema,
const Schema& projected_schema, const SchemaProjection& projection) {
return NotImplemented("NYI");
}

} // namespace iceberg::parquet
43 changes: 43 additions & 0 deletions src/iceberg/parquet/parquet_data_util_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.
*/

#pragma once

#include "iceberg/schema_util.h"

namespace arrow {
class RecordBatch;
class Schema;
} // namespace arrow

namespace iceberg::parquet {

/// \brief Convert record batch read from a Parquet file to projected Iceberg Schema.
///
/// \param record_batch The record batch to convert.
/// \param output_arrow_schema The Arrow schema to convert to.
/// \param projected_schema The projected Iceberg schema.
/// \param projection The projection from projected Iceberg schema to the record batch.
/// \return The converted record batch.
Result<std::shared_ptr<::arrow::RecordBatch>> ProjectRecordBatch(
std::shared_ptr<::arrow::RecordBatch> record_batch,
const std::shared_ptr<::arrow::Schema>& output_arrow_schema,
const Schema& projected_schema, const SchemaProjection& projection);

} // namespace iceberg::parquet
Loading
Loading