Skip to content

Commit 7eb13e2

Browse files
authored
Spark: Deprecate unused methods in SparkTableUtil and SparkSchemaUtil (apache#14308)
* Spark: Deprecate unused methods from SparkTableUtil and SparkSchemaUtil * fixup! Spark: Deprecate unused methods from SparkTableUtil and SparkSchemaUtil
1 parent f631298 commit 7eb13e2

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSchemaUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ public static Schema convert(Schema baseSchema, StructType sparkType, boolean ca
199199
* @param sparkType a Spark StructType
200200
* @return the equivalent Schema
201201
* @throws IllegalArgumentException if the type cannot be converted or there are missing ids
202+
* @deprecated since 1.11.0, will be removed in 1.12.0
202203
*/
204+
@Deprecated
203205
public static Schema convertWithFreshIds(Schema baseSchema, StructType sparkType) {
204206
return convertWithFreshIds(baseSchema, sparkType, true);
205207
}
@@ -263,7 +265,9 @@ public static Schema prune(Schema schema, StructType requestedType) {
263265
* @param filters a list of filters
264266
* @return a Schema corresponding to the Spark projection
265267
* @throws IllegalArgumentException if the Spark type does not match the Schema
268+
* @deprecated since 1.11.0, will be removed in 1.12.0
266269
*/
270+
@Deprecated
267271
public static Schema prune(Schema schema, StructType requestedType, List<Expression> filters) {
268272
Set<Integer> filterRefs = Binder.boundReferences(schema.asStruct(), filters, true);
269273
return new Schema(

spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ private SparkTableUtil() {}
143143
* @param spark a Spark session
144144
* @param table a table name and (optional) database
145145
* @return a DataFrame of the table's partitions
146+
* @deprecated since 1.11.0, will be removed in 1.12.0
146147
*/
148+
@Deprecated
147149
public static Dataset<Row> partitionDF(SparkSession spark, String table) {
148150
List<SparkPartition> partitions = getPartitions(spark, table);
149151
return spark
@@ -158,7 +160,9 @@ public static Dataset<Row> partitionDF(SparkSession spark, String table) {
158160
* @param table name of the table.
159161
* @param expression The expression whose matching partitions are returned.
160162
* @return a DataFrame of the table partitions.
163+
* @deprecated since 1.11.0, will be removed in 1.12.0
161164
*/
165+
@Deprecated
162166
public static Dataset<Row> partitionDFByFilter(
163167
SparkSession spark, String table, String expression) {
164168
List<SparkPartition> partitions = getPartitionsByFilter(spark, table, expression);
@@ -173,7 +177,9 @@ public static Dataset<Row> partitionDFByFilter(
173177
* @param spark a Spark session
174178
* @param table a table name and (optional) database
175179
* @return all table's partitions
180+
* @deprecated since 1.11.0, will be removed in 1.12.0
176181
*/
182+
@Deprecated
177183
public static List<SparkPartition> getPartitions(SparkSession spark, String table) {
178184
try {
179185
TableIdentifier tableIdent = spark.sessionState().sqlParser().parseTableIdentifier(table);
@@ -228,7 +234,9 @@ public static List<SparkPartition> getPartitions(
228234
* @param table a table name and (optional) database
229235
* @param predicate a predicate on partition columns
230236
* @return matching table's partitions
237+
* @deprecated since 1.11.0, will be removed in 1.12.0
231238
*/
239+
@Deprecated
232240
public static List<SparkPartition> getPartitionsByFilter(
233241
SparkSession spark, String table, String predicate) {
234242
TableIdentifier tableIdent;
@@ -258,7 +266,9 @@ public static List<SparkPartition> getPartitionsByFilter(
258266
* @param tableIdent a table identifier
259267
* @param predicateExpr a predicate expression on partition columns
260268
* @return matching table's partitions
269+
* @deprecated since 1.11.0, will be removed in 1.12.0
261270
*/
271+
@Deprecated
262272
public static List<SparkPartition> getPartitionsByFilter(
263273
SparkSession spark, TableIdentifier tableIdent, Expression predicateExpr) {
264274
try {
@@ -411,7 +421,9 @@ private static Iterator<ManifestFile> buildManifest(
411421
* @param partitionFilter only import partitions whose values match those in the map, can be
412422
* partially defined
413423
* @param checkDuplicateFiles if true, throw exception if import results in a duplicate data file
424+
* @deprecated since 1.11.0, will be removed in 1.12.0
414425
*/
426+
@Deprecated
415427
public static void importSparkTable(
416428
SparkSession spark,
417429
TableIdentifier sourceTableIdent,
@@ -434,7 +446,9 @@ public static void importSparkTable(
434446
* @param targetTable an Iceberg table where to import the data
435447
* @param stagingDir a staging directory to store temporary manifest files
436448
* @param parallelism number of threads to use for file reading
449+
* @deprecated since 1.11.0, will be removed in 1.12.0
437450
*/
451+
@Deprecated
438452
public static void importSparkTable(
439453
SparkSession spark,
440454
TableIdentifier sourceTableIdent,
@@ -627,7 +641,9 @@ public static void importSparkTable(
627641
* @param targetTable an Iceberg table where to import the data
628642
* @param stagingDir a staging directory to store temporary manifest files
629643
* @param checkDuplicateFiles if true, throw exception if import results in a duplicate data file
644+
* @deprecated since 1.11.0, will be removed in 1.12.0
630645
*/
646+
@Deprecated
631647
public static void importSparkTable(
632648
SparkSession spark,
633649
TableIdentifier sourceTableIdent,
@@ -732,7 +748,9 @@ private static void importUnpartitionedSparkTable(
732748
* @param spec a partition spec
733749
* @param stagingDir a staging directory to store temporary manifest files
734750
* @param checkDuplicateFiles if true, throw exception if import results in a duplicate data file
751+
* @deprecated since 1.11.0, will be removed in 1.12.0
735752
*/
753+
@Deprecated
736754
public static void importSparkPartitions(
737755
SparkSession spark,
738756
List<SparkPartition> partitions,
@@ -930,7 +948,9 @@ public static void importSparkPartitions(
930948
* @param targetTable an Iceberg table where to import the data
931949
* @param spec a partition spec
932950
* @param stagingDir a staging directory to store temporary manifest files
951+
* @deprecated since 1.11.0, will be removed in 1.12.0
933952
*/
953+
@Deprecated
934954
public static void importSparkPartitions(
935955
SparkSession spark,
936956
List<SparkPartition> partitions,
@@ -940,6 +960,10 @@ public static void importSparkPartitions(
940960
importSparkPartitions(spark, partitions, targetTable, spec, stagingDir, false, 1);
941961
}
942962

963+
/**
964+
* @deprecated since 1.11.0, will be removed in 1.12.0
965+
*/
966+
@Deprecated
943967
public static List<SparkPartition> filterPartitions(
944968
List<SparkPartition> partitions, Map<String, String> partitionFilter) {
945969
if (partitionFilter.isEmpty()) {

0 commit comments

Comments
 (0)