Skip to content

Commit ab5d2c9

Browse files
added support for timestamp_tz datatype.
added support for timestamp_tz datatype.
1 parent 8bcb39f commit ab5d2c9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

docs/Snowflake-batchsource.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Data Types Mapping
6868
----------
6969

7070
| Snowflake Data Types | CDAP Schema Data Type | Comment |
71-
| ------------------------------ | --------------------- | --------------------------------------------------------- |
71+
| ------------------------------ |-----------------------| --------------------------------------------------------- |
7272
| NUMBER | decimal | Default precision and scale are (38,0). |
7373
| DECIMAL | decimal | Synonymous with NUMBER. |
7474
| NUMERIC | decimal | Synonymous with NUMBER. |
@@ -87,10 +87,10 @@ Data Types Mapping
8787
| DATE | date | |
8888
| DATETIME | timestamp | Alias for TIMESTAMP_NTZ |
8989
| TIME | time | |
90-
| TIMESTAMP | timestamp/string | Alias for one of the TIMESTAMP variations (TIMESTAMP_NTZ by default).|
90+
| TIMESTAMP | timestamp | Alias for one of the TIMESTAMP variations (TIMESTAMP_NTZ by default).|
9191
| TIMESTAMP_LTZ | timestamp | TIMESTAMP with local time zone; time zone, if provided, is not stored.|
9292
| TIMESTAMP_NTZ | timestamp | TIMESTAMP with no time zone; time zone, if provided, is not stored.|
93-
| TIMESTAMP_TZ | string | TIMESTAMP with time zone. |
93+
| TIMESTAMP_TZ | timestamp | TIMESTAMP with time zone. |
9494
| VARIANT | string | A tagged universal type, which can store values of any other type, including OBJECT and ARRAY, up to a maximum size of 16 MB compressed. |
9595
| OBJECT | string | This will return a json with the data |
9696
| ARRAY | string | This will return a json with the data | |

src/main/java/io/cdap/plugin/snowflake/common/util/SchemaHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class SchemaHelper {
5151
.put(Types.BOOLEAN, Schema.of(Schema.Type.BOOLEAN))
5252
.put(Types.BIGINT, Schema.decimalOf(38))
5353
.put(Types.SMALLINT, Schema.decimalOf(38))
54+
.put(Types.TIMESTAMP_WITH_TIMEZONE, Schema.of(Schema.LogicalType.TIMESTAMP_MICROS))
5455
.build();
5556

5657
private SchemaHelper() {

src/test/java/io/cdap/plugin/snowflake/common/util/SchemaHelperTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public void testGetSchemaFromSnowflake() throws IOException {
108108
new SnowflakeFieldDescriptor("field121", Types.BIGINT, true),
109109
new SnowflakeFieldDescriptor("field122", Types.BIGINT, false),
110110
new SnowflakeFieldDescriptor("field131", Types.SMALLINT, true),
111-
new SnowflakeFieldDescriptor("field132", Types.SMALLINT, false));
111+
new SnowflakeFieldDescriptor("field132", Types.SMALLINT, false),
112+
new SnowflakeFieldDescriptor("field133", Types.TIMESTAMP_WITH_TIMEZONE, false),
113+
new SnowflakeFieldDescriptor("field134", Types.TIMESTAMP_WITH_TIMEZONE, true));
112114

113115
Schema expected = Schema.recordOf(
114116
"data",
@@ -135,7 +137,9 @@ public void testGetSchemaFromSnowflake() throws IOException {
135137
Schema.Field.of("field121", Schema.nullableOf(Schema.decimalOf(38))),
136138
Schema.Field.of("field122", Schema.decimalOf(38)),
137139
Schema.Field.of("field131", Schema.nullableOf(Schema.decimalOf(38))),
138-
Schema.Field.of("field132", Schema.decimalOf(38))
140+
Schema.Field.of("field132", Schema.decimalOf(38)),
141+
Schema.Field.of("field133", Schema.of(Schema.LogicalType.TIMESTAMP_MICROS)),
142+
Schema.Field.of("field134", Schema.nullableOf(Schema.of(Schema.LogicalType.TIMESTAMP_MICROS)))
139143
);
140144

141145
Mockito.when(snowflakeAccessor.describeQuery(null)).thenReturn(sample);

0 commit comments

Comments
 (0)