|
19 | 19 | import java.util.Map; |
20 | 20 |
|
21 | 21 | import org.apache.spark.annotation.Experimental; |
| 22 | +import org.apache.spark.sql.catalyst.InternalRow; |
| 23 | +import org.apache.spark.sql.catalyst.analysis.NoSuchPartitionException; |
| 24 | +import org.apache.spark.sql.catalyst.analysis.PartitionAlreadyExistsException; |
22 | 25 |
|
23 | 26 | /** |
24 | | - * Catalog methods for working with Partitions. |
| 27 | + * A partition interface of {@link Table} to indicate partition APIs. |
| 28 | + * A partition is composed of identifier and properties, |
| 29 | + * and properties contains metadata information of the partition. |
| 30 | + * <p> |
| 31 | + * These APIs are used to modify table partition identifier or partition metadata, |
| 32 | + * in some cases, they will change actual value of table data as well. |
| 33 | + * |
| 34 | + * @since 3.0.0 |
25 | 35 | */ |
26 | 36 | @Experimental |
27 | | -public interface SupportsPartitions extends TableCatalog { |
28 | | - |
29 | | - /** |
30 | | - * Create partitions in an existing table, assuming it exists. |
31 | | - * |
32 | | - * @param ident a table identifier |
33 | | - * @param partitions transforms to use for partitioning data in the table |
34 | | - * @param ignoreIfExists |
35 | | - */ |
36 | | - void createPartitions( |
37 | | - Identifier ident, |
38 | | - TablePartition[] partitions, |
39 | | - Boolean ignoreIfExists); |
| 37 | +public interface SupportsPartitions extends Table { |
40 | 38 |
|
41 | 39 | /** |
42 | | - * Drop partitions from a table, assuming they exist. |
| 40 | + * Create a partition in table. |
43 | 41 | * |
44 | | - * @param ident a table identifier |
45 | | - * @param partitions a list of string map for existing partitions |
46 | | - * @param ignoreIfNotExists |
| 42 | + * @param ident a new partition identifier |
| 43 | + * @param properties the metadata of a partition |
| 44 | + * @throws PartitionAlreadyExistsException If a partition already exists for the identifier |
47 | 45 | */ |
48 | | - void dropPartitions( |
49 | | - Identifier ident, |
50 | | - Map<String, String>[] partitions, |
51 | | - Boolean ignoreIfNotExists); |
| 46 | + void createPartition( |
| 47 | + InternalRow ident, |
| 48 | + Map<String, String> properties) throws PartitionAlreadyExistsException; |
52 | 49 |
|
53 | 50 | /** |
54 | | - * Override the specs of one or many existing table partitions, assuming they exist. |
| 51 | + * Drop a partition from table. |
55 | 52 | * |
56 | | - * @param ident a table identifier |
57 | | - * @param oldpartitions a list of string map for existing partitions to be renamed |
58 | | - * @param newPartitions a list of string map for new partitions |
| 53 | + * @param ident a partition identifier |
| 54 | + * @return true if a partition was deleted, false if no partition exists for the identifier |
59 | 55 | */ |
60 | | - void renamePartitions( |
61 | | - Identifier ident, |
62 | | - Map<String, String>[] oldpartitions, |
63 | | - Map<String, String>[] newPartitions); |
| 56 | + Boolean dropPartition(InternalRow ident); |
64 | 57 |
|
65 | 58 | /** |
66 | | - * Alter one or many table partitions whose specs that match those specified in `parts`, |
67 | | - * assuming the partitions exist. |
| 59 | + * Rename a Partition from old identifier to new identifier with no metadata changed. |
68 | 60 | * |
69 | | - * @param ident a table identifier |
70 | | - * @param partitions transforms to use for partitioning data in the table |
| 61 | + * @param oldIdent the partition identifier of the existing partition |
| 62 | + * @param newIdent the new partition identifier of the partition |
| 63 | + * @throws NoSuchPartitionException If the partition identifier to rename doesn't exist |
| 64 | + * @throws PartitionAlreadyExistsException If the new partition identifier already exists |
71 | 65 | */ |
72 | | - void alterPartitions( |
73 | | - Identifier ident, |
74 | | - TablePartition[] partitions); |
| 66 | + void renamePartition( |
| 67 | + InternalRow oldIdent, |
| 68 | + InternalRow newIdent) throws NoSuchPartitionException, PartitionAlreadyExistsException; |
75 | 69 |
|
76 | 70 | /** |
77 | | - * Retrieve the metadata of a table partition, assuming it exists. |
| 71 | + * Replace the partition metadata of the existing partition. |
78 | 72 | * |
79 | | - * @param ident a table identifier |
80 | | - * @param partition a list of string map for existing partitions |
| 73 | + * @param ident the partition identifier of the existing partition |
| 74 | + * @param properties the new metadata of the partition |
| 75 | + * @throws NoSuchPartitionException If the partition identifier to rename doesn't exist |
81 | 76 | */ |
82 | | - TablePartition getPartition( |
83 | | - Identifier ident, |
84 | | - Map<String, String> partition); |
| 77 | + void replacePartitionMetadata( |
| 78 | + InternalRow ident, |
| 79 | + Map<String, String> properties) throws NoSuchPartitionException; |
85 | 80 |
|
86 | 81 | /** |
87 | | - * List the names of all partitions that belong to the specified table, assuming it exists. |
| 82 | + * Retrieve the partition metadata of the existing partition. |
88 | 83 | * |
89 | | - * @param ident a table identifier |
90 | | - * @param partition a list of string map for existing partitions |
| 84 | + * @param ident a partition identifier |
| 85 | + * @return the metadata of the partition |
91 | 86 | */ |
92 | | - String[] listPartitionNames( |
93 | | - Identifier ident, |
94 | | - Map<String, String> partition); |
| 87 | + Map<String, String> getPartitionMetadata(InternalRow ident); |
95 | 88 |
|
96 | 89 | /** |
97 | | - * List the metadata of all partitions that belong to the specified table, assuming it exists. |
| 90 | + * List the identifiers of all partitions that contains the ident in a table. |
98 | 91 | * |
99 | | - * @param ident a table identifier |
100 | | - * @param partition a list of string map for existing partitions |
| 92 | + * @param ident a prefix of partition identifier |
| 93 | + * @return an array of Identifiers for the partitions |
101 | 94 | */ |
102 | | - TablePartition[] listPartitions( |
103 | | - Identifier ident, |
104 | | - Map<String, String> partition); |
| 95 | + InternalRow[] listPartitionIdentifiers(InternalRow ident); |
105 | 96 | } |
0 commit comments