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

#501 Fix Jdbc Native treating of nullable fields. #502

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

yruslan
Copy link
Collaborator

@yruslan yruslan commented Oct 18, 2024

Closes #501

The fix is tested and confirmed working.

@yruslan yruslan changed the base branch from main to support/1.9 October 18, 2024 08:32
@yruslan yruslan force-pushed the bugfix/501-fix-jdbc-native-nullability branch from a1c3a59 to a4572ff Compare October 18, 2024 08:51
@yruslan yruslan marked this pull request as ready for review October 18, 2024 09:18
Comment on lines +116 to +117
val v = rs.getBoolean(columnIndex)
if (rs.wasNull()) null else v
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very ugly, but it seems it is the way to go, at least for the maximum performance

Copy link
Collaborator

@VladimirRybalko VladimirRybalko Oct 18, 2024

Choose a reason for hiding this comment

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

val rsValue = dataType match {
  case BIT | BOOLEAN => rs.getBoolean(columnIndex)
  case TINYINT =>  rs.getByte(columnIndex)
  case SMALLINT      => rs.getShort(columnIndex)
  case INTEGER       => rs.getInt(columnIndex)
  case BIGINT        => rs.getLong(columnIndex)
  case FLOAT         => rs.getFloat(columnIndex)
  case DOUBLE        => rs.getDouble(columnIndex)        
  case REAL          => rs.getBigDecimal(columnIndex)
  case NUMERIC       => rs.getBigDecimal(columnIndex)
  case DATE          => sanitizeDate(rs.getDate(columnIndex))
  case TIMESTAMP     => sanitizeTimestamp(rs.getTimestamp(columnIndex))
  case _             => rs.getString(columnIndex)
}
if (rs.wasNull()) null else rsValue

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this looks much nicer indeed! Just it would call rs.wasNull() even when it is not necessary, so I still prefer the original approach.

@yruslan yruslan merged commit cb68ec6 into support/1.9 Oct 21, 2024
7 checks passed
@yruslan yruslan deleted the bugfix/501-fix-jdbc-native-nullability branch October 21, 2024 08:44
@yruslan yruslan mentioned this pull request Oct 21, 2024
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.

JDBC native source produces non-null values for null values at the source
2 participants