8000 feat: Add support for JSON datatype · classmethod/athena-query@75fa8d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 75fa8d8

Browse files
committed
feat: Add support for JSON datatype
1 parent 85e8e46 commit 75fa8d8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/helper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ function addDataType(
134134
case "double":
135135
updatedObjectWithDataType[key] = Number(input[key]);
136136
break;
137+
case "json":
138+
updatedObjectWithDataType[key] = JSON.parse(input[key]);
139+
break;
137140
default:
138141
updatedObjectWithDataType[key] = input[key];
139142
}

test/index.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test("parse to json following ColumnInfo", async () => {
3737
{ Name: "score4", Type: "int" },
3838
{ Name: "rate1", Type: "float" },
3939
{ Name: "rate2", Type: "double" },
40+
{ Name: "metadata", Type: "json" },
4041
],
4142
},
4243
Rows: [
@@ -52,6 +53,7 @@ test("parse to json following ColumnInfo", async () => {
5253
{ VarCharValue: "score4" },
5354
{ VarCharValue: "rate1" },
5455
{ VarCharValue: "rate2" },
56+
{ VarCharValue: "metadata" },
5557
],
5658
},
5759
{
@@ -65,6 +67,12 @@ test("parse to json following ColumnInfo", async () => {
6567
{ VarCharValue: "104" },
6668
{ VarCharValue: "1.01" },
6769
{ VarCharValue: "1.02" },
70+
{
71+
VarCharValue: JSON.stringify({
72+
key1: "value1",
73+
key2: "value2",
74+
}),
75+
},
6876
],
6977
},
7078
],
@@ -86,6 +94,7 @@ test("parse to json following ColumnInfo", async () => {
8694
score4: 104,
8795
rate1: 1.01,
8896
rate2: 1.02,
97+
metadata: { key1: "value1", key2: "value2" },
8998
});
9099
});
91100

0 commit comments

Comments
 (0)
0