Skip to content

Commit adb3295

Browse files
authored
Merge pull request #415 from data-integrations/sql_server_datatypes
Mssql batch source and sink documentation changes
2 parents 03f40d0 + a4dd583 commit adb3295

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

mssql-plugin/docs/SqlServer-batchsink.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ Data Types Mapping
9292
| BIT | boolean | |
9393
| CHAR | string | |
9494
| DATE | date | |
95-
| DATETIME | timestamp | |
96-
| DATETIME2 | timestamp | |
97-
| DATETIMEOFFSET | string | DATETIMEOFFSET string literal in the following format: |
95+
| DATETIME | datetime | |
96+
| DATETIME2 | datetime | |
97+
| DATETIMEOFFSET | timestamp | DATETIMEOFFSET string literal in the following format: |
9898
| | | "2019-06-24 16:19:15.8010000 +03:00" |
9999
| DECIMAL | decimal | |
100100
| FLOAT | double | |
@@ -107,7 +107,7 @@ Data Types Mapping
107107
| NVARCHAR | string | |
108108
| NVARCHAR(MAX) | string | |
109109
| REAL | float | |
110-
| SMALLDATETIME | timestamp | |
110+
| SMALLDATETIME | datetime | |
111111
| SMALLINT | int | |
112112
| SMALLMONEY | decimal | |
113113
| TEXT | string | |

mssql-plugin/docs/SqlServer-batchsource.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Data Types Mapping
110110
| DATE | date | |
111111
| DATETIME | datetime | Users can manually set output schema to map it to timestamp. |
112112
| DATETIME2 | datetime | Users can manually set output schema to map it to timestamp. |
113-
| DATETIMEOFFSET | datetime | Users can manually set output schema to map it to string. |
113+
| DATETIMEOFFSET | timestamp | Users can manually set output schema to map it to datetime. |
114114
| DECIMAL | decimal | |
115115
| FLOAT | double | |
116116
| IMAGE | bytes | |
@@ -122,7 +122,7 @@ Data Types Mapping
122122
| NVARCHAR | string | |
123123
| NVARCHAR(MAX) | string | |
124124
| REAL | float | |
125-
| SMALLDATETIME | timestamp | |
125+
| SMALLDATETIME | datetime | Users can manually set output schema to map it to timestamp. |
126126
| SMALLINT | int | |
127127
| SMALLMONEY | decimal | |
128128
| TEXT | string | |

mssql-plugin/src/main/java/io/cdap/plugin/mssql/SqlFieldsValidator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ public boolean isFieldCompatible(Schema.Field field, ResultSetMetaData metadata,
6464
|| super.isFieldCompatible(field, metadata, index);
6565
case STRING:
6666
return
67-
sqlType == SqlServerSinkSchemaReader.DATETIME_OFFSET_TYPE
6867
// Value of GEOMETRY and GEOGRAPHY type can be set as Well Known Text string such as "POINT(3 40 5 6)"
69-
|| sqlType == SqlServerSinkSchemaReader.GEOGRAPHY_TYPE
68+
sqlType == SqlServerSinkSchemaReader.GEOGRAPHY_TYPE
7069
|| sqlType == SqlServerSinkSchemaReader.GEOMETRY_TYPE
7170
|| sqlType == SqlServerSinkSchemaReader.SQL_VARIANT
7271
|| sqlType == Types.ROWID

mssql-plugin/src/main/java/io/cdap/plugin/mssql/SqlServerSource.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ public void validate(FailureCollector collector) {
197197
@Override
198198
protected void validateField(FailureCollector collector, Schema.Field field, Schema actualFieldSchema,
199199
Schema expectedFieldSchema) {
200-
// we allow the case when actual type is Datetime but user manually set it to timestamp (datetime and datetime2)
201-
// or string (datetimeoffset). To make it compatible with old behavior that convert datetime to timestamp.
200+
// we allow the case when actual type is Datetime but user manually set it to timestamp (datetime and datetime2).
201+
// To make it compatible with old behavior that convert datetime to timestamp.
202202
// below validation is kind of loose, it's possible users try to manually map datetime to string or
203203
// map datetimeoffset to timestamp which is invalid. In such case runtime will still fail even validation passes.
204204
// But we don't have the original source type information here and don't want to do big refactoring here
@@ -208,12 +208,6 @@ protected void validateField(FailureCollector collector, Schema.Field field, Sch
208208
// SmallDateTime does not contain any TimeZone information
209209
return;
210210
}
211-
if ((actualFieldSchema.getLogicalType() == Schema.LogicalType.DATETIME ||
212-
actualFieldSchema.getLogicalType() == Schema.LogicalType.TIMESTAMP_MICROS) &&
213-
expectedFieldSchema.getType() == Schema.Type.STRING) {
214-
// Case when user manually sets the type to string
215-
return;
216-
}
217211
if (actualFieldSchema.getLogicalType() == Schema.LogicalType.TIMESTAMP_MICROS &&
218212
expectedFieldSchema.getLogicalType() == Schema.LogicalType.DATETIME) {
219213
// DateTimeOffset case where we map it to CDAP Timestamp as opposed to CDAP DateTime earlier

0 commit comments

Comments
 (0)