fix(source): resolve avro Ref
during avro_schema_to_column_descs
without hack
#19601
+209
−21
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.
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Part of #17020.
Ref
in avro used to be supported by a hack we added in our apache_avro fork. This PR avoids the hack (replacingRef
with their referee in-place, resulting in an invalid tree containing duplicate definitions). The hack fails to work when there isRef
insideRef
- resulting in either unresolvedRef
or infinite recursion.This PR only corrects part of the usage - in
avro_schema_to_column_descs
to derive RisingWave column data types from avro schema. There will be a follow-up to correct the usage inconvert_to_datum
/AvroAccess
. Without the latter part, simple data types likeint
(inside aRef
in anotherRef
) can already be supported.Instead of building the expanded-yet-invalid tree as in the hack, this solution passes a
NamesRef
obtained from the root. Its complexity of having an associated lifetime is easy to deal with in this context. (To contrast,prost_reflect
for protobuf builds the tree withArc
- no lifetime and no duplication. Butapache_avro::Schema
does not useArc
.)The circular reference rejection logic is same as #10499 for protobuf. It can be DRY'ed with error message improved later.
This is intended to be part of v2.2 and NOT cherry-picked into earlier versions. There has been a further hack available for earlier versions that can be cherry-picked on demand - where the user is responsible for not using circular reference or an infinite recursion would happen.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.