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

[Issue #10427] Add AvroSchema UUID support fix #10428

Merged
merged 4 commits into from
Jul 13, 2021

Conversation

vroyer
Copy link
Contributor

@vroyer vroyer commented Apr 28, 2021

Fixes #10427

Motivation

As AVRO support the UUID type (see AVRO spec), add UUID support for the pulsar AvroSchema.

It also adds the AVRO Decimal logical type (see AVRO spec).

Modifications

Add the logical type conversion to the ReflectData instance when parsing the provided POJO.

Verifying this change

See the provided unit test in pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/AvroSchemaTest.java

@vroyer vroyer force-pushed the fix/avro_schema_uuid branch 2 times, most recently from b5ec4f4 to fbe13be Compare April 28, 2021 22:31
@vroyer
Copy link
Contributor Author

vroyer commented Apr 30, 2021 via email

@vroyer vroyer force-pushed the fix/avro_schema_uuid branch 2 times, most recently from caa75c1 to f61e75b Compare May 3, 2021 14:01
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

@sijie I believe that now the patch is really good to go.

please take another look when you have time

@eolivelli
Copy link
Contributor

@sijie I believe that now the patch is really good to go.

please take another look when you have time

@eolivelli eolivelli requested a review from sijie July 8, 2021 20:42
@sijie sijie added this to the 2.9.0 milestone Jul 12, 2021
@eolivelli eolivelli merged commit 8501345 into apache:master Jul 13, 2021
eolivelli pushed a commit that referenced this pull request Jul 13, 2021
@eolivelli eolivelli added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jul 13, 2021
@nodece nodece mentioned this pull request Jan 29, 2022
2 tasks
hangc0276 pushed a commit that referenced this pull request Jan 29, 2022
### Motivation

I can use Avro schema with BigDecimal in Pulsar 2.8.0, but this doesn't work on Pulsar 2.8.1, so I check this codebase and PR, found #10428 breaks this.

The following is error log:
```
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.4.jar:5.3.4]
	... 34 common frames omitted
Caused by: java.lang.UnsupportedOperationException: No recommended schema for decimal (scale is required)
	at org.apache.pulsar.shade.org.apache.avro.Conversions$DecimalConversion.getRecommendedSchema(Conversions.java:73) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:696) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:873) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData$AllowNull.createFieldSchema(ReflectData.java:92) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:736) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:328) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:325) ~[pulsar-client-2.8.1.jar:2.8.1]
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228) ~[na:na]
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210) ~[na:na]
	at java.base/java.lang.ClassValue.get(ClassValue.java:116) ~[na:na]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:339) ~[pulsar-client-2.8.1.jar:2.8.1]
	... 52 common frames omitted
```

I think that Avro cannot work on using the ReflectData with Conversions.DecimalConversion to parse the BigDecimal field without AvroSchema when getting schema, but the Avro ReflectDatumWriter and ReflectDatumReader are working, it seems that Avro support for BigDecimal is not enough.

Affected version: 2.8.1...2.8.x, 2.9.x

### Modifications

- Skip add the DecimalConversion in `extractAvroSchema()`
codelipenghui pushed a commit that referenced this pull request Jan 30, 2022
### Motivation

I can use Avro schema with BigDecimal in Pulsar 2.8.0, but this doesn't work on Pulsar 2.8.1, so I check this codebase and PR, found #10428 breaks this.

The following is error log:
```
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.4.jar:5.3.4]
	... 34 common frames omitted
Caused by: java.lang.UnsupportedOperationException: No recommended schema for decimal (scale is required)
	at org.apache.pulsar.shade.org.apache.avro.Conversions$DecimalConversion.getRecommendedSchema(Conversions.java:73) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:696) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:873) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData$AllowNull.createFieldSchema(ReflectData.java:92) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:736) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:328) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:325) ~[pulsar-client-2.8.1.jar:2.8.1]
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228) ~[na:na]
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210) ~[na:na]
	at java.base/java.lang.ClassValue.get(ClassValue.java:116) ~[na:na]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:339) ~[pulsar-client-2.8.1.jar:2.8.1]
	... 52 common frames omitted
```

I think that Avro cannot work on using the ReflectData with Conversions.DecimalConversion to parse the BigDecimal field without AvroSchema when getting schema, but the Avro ReflectDatumWriter and ReflectDatumReader are working, it seems that Avro support for BigDecimal is not enough.

Affected version: 2.8.1...2.8.x, 2.9.x

### Modifications

- Skip add the DecimalConversion in `extractAvroSchema()`

(cherry picked from commit 2ca8e8a)
zymap pushed a commit that referenced this pull request Jan 30, 2022
### Motivation

I can use Avro schema with BigDecimal in Pulsar 2.8.0, but this doesn't work on Pulsar 2.8.1, so I check this codebase and PR, found #10428 breaks this.

The following is error log:
```
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.4.jar:5.3.4]
	... 34 common frames omitted
Caused by: java.lang.UnsupportedOperationException: No recommended schema for decimal (scale is required)
	at org.apache.pulsar.shade.org.apache.avro.Conversions$DecimalConversion.getRecommendedSchema(Conversions.java:73) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:696) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:873) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData$AllowNull.createFieldSchema(ReflectData.java:92) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:736) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:328) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:325) ~[pulsar-client-2.8.1.jar:2.8.1]
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228) ~[na:na]
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210) ~[na:na]
	at java.base/java.lang.ClassValue.get(ClassValue.java:116) ~[na:na]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:339) ~[pulsar-client-2.8.1.jar:2.8.1]
	... 52 common frames omitted
```

I think that Avro cannot work on using the ReflectData with Conversions.DecimalConversion to parse the BigDecimal field without AvroSchema when getting schema, but the Avro ReflectDatumWriter and ReflectDatumReader are working, it seems that Avro support for BigDecimal is not enough.

Affected version: 2.8.1...2.8.x, 2.9.x

### Modifications

- Skip add the DecimalConversion in `extractAvroSchema()`

(cherry picked from commit 2ca8e8a)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
### Motivation

I can use Avro schema with BigDecimal in Pulsar 2.8.0, but this doesn't work on Pulsar 2.8.1, so I check this codebase and PR, found apache#10428 breaks this.

The following is error log:
```
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.4.jar:5.3.4]
	... 34 common frames omitted
Caused by: java.lang.UnsupportedOperationException: No recommended schema for decimal (scale is required)
	at org.apache.pulsar.shade.org.apache.avro.Conversions$DecimalConversion.getRecommendedSchema(Conversions.java:73) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:696) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:873) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData$AllowNull.createFieldSchema(ReflectData.java:92) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:736) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:328) ~[pulsar-client-2.8.1.jar:2.8.1]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:325) ~[pulsar-client-2.8.1.jar:2.8.1]
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228) ~[na:na]
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210) ~[na:na]
	at java.base/java.lang.ClassValue.get(ClassValue.java:116) ~[na:na]
	at org.apache.pulsar.shade.org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:339) ~[pulsar-client-2.8.1.jar:2.8.1]
	... 52 common frames omitted
```

I think that Avro cannot work on using the ReflectData with Conversions.DecimalConversion to parse the BigDecimal field without AvroSchema when getting schema, but the Avro ReflectDatumWriter and ReflectDatumReader are working, it seems that Avro support for BigDecimal is not enough.

Affected version: 2.8.1...2.8.x, 2.9.x

### Modifications

- Skip add the DecimalConversion in `extractAvroSchema()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UUID not supported by AVRO Schema
4 participants