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

HIVE-28703: Integral Data Type Overflow Not Enforced for JsonSerDe and UDFs #5608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

armitage420
Copy link
Contributor

What changes were proposed in this pull request?

The pull request addresses the issue of data type overflow not being enforced when using JsonSerDe in Apache Hive. The proposed changes aim to ensure strict data type validation during the insertion and loading of data into tables defined with types like TINYINT, SMALLINT, INT, and BIGINT.

Why are the changes needed?

This behavior can lead to data integrity issues and unexpected results.

Does this PR introduce any user-facing change?

Yes

Is the change a dependency upgrade?

No

How was this patch tested?

Tests introduced in this PR and local machine

@armitage420 armitage420 changed the title HIVE-28703: Integral Data Type Overflow Not Enforced for JsonSerDe and UDFs [WIP]HIVE-28703: Integral Data Type Overflow Not Enforced for JsonSerDe and UDFs Jan 12, 2025
@armitage420 armitage420 changed the title [WIP]HIVE-28703: Integral Data Type Overflow Not Enforced for JsonSerDe and UDFs HIVE-28703: Integral Data Type Overflow Not Enforced for JsonSerDe and UDFs Jan 16, 2025
@@ -128,6 +128,11 @@ public ByteWritable evaluate(IntWritable i) {
if (i == null) {
return null;
} else {
int value = i.get();
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
throw new IllegalArgumentException("Value out of range for Byte: " + value);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to use Hive-specific exceptions. Hive has an exception UDFArgumentException which seems suitable here.

@@ -146,6 +146,10 @@ public IntWritable evaluate(LongWritable i) {
if (i == null) {
return null;
} else {
long value = i.get();
if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
throw new IllegalArgumentException("Value out of range for Integer: " + value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, generic exception.

@@ -128,6 +128,10 @@ public ShortWritable evaluate(IntWritable i) {
if (i == null) {
return null;
} else {
int value = i.get();
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new IllegalArgumentException("Value out of range for Short: " + value);
Copy link
Contributor

Choose a reason for hiding this comment

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

same, can you please use Hive specific exceptions

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.

3 participants