Skip to content

Commit 911286c

Browse files
committed
[core][rest] Remove partition modification method in RESTCatalog
1 parent f47e4cc commit 911286c

File tree

35 files changed

+642
-747
lines changed

35 files changed

+642
-747
lines changed

paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.apache.paimon.table.FormatTable;
3535
import org.apache.paimon.table.Table;
3636
import org.apache.paimon.table.object.ObjectTable;
37-
import org.apache.paimon.table.sink.BatchTableCommit;
3837
import org.apache.paimon.table.system.SystemTableLoader;
3938
import org.apache.paimon.types.RowType;
4039

@@ -162,26 +161,6 @@ public Database getDatabase(String name) throws DatabaseNotExistException {
162161

163162
protected abstract Database getDatabaseImpl(String name) throws DatabaseNotExistException;
164163

165-
@Override
166-
public void createPartitions(Identifier identifier, List<Map<String, String>> partitions)
167-
throws TableNotExistException {}
168-
169-
@Override
170-
public void dropPartitions(Identifier identifier, List<Map<String, String>> partitions)
171-
throws TableNotExistException {
172-
checkNotSystemTable(identifier, "dropPartition");
173-
Table table = getTable(identifier);
174-
try (BatchTableCommit commit = table.newBatchWriteBuilder().newCommit()) {
175-
commit.truncatePartitions(partitions);
176-
} catch (Exception e) {
177-
throw new RuntimeException(e);
178-
}
179-
}
180-
181-
@Override
182-
public void alterPartitions(Identifier identifier, List<Partition> partitions)
183-
throws TableNotExistException {}
184-
185164
@Override
186165
public void markDonePartitions(Identifier identifier, List<Map<String, String>> partitions)
187166
throws TableNotExistException {}

paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,6 @@ public List<Partition> listPartitions(Identifier identifier) throws TableNotExis
271271
return result;
272272
}
273273

274-
@Override
275-
public void dropPartitions(Identifier identifier, List<Map<String, String>> partitions)
276-
throws TableNotExistException {
277-
wrapped.dropPartitions(identifier, partitions);
278-
if (partitionCache != null) {
279-
partitionCache.invalidate(identifier);
280-
}
281-
}
282-
283-
@Override
284-
public void alterPartitions(Identifier identifier, List<Partition> partitions)
285-
throws TableNotExistException {
286-
wrapped.alterPartitions(identifier, partitions);
287-
if (partitionCache != null) {
288-
partitionCache.invalidate(identifier);
289-
}
290-
}
291-
292274
@Override
293275
public void invalidateTable(Identifier identifier) {
294276
tableCache.invalidate(identifier);

paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -282,37 +282,6 @@ default void alterTable(Identifier identifier, SchemaChange change, boolean igno
282282

283283
// ======================= partition methods ===============================
284284

285-
/**
286-
* Create partitions of the specify table. Ignore existing partitions.
287-
*
288-
* @param identifier path of the table to create partitions
289-
* @param partitions partitions to be created
290-
* @throws TableNotExistException if the table does not exist
291-
*/
292-
void createPartitions(Identifier identifier, List<Map<String, String>> partitions)
293-
throws TableNotExistException;
294-
295-
/**
296-
* Drop partitions of the specify table. Ignore non-existent partitions.
297-
*
298-
* @param identifier path of the table to drop partitions
299-
* @param partitions partitions to be deleted
300-
* @throws TableNotExistException if the table does not exist
301-
*/
302-
void dropPartitions(Identifier identifier, List<Map<String, String>> partitions)
303-
throws TableNotExistException;
304-
305-
/**
306-
* Alter partitions of the specify table. For non-existent partitions, partitions will be
307-
* created directly.
308-
*
309-
* @param identifier path of the table to alter partitions
310-
* @param partitions partitions to be altered
311-
* @throws TableNotExistException if the table does not exist
312-
*/
313-
void alterPartitions(Identifier identifier, List<Partition> partitions)
314-
throws TableNotExistException;
315-
316285
/**
317286
* Mark partitions done of the specify table. For non-existent partitions, partitions will be
318287
* created directly.

paimon-core/src/main/java/org/apache/paimon/catalog/CatalogSnapshotCommit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.paimon.catalog;
2020

2121
import org.apache.paimon.Snapshot;
22-
import org.apache.paimon.partition.Partition;
22+
import org.apache.paimon.partition.PartitionStatistics;
2323
import org.apache.paimon.utils.SnapshotManager;
2424

2525
import java.util.List;
@@ -36,7 +36,7 @@ public CatalogSnapshotCommit(SupportsSnapshots supportsSnapshots, Identifier ide
3636
}
3737

3838
@Override
39-
public boolean commit(Snapshot snapshot, String branch, List<Partition> statistics)
39+
public boolean commit(Snapshot snapshot, String branch, List<PartitionStatistics> statistics)
4040
throws Exception {
4141
Identifier newIdentifier =
4242
new Identifier(identifier.getDatabaseName(), identifier.getTableName(), branch);

paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,6 @@ public void alterTable(
128128
wrapped.alterTable(identifier, changes, ignoreIfNotExists);
129129
}
130130

131-
@Override
132-
public void createPartitions(Identifier identifier, List<Map<String, String>> partitions)
133-
throws TableNotExistException {
134-
wrapped.createPartitions(identifier, partitions);
135-
}
136-
137-
@Override
138-
public void dropPartitions(Identifier identifier, List<Map<String, String>> partitions)
139-
throws TableNotExistException {
140-
wrapped.dropPartitions(identifier, partitions);
141-
}
142-
143-
@Override
144-
public void alterPartitions(Identifier identifier, List<Partition> partitions)
145-
throws TableNotExistException {
146-
wrapped.alterPartitions(identifier, partitions);
147-
}
148-
149131
@Override
150132
public void markDonePartitions(Identifier identifier, List<Map<String, String>> partitions)
151133
throws TableNotExistException {

paimon-core/src/main/java/org/apache/paimon/catalog/RenamingSnapshotCommit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.paimon.fs.FileIO;
2424
import org.apache.paimon.fs.Path;
2525
import org.apache.paimon.operation.Lock;
26-
import org.apache.paimon.partition.Partition;
26+
import org.apache.paimon.partition.PartitionStatistics;
2727
import org.apache.paimon.utils.SnapshotManager;
2828

2929
import javax.annotation.Nullable;
@@ -51,7 +51,7 @@ public RenamingSnapshotCommit(SnapshotManager snapshotManager, Lock lock) {
5151
}
5252

5353
@Override
54-
public boolean commit(Snapshot snapshot, String branch, List<Partition> statistics)
54+
public boolean commit(Snapshot snapshot, String branch, List<PartitionStatistics> statistics)
5555
throws Exception {
5656
Path newSnapshotPath =
5757
snapshotManager.branch().equals(branch)

paimon-core/src/main/java/org/apache/paimon/catalog/SnapshotCommit.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.paimon.catalog;
2020

2121
import org.apache.paimon.Snapshot;
22-
import org.apache.paimon.partition.Partition;
22+
import org.apache.paimon.partition.PartitionStatistics;
2323
import org.apache.paimon.utils.SnapshotManager;
2424

2525
import java.io.Serializable;
@@ -28,7 +28,8 @@
2828
/** Interface to commit snapshot atomically. */
2929
public interface SnapshotCommit extends AutoCloseable {
3030

31-
boolean commit(Snapshot snapshot, String branch, List<Partition> statistics) throws Exception;
31+
boolean commit(Snapshot snapshot, String branch, List<PartitionStatistics> statistics)
32+
throws Exception;
3233

3334
/** Factory to create {@link SnapshotCommit}. */
3435
interface Factory extends Serializable {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.paimon.catalog;
20+
21+
import org.apache.paimon.partition.PartitionStatistics;
22+
23+
import java.util.List;
24+
import java.util.Map;
25+
26+
/** A {@link Catalog} supports modifying table partitions. */
27+
public interface SupportsPartitionModification extends Catalog {
28+
29+
/**
30+
* Create partitions of the specify table. Ignore existing partitions.
31+
*
32+
* @param identifier path of the table to create partitions
33+
* @param partitions partitions to be created
34+
* @throws TableNotExistException if the table does not exist
35+
*/
36+
void createPartitions(Identifier identifier, List<Map<String, String>> partitions)
37+
throws TableNotExistException;
38+
39+
/**
40+
* Drop partitions of the specify table. Ignore non-existent partitions.
41+
*
42+
* @param identifier path of the table to drop partitions
43+
* @param partitions partitions to be deleted
44+
* @throws TableNotExistException if the table does not exist
45+
*/
46+
void dropPartitions(Identifier identifier, List<Map<String, String>> partitions)
47+
throws TableNotExistException;
48+
49+
/**
50+
* Alter partitions of the specify table. For non-existent partitions, partitions will be
51+
* created directly.
52+
*
53+
* @param identifier path of the table to alter partitions
54+
* @param partitions partitions to be altered
55+
* @throws TableNotExistException if the table does not exist
56+
*/
57+
void alterPartitions(Identifier identifier, List<PartitionStatistics> partitions)
58+
throws TableNotExistException;
59+
}

paimon-core/src/main/java/org/apache/paimon/catalog/SupportsSnapshots.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.paimon.catalog;
2020

2121
import org.apache.paimon.Snapshot;
22-
import org.apache.paimon.partition.Partition;
22+
import org.apache.paimon.partition.PartitionStatistics;
2323
import org.apache.paimon.table.TableSnapshot;
2424

2525
import java.util.List;
@@ -37,7 +37,8 @@ public interface SupportsSnapshots extends Catalog {
3737
* @return Success or not
3838
* @throws Catalog.TableNotExistException if the target does not exist
3939
*/
40-
boolean commitSnapshot(Identifier identifier, Snapshot snapshot, List<Partition> statistics)
40+
boolean commitSnapshot(
41+
Identifier identifier, Snapshot snapshot, List<PartitionStatistics> statistics)
4142
throws Catalog.TableNotExistException;
4243

4344
/**

paimon-core/src/main/java/org/apache/paimon/manifest/PartitionEntry.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.paimon.data.BinaryRow;
2323
import org.apache.paimon.io.DataFileMeta;
2424
import org.apache.paimon.partition.Partition;
25+
import org.apache.paimon.partition.PartitionStatistics;
2526
import org.apache.paimon.table.source.DataSplit;
2627
import org.apache.paimon.utils.InternalRowPartitionComputer;
2728

@@ -87,6 +88,16 @@ public PartitionEntry merge(PartitionEntry entry) {
8788

8889
public Partition toPartition(InternalRowPartitionComputer computer) {
8990
return new Partition(
91+
computer.generatePartValues(partition),
92+
recordCount,
93+
fileSizeInBytes,
94+
fileCount,
95+
lastFileCreationTime,
96+
false);
97+
}
98+
99+
public PartitionStatistics toPartitionStatistics(InternalRowPartitionComputer computer) {
100+
return new PartitionStatistics(
90101
computer.generatePartValues(partition),
91102
recordCount,
92103
fileSizeInBytes,

0 commit comments

Comments
 (0)