-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-9669] Add schema on write support to hive #13654
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
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7e3cc31
fix schema on read on hive
ff7a559
get rid of nullable check
ed44441
rename util method
0ef0f87
remove java restriction
de5c67c
revert java changes and move to new pr
3ba37c5
fix hive partition issue
041a135
fix hive tests
306d9e2
Merge branch 'master' into fix_schema_on_write_hive
ab9e84f
address review comments and apply fix that was done for avro
c7b4b8f
add testing
baedc96
get rid of object inspector cache
bfd9aa1
simplify if in hoodieavroutils
ae845ce
style
49815e2
update test that uses illegal schema for record
5fa01e2
address review comments
a31899b
refactor to get rid of most caches and make code better
65f6c00
address review comment and fix some things
dbb3f06
address review comments
15fbf03
add tests for the new hive avro serializer methods and also make the …
77825b4
fix parquet/orc extension check. Add schema evolution on log file che…
ea0bb44
fix checkstyle
560d38c
Merge branch 'master' into fix_schema_on_write_hive
96f114f
Merge branch 'master' into fix_schema_on_write_hive
efb6058
reuse code for validation of projection equivalence
52a99e1
address some review comments
4c10c4e
Revert "address some review comments"
yihua e24a2e3
Add test case
yihua 4a5339b
Only use equivalent check for read-only utils
yihua 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
82 changes: 82 additions & 0 deletions
82
hudi-common/src/main/java/org/apache/hudi/avro/AvroSchemaComparatorForRecordProjection.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,82 @@ | ||
| /* | ||
| * 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.avro; | ||
|
|
||
| import org.apache.avro.Schema; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static org.apache.hudi.avro.AvroSchemaUtils.resolveNullableSchema; | ||
|
|
||
| public class AvroSchemaComparatorForRecordProjection extends AvroSchemaComparatorForSchemaEvolution { | ||
|
|
||
| private static final AvroSchemaComparatorForRecordProjection INSTANCE = new AvroSchemaComparatorForRecordProjection(); | ||
|
|
||
| public static boolean areSchemasProjectionEquivalent(Schema s1, Schema s2) { | ||
| return INSTANCE.schemaEqualsInternal(s1, s2); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean schemaEqualsInternal(Schema s1, Schema s2) { | ||
| if (s1 == s2) { | ||
| return true; | ||
| } | ||
| if (s1 == null || s2 == null) { | ||
| return false; | ||
| } | ||
| return super.schemaEqualsInternal(resolveNullableSchema(s1), resolveNullableSchema(s2)); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean validateRecord(Schema s1, Schema s2) { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean validateField(Schema.Field f1, Schema.Field f2) { | ||
| return f1.name().equalsIgnoreCase(f2.name()); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean enumSchemaEquals(Schema s1, Schema s2) { | ||
| List<String> symbols1 = s1.getEnumSymbols(); | ||
| List<String> symbols2 = s2.getEnumSymbols(); | ||
| if (symbols1.size() > symbols2.size()) { | ||
| return false; | ||
| } | ||
|
|
||
| for (int i = 0; i < symbols1.size(); i++) { | ||
| if (!symbols1.get(i).equalsIgnoreCase(symbols2.get(i))) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean unionSchemaEquals(Schema s1, Schema s2) { | ||
| throw new UnsupportedOperationException("union not supported for projection equivalence"); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean validateFixed(Schema s1, Schema s2) { | ||
| return s1.getFixedSize() == s2.getFixedSize(); | ||
| } | ||
| } | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended for case insensitivity of column names?