Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update confluent dependency version to 7.6.0 #30638

Merged
merged 8 commits into from
Mar 19, 2024
4 changes: 2 additions & 2 deletions .github/trigger_files/beam_PostCommit_Java_Avro_Versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run"
}
"comment": "Modify this file in a trivial way to cause this test suite to run"
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14")

runtimeOnly("com.google.protobuf:protobuf-gradle-plugin:0.8.13") // Enable proto code generation
runtimeOnly("com.github.davidmc24.gradle-avro-plugin:gradle-avro-plugin:0.16.0") // Enable Avro code generation
Abacn marked this conversation as resolved.
Show resolved Hide resolved
runtimeOnly("com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1") // Enable Avro code generation
runtimeOnly("com.diffplug.spotless:spotless-plugin-gradle:5.6.1") // Enable a code formatting plugin
runtimeOnly("gradle.plugin.com.dorongold.plugins:task-tree:1.5") // Adds a 'taskTree' task to print task dependency tree
runtimeOnly("gradle.plugin.com.github.johnrengelman:shadow:7.1.1") // Enable shading Java dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ class BeamModulePlugin implements Plugin<Project> {
antlr_runtime : "org.antlr:antlr4-runtime:4.7",
args4j : "args4j:args4j:2.33",
auto_value_annotations : "com.google.auto.value:auto-value-annotations:$autovalue_version",
avro : "org.apache.avro:avro:1.8.2",
avro_tests : "org.apache.avro:avro:1.8.2:tests",
avro : "org.apache.avro:avro:1.11.3",
avro_tests : "org.apache.avro:avro:1.11.3:tests",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember there was issue upgrading avro version and that was why it sticked to 1.8.2 for a long time. Might be good to ask in devlist about this proposal

aws_java_sdk_cloudwatch : "com.amazonaws:aws-java-sdk-cloudwatch:$aws_java_sdk_version",
aws_java_sdk_core : "com.amazonaws:aws-java-sdk-core:$aws_java_sdk_version",
aws_java_sdk_dynamodb : "com.amazonaws:aws-java-sdk-dynamodb:$aws_java_sdk_version",
Expand Down Expand Up @@ -2448,7 +2448,7 @@ class BeamModulePlugin implements Plugin<Project> {
// TODO: Decide whether this should be inlined into the one project that relies on it
// or be left here.
project.ext.applyAvroNature = {
project.apply plugin: "com.commercehub.gradle.plugin.avro"
project.apply plugin: "com.github.davidmc24.gradle.plugin.avro"

// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
Expand Down
1 change: 1 addition & 0 deletions sdks/java/extensions/avro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
}
testImplementation library.java.avro_tests
testImplementation library.java.junit
testImplementation "org.tukaani:xz:1.9" // marked as optional in avro
Abacn marked this conversation as resolved.
Show resolved Hide resolved
testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow")
testRuntimeOnly library.java.slf4j_jdk14
avroVersions.each { k,v ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public static SimpleFunction<Row, byte[]> getRowToAvroBytesFunction(Schema beamS
}

private static class RowToAvroBytesFn extends SimpleFunction<Row, byte[]> {
private final transient org.apache.avro.Schema avroSchema;
private final org.apache.avro.Schema avroSchema;
Abacn marked this conversation as resolved.
Show resolved Hide resolved
private final AvroCoder<GenericRecord> coder;

RowToAvroBytesFn(Schema beamSchema) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ private static TableFieldSchema fieldDescriptorFromAvroField(Schema.Field field)
elementType.getType() != Schema.Type.UNION,
"Multiple non-null union types are not supported.");
TableFieldSchema unionFieldSchema =
fieldDescriptorFromAvroField(
new Schema.Field(field.name(), elementType, field.doc(), field.defaultVal()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why defaultVal dropped here?

Copy link
Contributor Author

@tilgalas tilgalas Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the elementType here will be a schema of the union, but with the null type filtered out - in the "extreme" case of an "optionable" union type of [null, SomeSchema] it won't even be a union anymore, just the bare SomeSchema - if the defaultVal is null, it will not correspond to this derived schema anymore, and Avro will throw an exception when constructing the Field object - I'm not sure why this wasn't a problem before (maybe Avro didn't actually check this?)

fieldDescriptorFromAvroField(new Schema.Field(field.name(), elementType, field.doc()));
builder =
builder
.setType(unionFieldSchema.getType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void testGcpApiSurface() throws Exception {
classesInPackage("javax"),
classesInPackage("org.apache.avro"),
classesInPackage("org.apache.beam"),
classesInPackage("org.codehaus.jackson"),
classesInPackage("org.joda.time"),
classesInPackage("org.threeten.bp"),
classesInPackage("com.google.gson"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ enum TestEnum {
.set(
"decimalValue",
new Conversions.DecimalConversion()
.toBytes(bd, Schema.create(Schema.Type.NULL), LogicalTypes.decimal(1, 1)))
.toBytes(
bd,
Schema.create(Schema.Type.NULL),
LogicalTypes.decimal(bd.precision(), bd.scale())))
.set("dateValue", now)
.set("timestampMicrosValue", now.getMillis() * 1000)
.set("timestampMicrosAsInstantValue", now)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testConvertGenericRecordToTableRow() throws Exception {
}
// After a Field is added to a Schema, it is assigned a position, so we can't simply reuse
// the existing Field.
avroFields.add(new Schema.Field(field.name(), schema, field.doc(), field.defaultValue()));
avroFields.add(new Schema.Field(field.name(), schema, field.doc(), field.defaultVal()));
}
Schema avroSchema = Schema.createRecord(avroFields);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void fromPubsubSchema() {

assertThrows(
"null definition should throw an exception",
NullPointerException.class,
SchemaParseException.class,
() ->
PubsubClient.fromPubsubSchema(
com.google.pubsub.v1.Schema.newBuilder().setType(Schema.Type.AVRO).build()));
Expand Down
9 changes: 6 additions & 3 deletions sdks/java/io/kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ provideIntegrationTestingDependencies()
enableJavaPerformanceTesting()

description = "Apache Beam :: SDKs :: Java :: IO :: Kafka"
ext.summary = "Library to read Kafka topics."
ext {
summary = "Library to read Kafka topics."
confluentVersion = "7.6.0"
}

def kafkaVersions = [
'01103': "0.11.0.3",
Expand Down Expand Up @@ -68,14 +71,14 @@ dependencies {
implementation library.java.jackson_annotations
implementation library.java.jackson_databind
implementation "org.springframework:spring-expression:5.3.27"
implementation ("io.confluent:kafka-avro-serializer:5.3.2") {
implementation ("io.confluent:kafka-avro-serializer:${confluentVersion}") {
// zookeeper depends on "spotbugs-annotations:3.1.9" which clashes with current
// "spotbugs-annotations:3.1.12" used in Beam. Not required.
exclude group: "org.apache.zookeeper", module: "zookeeper"
// "kafka-clients" has to be provided since user can use its own version.
exclude group: "org.apache.kafka", module: "kafka-clients"
}
implementation ("io.confluent:kafka-schema-registry-client:5.3.2") {
implementation ("io.confluent:kafka-schema-registry-client:${confluentVersion}") {
// It depends on "spotbugs-annotations:3.1.9" which clashes with current
// "spotbugs-annotations:3.1.12" used in Beam. Not required.
exclude group: "org.apache.zookeeper", module: "zookeeper"
Expand Down