Skip to content

Commit 6efed89

Browse files
committed
Merge remote-tracking branch 'upstream/main' into refine_Spark_3_words_from_docs
2 parents 5033945 + 92ae3d9 commit 6efed89

File tree

277 files changed

+6251
-2264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+6251
-2264
lines changed

.baseline/checkstyle/checkstyle-suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
<!-- Allow using Flink's shaded Curator dependency -->
5353
<suppress files="org.apache.iceberg.flink.maintenance.api.ZkLockFactory" id="BanShadedClasses"/>
54+
<suppress files="org.apache.iceberg.flink.maintenance.api.TestZkLockFactory" id="BanShadedClasses"/>
5455

5556
<!-- Suppress checks for CometColumnReader -->
5657
<suppress files="org.apache.iceberg.spark.data.vectorized.CometColumnReader" checks="IllegalImport"/>

.baseline/checkstyle/checkstyle.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@
265265
<property name="illegalClasses" value="org.apache.flink.util.Preconditions"/>
266266
<message key="import.illegal" value="Use org.apache.iceberg.relocated.com.google.common.base.Preconditions instead."/>
267267
</module>
268+
<module name="IllegalImport">
269+
<property name="id" value="BanHadoopUtils"/>
270+
<property name="regexp" value="true"/>
271+
<property name="illegalClasses" value="^org\.apache\.hadoop\.util\.(Sets|Lists|Preconditions)"/>
272+
<message key="import.illegal" value="Use org.apache.iceberg.relocated.* classes from bundled-guava module instead."/>
273+
</module>
268274
<module name="IllegalImport">
269275
<property name="id" value="GuavaClassesInAssertJ"/>
270276
<property name="illegalPkgs" value="org.assertj.core.util"/>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ Iceberg table support is organized in library modules:
7171

7272
Iceberg also has modules for adding Iceberg support to processing engines:
7373

74-
* `iceberg-spark` is an implementation of Spark's Datasource V2 API for Iceberg with submodules for each spark versions (use runtime jars for a shaded version)
75-
* `iceberg-flink` contains classes for integrating with Apache Flink (use iceberg-flink-runtime for a shaded version)
74+
* `iceberg-spark` is an implementation of Spark's Datasource V2 API for Iceberg with submodules for each spark versions (use [runtime jars](https://iceberg.apache.org/multi-engine-support/#runtime-jar) for a shaded version to avoid dependency conflicts)
75+
* `iceberg-flink` contains classes for integrating with Apache Flink (use [iceberg-flink-runtime](https://iceberg.apache.org/multi-engine-support/#runtime-jar) for a shaded version)
7676
* `iceberg-mr` contains an InputFormat and other classes for integrating with Apache Hive
7777

7878
---

api/src/main/java/org/apache/iceberg/types/Conversions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import org.apache.iceberg.exceptions.RuntimeIOException;
3333
import org.apache.iceberg.expressions.Literal;
3434
import org.apache.iceberg.util.UUIDUtil;
35+
import org.apache.iceberg.variants.Variant;
36+
import org.apache.iceberg.variants.VariantMetadata;
37+
import org.apache.iceberg.variants.VariantValue;
3538

3639
public class Conversions {
3740

@@ -117,6 +120,17 @@ public static ByteBuffer toByteBuffer(Type.TypeID typeId, Object value) {
117120
return (ByteBuffer) value;
118121
case DECIMAL:
119122
return ByteBuffer.wrap(((BigDecimal) value).unscaledValue().toByteArray());
123+
case VARIANT:
124+
// Produce a concatenated buffer of metadata and value
125+
Variant variant = (Variant) value;
126+
VariantMetadata variantMetadata = variant.metadata();
127+
VariantValue variantValue = variant.value();
128+
ByteBuffer variantBuffer =
129+
ByteBuffer.allocate(variantMetadata.sizeInBytes() + variantValue.sizeInBytes())
130+
.order(ByteOrder.LITTLE_ENDIAN);
131+
variantMetadata.writeTo(variantBuffer, 0);
132+
variantValue.writeTo(variantBuffer, variantMetadata.sizeInBytes());
133+
return variantBuffer;
120134
default:
121135
throw new UnsupportedOperationException("Cannot serialize type: " + typeId);
122136
}
@@ -177,6 +191,8 @@ private static Object internalFromByteBuffer(Type type, ByteBuffer buffer) {
177191
byte[] unscaledBytes = new byte[buffer.remaining()];
178192
tmp.get(unscaledBytes);
179193
return new BigDecimal(new BigInteger(unscaledBytes), decimal.scale());
194+
case VARIANT:
195+
return Variant.from(tmp);
180196
default:
181197
throw new UnsupportedOperationException("Cannot deserialize type: " + type);
182198
}

baseline.gradle

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ subprojects {
5252
apply plugin: 'com.palantir.baseline-exact-dependencies'
5353
apply plugin: 'com.diffplug.spotless'
5454

55-
pluginManager.withPlugin('com.palantir.baseline-checkstyle') {
56-
checkstyle {
57-
// com.palantir.baseline:gradle-baseline-java:4.42.0 (the last version supporting Java 8) pulls
58-
// in an old version of the checkstyle(9.1), which has this OutOfMemory bug https://github.com/checkstyle/checkstyle/issues/10934.
59-
// So, override its checkstyle version using CheckstyleExtension to 9.3 (the latest java 8 supported version) which contains a fix.
60-
toolVersion '9.3'
61-
}
62-
}
63-
6455
pluginManager.withPlugin('com.diffplug.spotless') {
6556
spotless {
6657
java {
@@ -174,4 +165,22 @@ subprojects {
174165
quiet = false
175166
}
176167
}
168+
169+
pluginManager.withPlugin('scala') {
170+
String scalaVersion = System.getProperty("scalaVersion") != null ? System.getProperty("scalaVersion") : System.getProperty("defaultScalaVersion")
171+
tasks.withType(ScalaCompile).configureEach { scalaCompile ->
172+
if (scalaVersion?.startsWith("2.12")) {
173+
scalaCompile.scalaCompileOptions.additionalParameters = [
174+
// Scala 2.12 does not support treating unused imports as errors individually,
175+
// so we only enable warnings for unused imports when using Scala 2.12.
176+
"-Ywarn-unused:imports",
177+
]
178+
} else if (scalaVersion?.startsWith("2.13")) {
179+
scalaCompile.scalaCompileOptions.additionalParameters = [
180+
"-Wconf:cat=unused:error",
181+
"-Wunused:imports"
182+
]
183+
}
184+
}
185+
}
177186
}

core/src/main/java/org/apache/iceberg/BaseDistributedDataScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private DeleteFileIndex planDeletesLocally(List<ManifestFile> deleteManifests) {
300300
}
301301

302302
return builder
303-
.specsById(table().specs())
303+
.specsById(specs())
304304
.filterData(filter())
305305
.caseSensitive(isCaseSensitive())
306306
.scanMetrics(scanMetrics())

core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected void refreshFromMetadataLocation(
214214
this.shouldRefresh = false;
215215
}
216216

217-
private String metadataFileLocation(TableMetadata metadata, String filename) {
217+
protected String metadataFileLocation(TableMetadata metadata, String filename) {
218218
String metadataLocation = metadata.properties().get(TableProperties.WRITE_METADATA_LOCATION);
219219

220220
if (metadataLocation != null) {

core/src/main/java/org/apache/iceberg/DataScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected ManifestGroup newManifestGroup(
5353
.caseSensitive(isCaseSensitive())
5454
.select(withColumnStats ? SCAN_WITH_STATS_COLUMNS : SCAN_COLUMNS)
5555
.filterData(filter())
56-
.specsById(table().specs())
56+
.specsById(specs())
5757
.scanMetrics(scanMetrics())
5858
.ignoreDeleted()
5959
.columnsToKeepStats(columnsToKeepStats());

core/src/main/java/org/apache/iceberg/DataTableScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public CloseableIterable<FileScanTask> doPlanFiles() {
7474
.caseSensitive(isCaseSensitive())
7575
.select(scanColumns())
7676
.filterData(filter())
77-
.specsById(table().specs())
77+
.specsById(specs())
7878
.scanMetrics(scanMetrics())
7979
.ignoreDeleted()
8080
.columnsToKeepStats(columnsToKeepStats());

core/src/main/java/org/apache/iceberg/MetricsConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public final class MetricsConfig implements Serializable {
5555
private static final MetricsMode DEFAULT_MODE =
5656
MetricsModes.fromString(DEFAULT_WRITE_METRICS_MODE_DEFAULT);
5757
private static final MetricsConfig DEFAULT = new MetricsConfig(ImmutableMap.of(), DEFAULT_MODE);
58+
private static final MetricsConfig POSITION_DELETE_MODE =
59+
new MetricsConfig(
60+
ImmutableMap.of(
61+
MetadataColumns.DELETE_FILE_PATH.name(),
62+
MetricsModes.Full.get(),
63+
MetadataColumns.DELETE_FILE_POS.name(),
64+
MetricsModes.Full.get()),
65+
DEFAULT_MODE);
5866

5967
private final Map<String, MetricsMode> columnModes;
6068
private final MetricsMode defaultMode;
@@ -68,6 +76,10 @@ public static MetricsConfig getDefault() {
6876
return DEFAULT;
6977
}
7078

79+
public static MetricsConfig forPositionDelete() {
80+
return POSITION_DELETE_MODE;
81+
}
82+
7183
/**
7284
* Creates a metrics config from table configuration.
7385
*
@@ -92,7 +104,11 @@ public static MetricsConfig forTable(Table table) {
92104
* Creates a metrics config for a position delete file.
93105
*
94106
* @param table an Iceberg table
107+
* @deprecated This method is deprecated as of version 1.11.0 and will be removed in 1.12.0.
108+
* Position deletes that include row data are no longer supported. Use {@link
109+
* #forPositionDelete()} instead.
95110
*/
111+
@Deprecated
96112
public static MetricsConfig forPositionDelete(Table table) {
97113
ImmutableMap.Builder<String, MetricsMode> columnModes = ImmutableMap.builder();
98114

0 commit comments

Comments
 (0)