Skip to content

Commit c2a4a5f

Browse files
committed
address review: meson, Hive-compat note, reject no-data-files in Validate
- Add replace_partitions.h to src/iceberg/update/meson.build (manuzhang) - Add Java-style note recommending OverwriteFiles for non-Hive use (zhjwpku) - Validate(): call DataSpec() to reject no-data-files replace, matching Java BaseReplacePartitions which throws when no file was added (manuzhang)
1 parent 90ae61d commit c2a4a5f

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/iceberg/update/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install_headers(
2323
'merge_append.h',
2424
'merging_snapshot_update.h',
2525
'pending_update.h',
26+
'replace_partitions.h',
2627
'row_delta.h',
2728
'set_snapshot.h',
2829
'snapshot_manager.h',

src/iceberg/update/replace_partitions.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ std::string ReplacePartitions::operation() { return DataOperation::kOverwrite; }
9191

9292
Status ReplacePartitions::Validate(const TableMetadata& current_metadata,
9393
const std::shared_ptr<Snapshot>& snapshot) {
94+
// Java's BaseReplacePartitions requires at least one staged data file:
95+
// dataSpec() throws if none was added. Call DataSpec() up front to surface
96+
// the same error here, instead of silently committing an empty snapshot.
97+
ICEBERG_ASSIGN_OR_RAISE(auto data_spec, DataSpec());
98+
9499
if (snapshot == nullptr) {
95100
return {};
96101
}

src/iceberg/update/replace_partitions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ namespace iceberg {
4949
/// When committing, these changes are applied to the latest table snapshot.
5050
/// Commit conflicts are resolved by re-applying to the new latest snapshot
5151
/// and reattempting the commit.
52+
///
53+
/// \note This is provided to implement SQL compatible with Hive table
54+
/// operations but is not recommended. Instead, use OverwriteFiles to
55+
/// explicitly overwrite data.
5256
class ICEBERG_EXPORT ReplacePartitions : public MergingSnapshotUpdate {
5357
public:
5458
/// \brief Create a new ReplacePartitions instance.

0 commit comments

Comments
 (0)