Skip to content

Commit 9aed7a0

Browse files
committed
Better schema
1 parent bf3f817 commit 9aed7a0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/snowflake.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import snowflake from "snowflake-sdk";
55

66
export default url => {
77
url = new URL(url);
8-
console.log(url);
98
const {host: account, username, password, pathname, searchParams} = new URL(
109
url
1110
);
@@ -66,25 +65,23 @@ export default url => {
6665
};
6766
};
6867

69-
// https://www.postgresql.org/docs/9.6/datatype.html
68+
// https://github.com/snowflakedb/snowflake-connector-nodejs/blob/master/lib/connection/result/data_types.js
7069
const array = ["null", "array"],
7170
boolean = ["null", "boolean"],
72-
// integer = ["null", "integer"],
71+
integer = ["null", "integer"],
7372
number = ["null", "number"],
7473
object = ["null", "object"],
7574
string = ["null", "string"];
7675
function dataTypeSchema(column) {
77-
// https://github.com/snowflakedb/snowflake-connector-nodejs/blob/master/lib/connection/result/data_types.js
7876
switch (column.getType()) {
7977
case "binary":
8078
return {type: object, buffer: true};
8179
case "boolean":
8280
return {type: boolean};
8381
case "fixed":
8482
case "real":
85-
return {type: number};
83+
return {type: column.getScale() ? number : integer};
8684
case "date":
87-
case "time":
8885
case "timestamp_ltz":
8986
case "timestamp_ntz":
9087
case "timestamp_tz":
@@ -94,6 +91,7 @@ function dataTypeSchema(column) {
9491
return {type: object};
9592
case "array":
9693
return {type: array, items: {type: object}};
94+
case "time":
9795
case "text":
9896
default:
9997
return {type: string};

0 commit comments

Comments
 (0)