-
Notifications
You must be signed in to change notification settings - Fork 477
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
ORC-1121: Fix column coversion check bug which causes column filters don't work #1055
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
public class SchemaEvolution { | ||
// indexed by reader column id | ||
private final TypeDescription[] readerFileTypes; | ||
// key: file column id, value: reader column id | ||
private final Map<Integer, Integer> typeIdsMap = new HashMap<>(); | ||
// indexed by reader column id | ||
private final boolean[] readerIncluded; | ||
// the offset to the first column id ignoring any ACID columns | ||
|
@@ -126,6 +128,11 @@ public SchemaEvolution(TypeDescription fileSchema, | |
} | ||
} | ||
buildConversion(fileSchema, this.readerSchema, positionalLevels); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this File to Reader id mapping should be part of buildConversion |
||
for (int i = 0; i < readerFileTypes.length; i++) { | ||
if (readerFileTypes[i] != null) { | ||
this.typeIdsMap.put(readerFileTypes[i].getId(), i); | ||
} | ||
} | ||
this.positionalColumns = options.getForcePositionalEvolution(); | ||
this.ppdSafeConversion = populatePpdSafeConversion(); | ||
} | ||
|
@@ -296,13 +303,13 @@ private boolean typesAreImplicitConversion(final TypeDescription fileType, | |
|
||
/** | ||
* Check if column is safe for ppd evaluation | ||
* @param colId reader column id | ||
* @param colId file column id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For readability, can we also rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
* @return true if the specified column is safe for ppd evaluation else false | ||
*/ | ||
public boolean isPPDSafeConversion(final int colId) { | ||
if (hasConversion()) { | ||
return !(colId < 0 || colId >= ppdSafeConversion.length) && | ||
ppdSafeConversion[colId]; | ||
Integer readerTypeId = typeIdsMap.get(colId); | ||
return readerTypeId != null && ppdSafeConversion[readerTypeId]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we only use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This looks better. Done |
||
} | ||
|
||
// when there is no schema evolution PPD is safe | ||
|
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.
I think we can use an array just like
readerFileTypes
.BTW, for readability, I'd suggest renaming
readerFileTypes
toreaderIdToFileTypes
and renamingtypeIdsMap
tofileIdToReaderIds
.