Skip to content

Upcast int/float in long/double in sink #220

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

Conversation

jayehwhyehentee
Copy link
Collaborator

Fixes #219

/gcbrun

@jayehwhyehentee jayehwhyehentee merged commit 374dd7b into GoogleCloudDataproc:main Feb 25, 2025
4 checks passed
@jayehwhyehentee jayehwhyehentee deleted the fix_int_float branch February 25, 2025 14:32
Comment on lines +128 to +137
return Long.valueOf(String.valueOf((int) element.getShort(fieldNumber)));
case INTEGER:
return Long.valueOf(String.valueOf(element.getInt(fieldNumber)));
case DATE:
// read in the form of - number of days since EPOCH (Integer)
return element.getInt(fieldNumber);
case BIGINT:
return element.getLong(fieldNumber);
case FLOAT:
return element.getFloat(fieldNumber);
return Double.valueOf(String.valueOf(element.getFloat(fieldNumber)));

Choose a reason for hiding this comment

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

Why are we converting to string then long/double here? Wouldn't this be super inefficient? Why not just cast the values? (long) element.getInt(...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair point. #222 looks good?

Choose a reason for hiding this comment

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

Thank you for fixing this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integer and Float schema types fail after creation
3 participants