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
HIVE-28046: Using serdeConstants fields instead of string literals in hive-exec module #5072
Conversation
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 4 New issues |
@abstractdog can you take a look? |
cc @ayushtkn |
@zabetak amy idea who can review this PR? |
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.
At first glance it looks reasonable. I will take a better look tomorrow.
One thing that I am not sure if it's beneficial is using the serdeConstants
in tests. I assume that we don't want to change the values of such constants cause we risk breaking compatibility. By hardcoding the string values in tests we can guard against such changes.
looks good to me I don't think we're about to change these constants, and I cannot think of a dev scenario where we risk compatibility due to the fact that we're using the constants in tests |
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.
The patch is a good starting point but it seems somewhat incomplete.
I attempted a replace based on the following semi-automatic procedure and found more places where serdeConstants
should be used.
- Generate a sed script file using serdeConstants.java for the possible replacements
grep "public static final java.lang.String" ./serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/serdeConstants.java | sed 's/.\+java\.lang\.String//'| sed 's/ //g' | sed 's/\(.*\)=\(.*\);/s#\2#serdeConstants.\1#/' | sed 's/\./\\./g' > sedrepscript
- Apply the script file to all java files in production code
find ql/src/java -name "*.java" -exec sed -i -f sedrepscript {} \;
- Manual review of change files adding import when necessary and reverting irrelevant changes.
All the changes can be found here:
6a338bb
Please review those changes and update this PR accordingly.
The replacement in test files is a controversial topic so I would suggest to exclude those changes from the patchset and target exclusively production files.
If a developer changes Also note that when we attempted a replace literals with constants in |
Quality Gate passedIssues Measures |
@zabetak could you have another look? |
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.
LGTM, will merge soon!
Using serdeConstants fields instead of string literals in hive-exec module
Why are the changes needed?
to improve the use of existing constants
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No
How was this patch tested?
using existing tests