Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ protected void writeToDB(PreparedStatement stmt, @Nullable Schema.Field field, i
case DECIMAL:
stmt.setBigDecimal(sqlIndex, record.getDecimal(fieldName));
break;
case DATETIME:
stmt.setTimestamp(sqlIndex, Timestamp.valueOf(record.getDateTime(fieldName)));
break;
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public boolean isFieldCompatible(Schema.Field field, ResultSetMetaData metadata,
boolean isSigned = metadata.isSigned(index);
int precision = metadata.getPrecision(index);

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment here about the use cases you are handling here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add more details.

// Handles datetime datatypes
// Case when Timestamp maps to datetime
// Case when Datetime2 maps to datetime
// Case when DatetimeOffset maps to datetime
if ((sqlType == Types.TIMESTAMP || sqlType == SqlServerSourceSchemaReader.DATETIME_OFFSET_TYPE)
&& fieldLogicalType.equals(Schema.LogicalType.DATETIME)) {
return true;
}
// Handle logical types first
if (fieldLogicalType != null) {
return super.isFieldCompatible(fieldType, fieldLogicalType, sqlType, precision, isSigned);
Expand Down