-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-4418] Add support for ProtoKafkaSource #6135
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
Merged
codope
merged 24 commits into
apache:master
from
the-other-tim-brown:HUDI-4418-proto-kafka-source
Sep 1, 2022
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f63696c
Add support for ProtoKafkaSource
the-other-tim-brown ec6177e
update comments and names
the-other-tim-brown d4d4d72
try bumping avro in profiles
the-other-tim-brown 376eedd
try bumping parquet-avro version
the-other-tim-brown 03f2c7a
don't rely directly on newer avro APIs
the-other-tim-brown 51bbad4
simplify code
the-other-tim-brown d36fed6
remove unused dependency
the-other-tim-brown ffc9419
remove duplicate dependency
the-other-tim-brown 10eb307
add in KafkaSource as abstract class to better share code
the-other-tim-brown a9adc8d
fix compile issues
the-other-tim-brown 5475f67
DRY up testing, prevent TestJsonKafkaSourcePostProcessor from running…
the-other-tim-brown b9c9118
fix style issues
the-other-tim-brown 14115a6
update handling of unsigned ints
the-other-tim-brown 1879403
Merge remote-tracking branch 'upstream/master' into HUDI-4418-proto-k…
the-other-tim-brown f70abbc
remove guava transitive dependency from proto-java-util
the-other-tim-brown 1943960
fix handling of unsigned integer fields in conversion to avro
the-other-tim-brown 9a4df85
Merge remote-tracking branch 'upstream/master' into HUDI-4418-proto-k…
the-other-tim-brown 794ed48
Merge remote-tracking branch 'upstream/master' into HUDI-4418-proto-k…
the-other-tim-brown 1f268aa
move configs into the parent pom, use singleton list, remove unused l…
the-other-tim-brown e6e1a68
move shared constants into the KafkaSource, address issue with untype…
the-other-tim-brown 75bd5b0
add comments to describe caches
the-other-tim-brown 95a7f4a
add casting back in
the-other-tim-brown fc344fa
fix execution configuration for protoc plugin
the-other-tim-brown 55997e7
simplify namespace to use proto package
the-other-tim-brown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...ilities/src/main/java/org/apache/hudi/utilities/schema/ProtoClassBasedSchemaProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package org.apache.hudi.utilities.schema; | ||
|
|
||
| import org.apache.hudi.DataSourceUtils; | ||
| import org.apache.hudi.common.config.TypedProperties; | ||
| import org.apache.hudi.common.util.ReflectionUtils; | ||
| import org.apache.hudi.exception.HoodieException; | ||
| import org.apache.hudi.utilities.sources.helpers.ProtoConversionUtil; | ||
|
|
||
| import org.apache.avro.Schema; | ||
| import org.apache.spark.api.java.JavaSparkContext; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| /** | ||
| * A schema provider that takes in a class name for a generated protobuf class that is on the classpath. | ||
| */ | ||
| public class ProtoClassBasedSchemaProvider extends SchemaProvider { | ||
| /** | ||
| * Configs supported. | ||
| */ | ||
| public static class Config { | ||
| public static final String PROTO_SCHEMA_CLASS_NAME = "hoodie.deltastreamer.schemaprovider.proto.className"; | ||
| public static final String PROTO_SCHEMA_FLATTEN_WRAPPED_PRIMITIVES = "hoodie.deltastreamer.schemaprovider.proto.flattenWrappers"; | ||
| } | ||
|
|
||
| private final String schemaString; | ||
|
|
||
| /** | ||
| * To be lazily inited on executors. | ||
| */ | ||
| private transient Schema schema; | ||
|
|
||
| public ProtoClassBasedSchemaProvider(TypedProperties props, JavaSparkContext jssc) { | ||
| super(props, jssc); | ||
| DataSourceUtils.checkRequiredProperties(props, Collections.singletonList( | ||
| Config.PROTO_SCHEMA_CLASS_NAME)); | ||
| String className = config.getString(Config.PROTO_SCHEMA_CLASS_NAME); | ||
| boolean flattenWrappedPrimitives = props.getBoolean(ProtoClassBasedSchemaProvider.Config.PROTO_SCHEMA_FLATTEN_WRAPPED_PRIMITIVES, false); | ||
| try { | ||
| schemaString = ProtoConversionUtil.getAvroSchemaForMessageClass(ReflectionUtils.getClass(className), flattenWrappedPrimitives).toString(); | ||
| } catch (Exception e) { | ||
| throw new HoodieException(String.format("Error reading proto source schema for class: %s", className), e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Schema getSourceSchema() { | ||
| if (schema == null) { | ||
| Schema.Parser parser = new Schema.Parser(); | ||
| schema = parser.parse(schemaString); | ||
| } | ||
| return schema; | ||
| } | ||
|
|
||
| @Override | ||
| public Schema getTargetSchema() { | ||
| return getSourceSchema(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.