You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/12/25 18:28:21 UTC
[GitHub] [hudi] nsivabalan opened a new pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
nsivabalan opened a new pull request #2380:
URL: https://github.com/apache/hudi/pull/2380
## What is the purpose of the pull request
Redo of https://github.com/apache/hudi/pull/1565
## Brief change log
- Added HoodieKafkaAvroDecoder and AbstractHoodieKafkaAvroDeserializer to assist in deserializing kafka avro data.
- Introduced a property for configuring AvroKafkaSource with or without schema-registry setup.
## Verify this pull request
This change added tests and can be verified as follows:
- *Added TestHoodieKafkaAvroDecoder to verify the change.*
## Committer checklist
- [ ] Has a corresponding JIRA in PR title & commit
- [ ] Commit message is descriptive of the change
- [ ] CI is green
- [ ] Necessary doc changes done or have another open PR
- [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] vinothchandar commented on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
vinothchandar commented on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751376686
@afilipchik could you take a pass at this PR this week?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] nsivabalan commented on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
nsivabalan commented on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751280380
@afilipchik @vinothchandar : I have taken a stab at https://github.com/apache/hudi/pull/1565
Basically, AbstractHoodieKafkaAvroDeserializer initializes SchemaProvider based on configs to fetch source scheme and target schema. In other words I have combined https://github.com/apache/hudi/pull/1562 and https://github.com/apache/hudi/pull/1565
If deserialize() is called w/ reader schema, same is used. If not, the one from schema provider is used. In either case, writer schema is fetched from schema provider. In previous patch from Pratyaksh, we were using the passed in schema as both reader and writer schema and hence schema evolution could run into issues.
But AbstractHoodieKafkaAvroDeserializer is inspired from Confluent schema-registry repo. I am not sure how to make this generic(as of now assumes the schema id at the beginning, followed by length and data). I haven't worked w/ schema registries nor w/ kafka/avro before. Will have to do research on what other ways we could deser kafka avro data. But as per Pratyaksh's comment, looks like usage of non schema registry flows are discouraged in general. So, not sure how much value we could add by supporting all diff ways to deser kafka avro data (i.e if not for confluent way).
Let me know your thoughts. I am looking to get this into 0.7.0 (will be cutting a release in a weeks time). So, would appreciate if you can respond whenever you can.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] nsivabalan closed pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
nsivabalan closed pull request #2380:
URL: https://github.com/apache/hudi/pull/2380
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io commented on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751280210
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=h1) Report
> Merging [#2380](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=desc) (0b111c8) into [master](https://codecov.io/gh/apache/hudi/commit/286055ce34bdbbac68c995a2710fc7be07734b12?el=desc) (286055c) will **decrease** coverage by `42.48%`.
> The diff coverage is `0.00%`.
[](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2380 +/- ##
============================================
- Coverage 52.20% 9.71% -42.49%
+ Complexity 2659 48 -2611
============================================
Files 335 55 -280
Lines 14981 1914 -13067
Branches 1505 227 -1278
============================================
- Hits 7821 186 -7635
+ Misses 6535 1715 -4820
+ Partials 625 13 -612
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| hudicli | `?` | `?` | |
| hudiclient | `?` | `?` | |
| hudicommon | `?` | `?` | |
| hudihadoopmr | `?` | `?` | |
| huditimelineservice | `?` | `?` | |
| hudiutilities | `9.71% <0.00%> (-59.94%)` | `0.00 <0.00> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...hudi/utilities/schema/FilebasedSchemaProvider.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NjaGVtYS9GaWxlYmFzZWRTY2hlbWFQcm92aWRlci5qYXZh) | `0.00% <0.00%> (-82.36%)` | `0.00 <0.00> (-5.00)` | |
| [...ies/serde/AbstractHoodieKafkaAvroDeserializer.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0Fic3RyYWN0SG9vZGllS2Fma2FBdnJvRGVzZXJpYWxpemVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/hudi/utilities/serde/HoodieKafkaAvroDecoder.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0hvb2RpZUthZmthQXZyb0RlY29kZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/config/HoodieKafkaAvroDeserializationConfig.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL2NvbmZpZy9Ib29kaWVLYWZrYUF2cm9EZXNlcmlhbGl6YXRpb25Db25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...apache/hudi/utilities/sources/AvroKafkaSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvQXZyb0thZmthU291cmNlLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...va/org/apache/hudi/utilities/IdentitySplitter.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL0lkZW50aXR5U3BsaXR0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-2.00%)` | |
| [...va/org/apache/hudi/utilities/schema/SchemaSet.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NjaGVtYS9TY2hlbWFTZXQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-3.00%)` | |
| [...a/org/apache/hudi/utilities/sources/RowSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvUm93U291cmNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-4.00%)` | |
| [.../org/apache/hudi/utilities/sources/AvroSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvQXZyb1NvdXJjZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [.../org/apache/hudi/utilities/sources/JsonSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvSnNvblNvdXJjZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| ... and [320 more](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree-more) | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751280210
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=h1) Report
> Merging [#2380](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=desc) (0b111c8) into [master](https://codecov.io/gh/apache/hudi/commit/286055ce34bdbbac68c995a2710fc7be07734b12?el=desc) (286055c) will **decrease** coverage by `42.48%`.
> The diff coverage is `0.00%`.
[](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2380 +/- ##
============================================
- Coverage 52.20% 9.71% -42.49%
+ Complexity 2659 48 -2611
============================================
Files 335 55 -280
Lines 14981 1914 -13067
Branches 1505 227 -1278
============================================
- Hits 7821 186 -7635
+ Misses 6535 1715 -4820
+ Partials 625 13 -612
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| hudicli | `?` | `?` | |
| hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| hudicommon | `?` | `?` | |
| hudihadoopmr | `?` | `?` | |
| huditimelineservice | `?` | `?` | |
| hudiutilities | `9.71% <0.00%> (-59.94%)` | `0.00 <0.00> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...hudi/utilities/schema/FilebasedSchemaProvider.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NjaGVtYS9GaWxlYmFzZWRTY2hlbWFQcm92aWRlci5qYXZh) | `0.00% <0.00%> (-82.36%)` | `0.00 <0.00> (-5.00)` | |
| [...ies/serde/AbstractHoodieKafkaAvroDeserializer.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0Fic3RyYWN0SG9vZGllS2Fma2FBdnJvRGVzZXJpYWxpemVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/hudi/utilities/serde/HoodieKafkaAvroDecoder.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0hvb2RpZUthZmthQXZyb0RlY29kZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/config/HoodieKafkaAvroDeserializationConfig.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL2NvbmZpZy9Ib29kaWVLYWZrYUF2cm9EZXNlcmlhbGl6YXRpb25Db25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...apache/hudi/utilities/sources/AvroKafkaSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvQXZyb0thZmthU291cmNlLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...va/org/apache/hudi/utilities/IdentitySplitter.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL0lkZW50aXR5U3BsaXR0ZXIuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-2.00%)` | |
| [...va/org/apache/hudi/utilities/schema/SchemaSet.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NjaGVtYS9TY2hlbWFTZXQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-3.00%)` | |
| [...a/org/apache/hudi/utilities/sources/RowSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvUm93U291cmNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-4.00%)` | |
| [.../org/apache/hudi/utilities/sources/AvroSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvQXZyb1NvdXJjZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [.../org/apache/hudi/utilities/sources/JsonSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvSnNvblNvdXJjZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| ... and [320 more](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree-more) | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] nsivabalan commented on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
nsivabalan commented on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-788908371
Closing this in favor of https://github.com/apache/hudi/pull/2598/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] afilipchik commented on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
afilipchik commented on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-754744538
On making AbstractHoodieKafkaAvroDeserializer abstract - it looks like modified Confluent deserializer, so it believe it should be called like that. If we want to support Confluent schema registry we need to use schema id to acquire writer's schema, otherwise schema evolutions will be a pain.
I.E. to deserialize an avro message we need 2 things: schema it was written with (can come from properties, but with Confluent id in the beginning of the message tells you exact version and can be used to fetch it from the schema registry) and the reader schema (schema on the reader side which comes from the schema provider)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] afilipchik commented on a change in pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
afilipchik commented on a change in pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#discussion_r552037619
##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/serde/AbstractHoodieKafkaAvroDeserializer.java
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.serde;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.utilities.UtilHelpers;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig;
+
+import kafka.utils.VerifiableProperties;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.kafka.common.errors.SerializationException;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig.SCHEMA_PROVIDER_CLASS_PROP;
+
+public class AbstractHoodieKafkaAvroDeserializer {
+
+ private final DecoderFactory decoderFactory = DecoderFactory.get();
+ private boolean useSpecificAvroReader = false;
+ private Schema sourceSchema;
+ private Schema targetSchema;
+
+ public AbstractHoodieKafkaAvroDeserializer(VerifiableProperties properties) {
+ // this.sourceSchema = new Schema.Parser().parse(properties.props().getProperty(FilebasedSchemaProvider.Config.SOURCE_SCHEMA_PROP));
+ TypedProperties typedProperties = new TypedProperties();
+ copyProperties(typedProperties, properties.props());
+ try {
+ SchemaProvider schemaProvider = UtilHelpers.createSchemaProvider(
+ typedProperties.getString(SCHEMA_PROVIDER_CLASS_PROP), typedProperties, null);
+ this.sourceSchema = Objects.requireNonNull(schemaProvider).getSourceSchema();
+ this.targetSchema = Objects.requireNonNull(schemaProvider).getTargetSchema();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void copyProperties(TypedProperties typedProperties, Properties properties) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ typedProperties.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ protected void configure(HoodieKafkaAvroDeserializationConfig config) {
+ useSpecificAvroReader = config
+ .getBoolean(HoodieKafkaAvroDeserializationConfig.SPECIFIC_AVRO_READER_CONFIG);
+ }
+
+ protected Object deserialize(byte[] payload) throws SerializationException {
+ return deserialize(null, null, payload, targetSchema);
+ }
+
+ /**
+ * Just like single-parameter version but accepts an Avro schema to use for reading.
+ *
+ * @param payload serialized data
+ * @param readerSchema schema to use for Avro read (optional, enables Avro projection)
+ * @return the deserialized object
+ */
+ protected Object deserialize(byte[] payload, Schema readerSchema) throws SerializationException {
+ return deserialize(null, null, payload, readerSchema);
+ }
+
+ protected Object deserialize(String topic, Boolean isKey, byte[] payload, Schema readerSchema) {
Review comment:
It should be coming from the configured schema provider.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751280210
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=h1) Report
> Merging [#2380](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=desc) (0b111c8) into [master](https://codecov.io/gh/apache/hudi/commit/286055ce34bdbbac68c995a2710fc7be07734b12?el=desc) (286055c) will **decrease** coverage by `0.18%`.
> The diff coverage is `1.58%`.
[](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2380 +/- ##
============================================
- Coverage 52.20% 52.01% -0.19%
- Complexity 2659 2660 +1
============================================
Files 335 338 +3
Lines 14981 15043 +62
Branches 1505 1509 +4
============================================
+ Hits 7821 7825 +4
- Misses 6535 6593 +58
Partials 625 625
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| hudicli | `38.83% <ø> (ø)` | `0.00 <ø> (ø)` | |
| hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| hudicommon | `54.80% <ø> (+0.03%)` | `0.00 <ø> (ø)` | |
| hudihadoopmr | `33.29% <ø> (ø)` | `0.00 <ø> (ø)` | |
| huditimelineservice | `65.30% <ø> (ø)` | `0.00 <ø> (ø)` | |
| hudiutilities | `67.45% <1.58%> (-2.21%)` | `0.00 <0.00> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2380?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...ies/serde/AbstractHoodieKafkaAvroDeserializer.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0Fic3RyYWN0SG9vZGllS2Fma2FBdnJvRGVzZXJpYWxpemVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/hudi/utilities/serde/HoodieKafkaAvroDecoder.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL0hvb2RpZUthZmthQXZyb0RlY29kZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/config/HoodieKafkaAvroDeserializationConfig.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NlcmRlL2NvbmZpZy9Ib29kaWVLYWZrYUF2cm9EZXNlcmlhbGl6YXRpb25Db25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...apache/hudi/utilities/sources/AvroKafkaSource.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NvdXJjZXMvQXZyb0thZmthU291cmNlLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...hudi/utilities/schema/FilebasedSchemaProvider.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS11dGlsaXRpZXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvdXRpbGl0aWVzL3NjaGVtYS9GaWxlYmFzZWRTY2hlbWFQcm92aWRlci5qYXZh) | `83.33% <100.00%> (+0.98%)` | `5.00 <0.00> (ø)` | |
| [...ache/hudi/common/fs/inline/InMemoryFileSystem.java](https://codecov.io/gh/apache/hudi/pull/2380/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL2ZzL2lubGluZS9Jbk1lbW9yeUZpbGVTeXN0ZW0uamF2YQ==) | `89.65% <0.00%> (+10.34%)` | `16.00% <0.00%> (+1.00%)` | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] nsivabalan edited a comment on pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
nsivabalan edited a comment on pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#issuecomment-751280380
@afilipchik @vinothchandar : I have taken a stab at https://github.com/apache/hudi/pull/1565. I did not have permission to update Pratyaksh's repo, hence created a new one.
Basically, AbstractHoodieKafkaAvroDeserializer initializes SchemaProvider based on configs to fetch source scheme and target schema. In other words I have combined https://github.com/apache/hudi/pull/1562 and https://github.com/apache/hudi/pull/1565
If deserialize() is called w/ reader schema, same is used. If not, the one from schema provider is used. In either case, writer schema is fetched from schema provider. In previous patch from Pratyaksh, we were using the passed in schema as both reader and writer schema and hence schema evolution could run into issues.
But AbstractHoodieKafkaAvroDeserializer is inspired from Confluent schema-registry repo. I am not sure how to make this generic(as of now assumes the schema id at the beginning, followed by length and data). I haven't worked w/ schema registries nor w/ kafka/avro before. Will have to do research on what other ways we could deser kafka avro data. But as per Pratyaksh's comment, looks like usage of non schema registry flows are discouraged in general. So, not sure how much value we could add by supporting all diff ways to deser kafka avro data (i.e if not for confluent way).
Let me know your thoughts. I am looking to get this into 0.7.0 (will be cutting a release in a weeks time). So, would appreciate if you can respond whenever you can.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] vburenin commented on a change in pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
vburenin commented on a change in pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#discussion_r551397436
##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/serde/AbstractHoodieKafkaAvroDeserializer.java
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.serde;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.utilities.UtilHelpers;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig;
+
+import kafka.utils.VerifiableProperties;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.kafka.common.errors.SerializationException;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig.SCHEMA_PROVIDER_CLASS_PROP;
+
+public class AbstractHoodieKafkaAvroDeserializer {
+
+ private final DecoderFactory decoderFactory = DecoderFactory.get();
+ private boolean useSpecificAvroReader = false;
+ private Schema sourceSchema;
+ private Schema targetSchema;
+
+ public AbstractHoodieKafkaAvroDeserializer(VerifiableProperties properties) {
+ // this.sourceSchema = new Schema.Parser().parse(properties.props().getProperty(FilebasedSchemaProvider.Config.SOURCE_SCHEMA_PROP));
+ TypedProperties typedProperties = new TypedProperties();
+ copyProperties(typedProperties, properties.props());
+ try {
+ SchemaProvider schemaProvider = UtilHelpers.createSchemaProvider(
+ typedProperties.getString(SCHEMA_PROVIDER_CLASS_PROP), typedProperties, null);
+ this.sourceSchema = Objects.requireNonNull(schemaProvider).getSourceSchema();
+ this.targetSchema = Objects.requireNonNull(schemaProvider).getTargetSchema();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void copyProperties(TypedProperties typedProperties, Properties properties) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ typedProperties.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ protected void configure(HoodieKafkaAvroDeserializationConfig config) {
+ useSpecificAvroReader = config
+ .getBoolean(HoodieKafkaAvroDeserializationConfig.SPECIFIC_AVRO_READER_CONFIG);
+ }
+
+ protected Object deserialize(byte[] payload) throws SerializationException {
+ return deserialize(null, null, payload, targetSchema);
+ }
+
+ /**
+ * Just like single-parameter version but accepts an Avro schema to use for reading.
+ *
+ * @param payload serialized data
+ * @param readerSchema schema to use for Avro read (optional, enables Avro projection)
+ * @return the deserialized object
+ */
+ protected Object deserialize(byte[] payload, Schema readerSchema) throws SerializationException {
+ return deserialize(null, null, payload, readerSchema);
+ }
+
+ protected Object deserialize(String topic, Boolean isKey, byte[] payload, Schema readerSchema) {
Review comment:
Original AbstractKafkaAvroDeserializer decoder has a check
```
if (payload == null) {
return null;
}
```
Is removal of this check safe?
##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/AvroKafkaSource.java
##########
@@ -45,15 +50,21 @@
private static final Logger LOG = LogManager.getLogger(AvroKafkaSource.class);
private final KafkaOffsetGen offsetGen;
-
private final HoodieDeltaStreamerMetrics metrics;
+ private final String useSchemaRegistry = "hoodie.deltastreamer.source.avro.serde.useSchemaRegistry";
public AvroKafkaSource(TypedProperties props, JavaSparkContext sparkContext, SparkSession sparkSession,
SchemaProvider schemaProvider, HoodieDeltaStreamerMetrics metrics) {
super(props, sparkContext, sparkSession, schemaProvider);
this.metrics = metrics;
+ boolean useSchemaRegistryForDeserialization = props.getBoolean(useSchemaRegistry, true);
props.put("key.deserializer", StringDeserializer.class);
- props.put("value.deserializer", KafkaAvroDeserializer.class);
+ if (useSchemaRegistryForDeserialization) {
+ props.put("value.deserializer", KafkaAvroDeserializer.class);
+ } else {
+ DataSourceUtils.checkRequiredProperties(props, Collections.singletonList(FilebasedSchemaProvider.Config.SOURCE_SCHEMA_FILE_PROP));
+ props.put("value.deserializer", HoodieKafkaAvroDecoder.class);
Review comment:
Would be nice to have an ability to configure which decoder class is to use for value.deserializer to be able to handle internal data decodings specifics.
##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/serde/AbstractHoodieKafkaAvroDeserializer.java
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.serde;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.utilities.UtilHelpers;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig;
+
+import kafka.utils.VerifiableProperties;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.kafka.common.errors.SerializationException;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig.SCHEMA_PROVIDER_CLASS_PROP;
+
+public class AbstractHoodieKafkaAvroDeserializer {
+
+ private final DecoderFactory decoderFactory = DecoderFactory.get();
+ private boolean useSpecificAvroReader = false;
+ private Schema sourceSchema;
+ private Schema targetSchema;
+
+ public AbstractHoodieKafkaAvroDeserializer(VerifiableProperties properties) {
+ // this.sourceSchema = new Schema.Parser().parse(properties.props().getProperty(FilebasedSchemaProvider.Config.SOURCE_SCHEMA_PROP));
+ TypedProperties typedProperties = new TypedProperties();
+ copyProperties(typedProperties, properties.props());
+ try {
+ SchemaProvider schemaProvider = UtilHelpers.createSchemaProvider(
+ typedProperties.getString(SCHEMA_PROVIDER_CLASS_PROP), typedProperties, null);
+ this.sourceSchema = Objects.requireNonNull(schemaProvider).getSourceSchema();
+ this.targetSchema = Objects.requireNonNull(schemaProvider).getTargetSchema();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void copyProperties(TypedProperties typedProperties, Properties properties) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ typedProperties.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ protected void configure(HoodieKafkaAvroDeserializationConfig config) {
+ useSpecificAvroReader = config
+ .getBoolean(HoodieKafkaAvroDeserializationConfig.SPECIFIC_AVRO_READER_CONFIG);
+ }
+
+ protected Object deserialize(byte[] payload) throws SerializationException {
+ return deserialize(null, null, payload, targetSchema);
+ }
+
+ /**
+ * Just like single-parameter version but accepts an Avro schema to use for reading.
+ *
+ * @param payload serialized data
+ * @param readerSchema schema to use for Avro read (optional, enables Avro projection)
+ * @return the deserialized object
+ */
+ protected Object deserialize(byte[] payload, Schema readerSchema) throws SerializationException {
+ return deserialize(null, null, payload, readerSchema);
+ }
+
+ protected Object deserialize(String topic, Boolean isKey, byte[] payload, Schema readerSchema) {
Review comment:
Do you know where readerSchema come from?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] afilipchik commented on a change in pull request #2380: [Hudi 73] Adding support for vanilla AvroKafkaSource
Posted by GitBox <gi...@apache.org>.
afilipchik commented on a change in pull request #2380:
URL: https://github.com/apache/hudi/pull/2380#discussion_r552040233
##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/serde/AbstractHoodieKafkaAvroDeserializer.java
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.serde;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.utilities.UtilHelpers;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig;
+
+import kafka.utils.VerifiableProperties;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.kafka.common.errors.SerializationException;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.utilities.serde.config.HoodieKafkaAvroDeserializationConfig.SCHEMA_PROVIDER_CLASS_PROP;
+
+public class AbstractHoodieKafkaAvroDeserializer {
+
+ private final DecoderFactory decoderFactory = DecoderFactory.get();
+ private boolean useSpecificAvroReader = false;
+ private Schema sourceSchema;
+ private Schema targetSchema;
+
+ public AbstractHoodieKafkaAvroDeserializer(VerifiableProperties properties) {
+ // this.sourceSchema = new Schema.Parser().parse(properties.props().getProperty(FilebasedSchemaProvider.Config.SOURCE_SCHEMA_PROP));
+ TypedProperties typedProperties = new TypedProperties();
+ copyProperties(typedProperties, properties.props());
+ try {
+ SchemaProvider schemaProvider = UtilHelpers.createSchemaProvider(
+ typedProperties.getString(SCHEMA_PROVIDER_CLASS_PROP), typedProperties, null);
+ this.sourceSchema = Objects.requireNonNull(schemaProvider).getSourceSchema();
+ this.targetSchema = Objects.requireNonNull(schemaProvider).getTargetSchema();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void copyProperties(TypedProperties typedProperties, Properties properties) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ typedProperties.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ protected void configure(HoodieKafkaAvroDeserializationConfig config) {
+ useSpecificAvroReader = config
+ .getBoolean(HoodieKafkaAvroDeserializationConfig.SPECIFIC_AVRO_READER_CONFIG);
+ }
+
+ protected Object deserialize(byte[] payload) throws SerializationException {
+ return deserialize(null, null, payload, targetSchema);
+ }
+
+ /**
+ * Just like single-parameter version but accepts an Avro schema to use for reading.
+ *
+ * @param payload serialized data
+ * @param readerSchema schema to use for Avro read (optional, enables Avro projection)
+ * @return the deserialized object
+ */
+ protected Object deserialize(byte[] payload, Schema readerSchema) throws SerializationException {
+ return deserialize(null, null, payload, readerSchema);
+ }
+
+ protected Object deserialize(String topic, Boolean isKey, byte[] payload, Schema readerSchema) {
+ try {
+ ByteBuffer buffer = this.getByteBuffer(payload);
+ int id = buffer.getInt();
Review comment:
this assumes the message starts with schema version (code looks like from Confluent deserializer). It doesn't belong to AbstractHoodieKafkaAvroDeserializer.java
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org