duckdb 0.8.2-dev15.0 → 0.8.2-dev33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/duckdb.d.ts +59 -0
- package/lib/duckdb.js +21 -0
- package/package.json +1 -1
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +0 -12
- package/src/duckdb/src/common/types/vector.cpp +15 -14
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +6 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb_node.hpp +1 -0
- package/src/statement.cpp +94 -1
- package/test/columns.test.ts +243 -0
package/lib/duckdb.d.ts
CHANGED
@@ -171,6 +171,63 @@ export class Database {
|
|
171
171
|
): Promise<void>;
|
172
172
|
}
|
173
173
|
|
174
|
+
export type GenericTypeInfo = {
|
175
|
+
id: string,
|
176
|
+
sql_type: string,
|
177
|
+
alias?: string,
|
178
|
+
}
|
179
|
+
|
180
|
+
export type StructTypeInfo = {
|
181
|
+
id: "STRUCT",
|
182
|
+
alias?: string,
|
183
|
+
sql_type: string,
|
184
|
+
children: TypeInfoChildren,
|
185
|
+
}
|
186
|
+
|
187
|
+
export type ListTypeInfo = {
|
188
|
+
id: "LIST",
|
189
|
+
alias?: string,
|
190
|
+
sql_type: string,
|
191
|
+
child: TypeInfo,
|
192
|
+
}
|
193
|
+
|
194
|
+
export type MapTypeInfo = {
|
195
|
+
id: "MAP",
|
196
|
+
alias?: string,
|
197
|
+
sql_type: string,
|
198
|
+
key: TypeInfo,
|
199
|
+
value: TypeInfo,
|
200
|
+
}
|
201
|
+
|
202
|
+
export type UnionTypeInfo = {
|
203
|
+
id: "UNION",
|
204
|
+
alias?: string,
|
205
|
+
sql_type: string,
|
206
|
+
children: TypeInfoChildren,
|
207
|
+
}
|
208
|
+
|
209
|
+
export type DecimalTypeInfo = {
|
210
|
+
id: "DECIMAL",
|
211
|
+
alias?: string,
|
212
|
+
sql_type: string,
|
213
|
+
width: number,
|
214
|
+
scale: number,
|
215
|
+
}
|
216
|
+
|
217
|
+
export type EnumTypeInfo = {
|
218
|
+
id: "ENUM",
|
219
|
+
alias?: string,
|
220
|
+
sql_type: string,
|
221
|
+
name: string,
|
222
|
+
values: string[],
|
223
|
+
}
|
224
|
+
|
225
|
+
export type TypeInfoChildren = { name: string, type: TypeInfo }[];
|
226
|
+
|
227
|
+
export type TypeInfo = GenericTypeInfo | StructTypeInfo | ListTypeInfo | MapTypeInfo | UnionTypeInfo | DecimalTypeInfo | EnumTypeInfo;
|
228
|
+
|
229
|
+
export type ColumnInfo = { name: string, type: TypeInfo };
|
230
|
+
|
174
231
|
export class Statement {
|
175
232
|
sql: string;
|
176
233
|
|
@@ -185,6 +242,8 @@ export class Statement {
|
|
185
242
|
finalize(callback?: Callback<void>): void;
|
186
243
|
|
187
244
|
run(...args: [...any, Callback<void>] | any[]): Statement;
|
245
|
+
|
246
|
+
columns(): ColumnInfo[];
|
188
247
|
}
|
189
248
|
|
190
249
|
export const ERROR: number;
|
package/lib/duckdb.js
CHANGED
@@ -689,6 +689,27 @@ Statement.prototype.stream;
|
|
689
689
|
*/
|
690
690
|
Statement.prototype.sql;
|
691
691
|
|
692
|
+
/**
|
693
|
+
* @method
|
694
|
+
* @return {ColumnInfo[]} - Array of column names and types
|
695
|
+
*/
|
696
|
+
Statement.prototype.columns;
|
697
|
+
|
698
|
+
/**
|
699
|
+
* @typedef ColumnInfo
|
700
|
+
* @type {object}
|
701
|
+
* @property {string} name - Column name
|
702
|
+
* @property {TypeInfo} type - Column type
|
703
|
+
*/
|
704
|
+
|
705
|
+
/**
|
706
|
+
* @typedef TypeInfo
|
707
|
+
* @type {object}
|
708
|
+
* @property {string} id - Type ID
|
709
|
+
* @property {string} [alias] - SQL type alias
|
710
|
+
* @property {string} sql_type - SQL type name
|
711
|
+
*/
|
712
|
+
|
692
713
|
/**
|
693
714
|
* @typedef DuckDbError
|
694
715
|
* @type {object}
|
package/package.json
CHANGED
@@ -14,12 +14,6 @@ namespace duckdb {
|
|
14
14
|
|
15
15
|
ArrowSchemaWrapper::~ArrowSchemaWrapper() {
|
16
16
|
if (arrow_schema.release) {
|
17
|
-
for (int64_t child_idx = 0; child_idx < arrow_schema.n_children; child_idx++) {
|
18
|
-
auto &child = *arrow_schema.children[child_idx];
|
19
|
-
if (child.release) {
|
20
|
-
child.release(&child);
|
21
|
-
}
|
22
|
-
}
|
23
17
|
arrow_schema.release(&arrow_schema);
|
24
18
|
arrow_schema.release = nullptr;
|
25
19
|
}
|
@@ -27,12 +21,6 @@ ArrowSchemaWrapper::~ArrowSchemaWrapper() {
|
|
27
21
|
|
28
22
|
ArrowArrayWrapper::~ArrowArrayWrapper() {
|
29
23
|
if (arrow_array.release) {
|
30
|
-
for (int64_t child_idx = 0; child_idx < arrow_array.n_children; child_idx++) {
|
31
|
-
auto &child = *arrow_array.children[child_idx];
|
32
|
-
if (child.release) {
|
33
|
-
child.release(&child);
|
34
|
-
}
|
35
|
-
}
|
36
24
|
arrow_array.release(&arrow_array);
|
37
25
|
arrow_array.release = nullptr;
|
38
26
|
}
|
@@ -855,38 +855,39 @@ void Vector::Flatten(const SelectionVector &sel, idx_t count) {
|
|
855
855
|
}
|
856
856
|
}
|
857
857
|
|
858
|
-
void Vector::ToUnifiedFormat(idx_t count, UnifiedVectorFormat &
|
858
|
+
void Vector::ToUnifiedFormat(idx_t count, UnifiedVectorFormat &format) {
|
859
859
|
switch (GetVectorType()) {
|
860
860
|
case VectorType::DICTIONARY_VECTOR: {
|
861
861
|
auto &sel = DictionaryVector::SelVector(*this);
|
862
|
+
format.owned_sel.Initialize(sel);
|
863
|
+
format.sel = &format.owned_sel;
|
864
|
+
|
862
865
|
auto &child = DictionaryVector::Child(*this);
|
863
866
|
if (child.GetVectorType() == VectorType::FLAT_VECTOR) {
|
864
|
-
data
|
865
|
-
|
866
|
-
data.validity = FlatVector::Validity(child);
|
867
|
+
format.data = FlatVector::GetData(child);
|
868
|
+
format.validity = FlatVector::Validity(child);
|
867
869
|
} else {
|
868
|
-
// dictionary with non-flat child: create a new reference to the child and
|
870
|
+
// dictionary with non-flat child: create a new reference to the child and flatten it
|
869
871
|
Vector child_vector(child);
|
870
872
|
child_vector.Flatten(sel, count);
|
871
873
|
auto new_aux = make_buffer<VectorChildBuffer>(std::move(child_vector));
|
872
874
|
|
873
|
-
data
|
874
|
-
|
875
|
-
data.validity = FlatVector::Validity(new_aux->data);
|
875
|
+
format.data = FlatVector::GetData(new_aux->data);
|
876
|
+
format.validity = FlatVector::Validity(new_aux->data);
|
876
877
|
this->auxiliary = std::move(new_aux);
|
877
878
|
}
|
878
879
|
break;
|
879
880
|
}
|
880
881
|
case VectorType::CONSTANT_VECTOR:
|
881
|
-
|
882
|
-
|
883
|
-
|
882
|
+
format.sel = ConstantVector::ZeroSelectionVector(count, format.owned_sel);
|
883
|
+
format.data = ConstantVector::GetData(*this);
|
884
|
+
format.validity = ConstantVector::Validity(*this);
|
884
885
|
break;
|
885
886
|
default:
|
886
887
|
Flatten(count);
|
887
|
-
|
888
|
-
|
889
|
-
|
888
|
+
format.sel = FlatVector::IncrementalSelectionVector();
|
889
|
+
format.data = FlatVector::GetData(*this);
|
890
|
+
format.validity = FlatVector::Validity(*this);
|
890
891
|
break;
|
891
892
|
}
|
892
893
|
}
|
@@ -564,10 +564,12 @@ static idx_t DistinctSelectList(Vector &left, Vector &right, idx_t count, const
|
|
564
564
|
SelectionVector lcursor(count);
|
565
565
|
SelectionVector rcursor(count);
|
566
566
|
|
567
|
-
ListVector::GetEntry(left)
|
568
|
-
ListVector::GetEntry(right)
|
569
|
-
|
570
|
-
|
567
|
+
Vector lentry_flattened(ListVector::GetEntry(left));
|
568
|
+
Vector rentry_flattened(ListVector::GetEntry(right));
|
569
|
+
lentry_flattened.Flatten(ListVector::GetListSize(left));
|
570
|
+
rentry_flattened.Flatten(ListVector::GetListSize(right));
|
571
|
+
Vector lchild(lentry_flattened, lcursor, count);
|
572
|
+
Vector rchild(rentry_flattened, rcursor, count);
|
571
573
|
|
572
574
|
// To perform the positional comparison, we use a vectorisation of the following algorithm:
|
573
575
|
// bool CompareLists(T *left, idx_t nleft, T *right, nright) {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.2-
|
2
|
+
#define DUCKDB_VERSION "0.8.2-dev33"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "5e5bd3d4f7"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
package/src/duckdb_node.hpp
CHANGED
@@ -165,6 +165,7 @@ public:
|
|
165
165
|
Napi::Value Run(const Napi::CallbackInfo &info);
|
166
166
|
Napi::Value Finish(const Napi::CallbackInfo &info);
|
167
167
|
Napi::Value Stream(const Napi::CallbackInfo &info);
|
168
|
+
Napi::Value Columns(const Napi::CallbackInfo &info);
|
168
169
|
|
169
170
|
public:
|
170
171
|
static Napi::FunctionReference constructor;
|
package/src/statement.cpp
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
#include "duckdb/common/helper.hpp"
|
12
12
|
#include "duckdb/common/vector.hpp"
|
13
|
+
#include "duckdb/common/types.hpp"
|
13
14
|
|
14
15
|
using duckdb::unique_ptr;
|
15
16
|
using duckdb::vector;
|
@@ -25,7 +26,8 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
|
|
25
26
|
DefineClass(env, "Statement",
|
26
27
|
{InstanceMethod("run", &Statement::Run), InstanceMethod("all", &Statement::All),
|
27
28
|
InstanceMethod("arrowIPCAll", &Statement::ArrowIPCAll), InstanceMethod("each", &Statement::Each),
|
28
|
-
InstanceMethod("finalize", &Statement::Finish), InstanceMethod("stream", &Statement::Stream)
|
29
|
+
InstanceMethod("finalize", &Statement::Finish), InstanceMethod("stream", &Statement::Stream),
|
30
|
+
InstanceMethod("columns", &Statement::Columns)});
|
29
31
|
|
30
32
|
constructor = Napi::Persistent(t);
|
31
33
|
constructor.SuppressDestruct();
|
@@ -503,6 +505,97 @@ Napi::Value Statement::Stream(const Napi::CallbackInfo &info) {
|
|
503
505
|
return deferred.Promise();
|
504
506
|
}
|
505
507
|
|
508
|
+
static Napi::Value TypeToObject(Napi::Env &env, const duckdb::LogicalType &type) {
|
509
|
+
auto obj = Napi::Object::New(env);
|
510
|
+
|
511
|
+
auto id = duckdb::LogicalTypeIdToString(type.id());
|
512
|
+
obj.Set("id", id);
|
513
|
+
obj.Set("sql_type", type.ToString());
|
514
|
+
|
515
|
+
if (type.HasAlias()) {
|
516
|
+
obj.Set("alias", type.GetAlias());
|
517
|
+
}
|
518
|
+
|
519
|
+
switch (type.id()) {
|
520
|
+
case duckdb::LogicalTypeId::STRUCT: {
|
521
|
+
auto &child_types = duckdb::StructType::GetChildTypes(type);
|
522
|
+
auto arr = Napi::Array::New(env, child_types.size());
|
523
|
+
for (size_t i = 0; i < child_types.size(); i++) {
|
524
|
+
auto child_name = child_types[i].first;
|
525
|
+
auto child_type = child_types[i].second;
|
526
|
+
auto child_obj = Napi::Object::New(env);
|
527
|
+
child_obj.Set("name", child_name);
|
528
|
+
child_obj.Set("type", TypeToObject(env, child_type));
|
529
|
+
arr.Set(i, child_obj);
|
530
|
+
}
|
531
|
+
obj.Set("children", arr);
|
532
|
+
} break;
|
533
|
+
case duckdb::LogicalTypeId::LIST: {
|
534
|
+
auto &child_type = duckdb::ListType::GetChildType(type);
|
535
|
+
obj.Set("child", TypeToObject(env, child_type));
|
536
|
+
} break;
|
537
|
+
case duckdb::LogicalTypeId::MAP: {
|
538
|
+
auto &key_type = duckdb::MapType::KeyType(type);
|
539
|
+
auto &value_type = duckdb::MapType::ValueType(type);
|
540
|
+
obj.Set("key", TypeToObject(env, key_type));
|
541
|
+
obj.Set("value", TypeToObject(env, value_type));
|
542
|
+
} break;
|
543
|
+
case duckdb::LogicalTypeId::ENUM: {
|
544
|
+
auto name = duckdb::EnumType::GetTypeName(type);
|
545
|
+
auto &values_vec = duckdb::EnumType::GetValuesInsertOrder(type);
|
546
|
+
auto enum_size = duckdb::EnumType::GetSize(type);
|
547
|
+
auto arr = Napi::Array::New(env, enum_size);
|
548
|
+
for (size_t i = 0; i < enum_size; i++) {
|
549
|
+
auto child_name = values_vec.GetValue(i).GetValue<duckdb::string>();
|
550
|
+
arr.Set(i, child_name);
|
551
|
+
}
|
552
|
+
obj.Set("name", name);
|
553
|
+
obj.Set("values", arr);
|
554
|
+
} break;
|
555
|
+
case duckdb::LogicalTypeId::UNION: {
|
556
|
+
auto child_count = duckdb::UnionType::GetMemberCount(type);
|
557
|
+
auto arr = Napi::Array::New(env, child_count);
|
558
|
+
for (size_t i = 0; i < child_count; i++) {
|
559
|
+
auto &child_name = duckdb::UnionType::GetMemberName(type, i);
|
560
|
+
auto &child_type = duckdb::UnionType::GetMemberType(type, i);
|
561
|
+
auto child_obj = Napi::Object::New(env);
|
562
|
+
child_obj.Set("name", child_name);
|
563
|
+
child_obj.Set("type", TypeToObject(env, child_type));
|
564
|
+
arr.Set(i, child_obj);
|
565
|
+
}
|
566
|
+
obj.Set("children", arr);
|
567
|
+
} break;
|
568
|
+
case duckdb::LogicalTypeId::DECIMAL: {
|
569
|
+
auto width = duckdb::DecimalType::GetWidth(type);
|
570
|
+
auto scale = duckdb::DecimalType::GetScale(type);
|
571
|
+
obj.Set("width", width);
|
572
|
+
obj.Set("scale", scale);
|
573
|
+
} break;
|
574
|
+
default:
|
575
|
+
break;
|
576
|
+
}
|
577
|
+
return obj;
|
578
|
+
}
|
579
|
+
|
580
|
+
Napi::Value Statement::Columns(const Napi::CallbackInfo &info) {
|
581
|
+
Napi::Env env = info.Env();
|
582
|
+
|
583
|
+
if (!statement) {
|
584
|
+
return env.Null();
|
585
|
+
}
|
586
|
+
|
587
|
+
auto &names = statement->GetNames();
|
588
|
+
auto &types = statement->GetTypes();
|
589
|
+
auto arr = Napi::Array::New(env, names.size());
|
590
|
+
for (size_t i = 0; i < names.size(); i++) {
|
591
|
+
auto obj = Napi::Object::New(env);
|
592
|
+
obj.Set("name", Napi::String::New(env, names[i]));
|
593
|
+
obj.Set("type", TypeToObject(env, types[i]));
|
594
|
+
arr.Set(i, obj);
|
595
|
+
}
|
596
|
+
return arr;
|
597
|
+
}
|
598
|
+
|
506
599
|
struct FinishTask : public Task {
|
507
600
|
FinishTask(Statement &statement, Napi::Function callback) : Task(statement, callback) {
|
508
601
|
}
|
@@ -0,0 +1,243 @@
|
|
1
|
+
import * as duckdb from '..';
|
2
|
+
import * as assert from 'assert';
|
3
|
+
|
4
|
+
describe('Column Types', function() {
|
5
|
+
let db: duckdb.Database;
|
6
|
+
before(function(done) { db = new duckdb.Database(':memory:', done); });
|
7
|
+
|
8
|
+
it('should prepare a statement and return the columns and their types', function(done) {
|
9
|
+
// we dont include the large_enum and small_enum since they are huge and test the same code path as the small_enum
|
10
|
+
var stmt = db.prepare("SELECT * EXCLUDE(medium_enum, large_enum) FROM test_all_types()", function(err: null | Error) {
|
11
|
+
if (err) throw err;
|
12
|
+
|
13
|
+
let cols = stmt.columns();
|
14
|
+
|
15
|
+
assert.equal(cols.length, 41);
|
16
|
+
|
17
|
+
var expected = [
|
18
|
+
{ name: 'bool', type: { id: 'BOOLEAN', sql_type: 'BOOLEAN' } },
|
19
|
+
{ name: 'tinyint', type: { id: 'TINYINT', sql_type: 'TINYINT' } },
|
20
|
+
{ name: 'smallint', type: { id: 'SMALLINT', sql_type: 'SMALLINT' } },
|
21
|
+
{ name: 'int', type: { id: 'INTEGER', sql_type: 'INTEGER' } },
|
22
|
+
{ name: 'bigint', type: { id: 'BIGINT', sql_type: 'BIGINT' } },
|
23
|
+
{ name: 'hugeint', type: { id: 'HUGEINT', sql_type: 'HUGEINT' } },
|
24
|
+
{ name: 'utinyint', type: { id: 'UTINYINT', sql_type: 'UTINYINT' } },
|
25
|
+
{ name: 'usmallint', type: { id: 'USMALLINT', sql_type: 'USMALLINT' } },
|
26
|
+
{ name: 'uint', type: { id: 'UINTEGER', sql_type: 'UINTEGER' } },
|
27
|
+
{ name: 'ubigint', type: { id: 'UBIGINT', sql_type: 'UBIGINT' } },
|
28
|
+
{ name: 'date', type: { id: 'DATE', sql_type: 'DATE' } },
|
29
|
+
{ name: 'time', type: { id: 'TIME', sql_type: 'TIME' } },
|
30
|
+
{ name: 'timestamp', type: { id: 'TIMESTAMP', sql_type: 'TIMESTAMP' } },
|
31
|
+
{ name: 'timestamp_s', type: { id: 'TIMESTAMP_S', sql_type: 'TIMESTAMP_S' } },
|
32
|
+
{ name: 'timestamp_ms', type: { id: 'TIMESTAMP_MS', sql_type: 'TIMESTAMP_MS' } },
|
33
|
+
{ name: 'timestamp_ns', type: { id: 'TIMESTAMP_NS', sql_type: 'TIMESTAMP_NS' } },
|
34
|
+
{ name: 'time_tz', type: { id: 'TIME WITH TIME ZONE', sql_type: 'TIME WITH TIME ZONE' } },
|
35
|
+
{ name: 'timestamp_tz', type: { id: 'TIMESTAMP WITH TIME ZONE', sql_type: 'TIMESTAMP WITH TIME ZONE' } },
|
36
|
+
{ name: 'float', type: { id: 'FLOAT', sql_type: 'FLOAT' } },
|
37
|
+
{ name: 'double', type: { id: 'DOUBLE', sql_type: 'DOUBLE' } },
|
38
|
+
{ name: 'dec_4_1', type: { id: 'DECIMAL', sql_type: 'DECIMAL(4,1)', width: 4, scale: 1 } },
|
39
|
+
{ name: 'dec_9_4', type: { id: 'DECIMAL', sql_type: 'DECIMAL(9,4)', width: 9, scale: 4 } },
|
40
|
+
{ name: 'dec_18_6', type: { id: 'DECIMAL', sql_type: 'DECIMAL(18,6)', width: 18, scale: 6 } },
|
41
|
+
{ name: 'dec38_10', type: { id: 'DECIMAL', sql_type: 'DECIMAL(38,10)', width: 38, scale: 10 } },
|
42
|
+
{ name: 'uuid', type: { id: 'UUID', sql_type: 'UUID' } },
|
43
|
+
{ name: 'interval', type: { id: 'INTERVAL', sql_type: 'INTERVAL' } },
|
44
|
+
{ name: 'varchar', type: { id: 'VARCHAR', sql_type: 'VARCHAR' } },
|
45
|
+
{ name: 'blob', type: { id: 'BLOB', sql_type: 'BLOB' } },
|
46
|
+
{ name: 'bit', type: { id: 'BIT', sql_type: 'BIT' } },
|
47
|
+
{
|
48
|
+
name: 'small_enum',
|
49
|
+
type: {
|
50
|
+
id: 'ENUM',
|
51
|
+
sql_type: 'small_enum',
|
52
|
+
name: 'small_enum',
|
53
|
+
values: [
|
54
|
+
"DUCK_DUCK_ENUM",
|
55
|
+
"GOOSE"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
name: 'int_array',
|
61
|
+
type: {
|
62
|
+
id: 'LIST',
|
63
|
+
sql_type: 'INTEGER[]',
|
64
|
+
child: {
|
65
|
+
id: 'INTEGER',
|
66
|
+
sql_type: 'INTEGER'
|
67
|
+
}
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: 'double_array',
|
72
|
+
type: {
|
73
|
+
id: 'LIST',
|
74
|
+
sql_type: 'DOUBLE[]',
|
75
|
+
child: {
|
76
|
+
id: 'DOUBLE',
|
77
|
+
sql_type: 'DOUBLE'
|
78
|
+
}
|
79
|
+
}
|
80
|
+
},
|
81
|
+
{
|
82
|
+
name: 'date_array',
|
83
|
+
type: {
|
84
|
+
id: 'LIST',
|
85
|
+
sql_type: 'DATE[]',
|
86
|
+
child: {
|
87
|
+
id: 'DATE',
|
88
|
+
sql_type: 'DATE'
|
89
|
+
}
|
90
|
+
}
|
91
|
+
},
|
92
|
+
{
|
93
|
+
name: 'timestamp_array',
|
94
|
+
type: {
|
95
|
+
id: 'LIST',
|
96
|
+
sql_type: 'TIMESTAMP[]',
|
97
|
+
child: {
|
98
|
+
id: 'TIMESTAMP',
|
99
|
+
sql_type: 'TIMESTAMP'
|
100
|
+
}
|
101
|
+
}
|
102
|
+
},
|
103
|
+
{
|
104
|
+
name: 'timestamptz_array',
|
105
|
+
type: {
|
106
|
+
id: 'LIST',
|
107
|
+
sql_type: 'TIMESTAMP WITH TIME ZONE[]',
|
108
|
+
child: {
|
109
|
+
id: 'TIMESTAMP WITH TIME ZONE',
|
110
|
+
sql_type: 'TIMESTAMP WITH TIME ZONE'
|
111
|
+
}
|
112
|
+
}
|
113
|
+
},
|
114
|
+
{
|
115
|
+
name: 'varchar_array',
|
116
|
+
type: {
|
117
|
+
id: 'LIST',
|
118
|
+
sql_type: 'VARCHAR[]',
|
119
|
+
child: {
|
120
|
+
id: 'VARCHAR',
|
121
|
+
sql_type: 'VARCHAR'
|
122
|
+
}
|
123
|
+
}
|
124
|
+
},
|
125
|
+
{
|
126
|
+
name: 'nested_int_array',
|
127
|
+
type: {
|
128
|
+
id: 'LIST',
|
129
|
+
sql_type: 'INTEGER[][]',
|
130
|
+
child: {
|
131
|
+
id: 'LIST',
|
132
|
+
sql_type: 'INTEGER[]',
|
133
|
+
child: {
|
134
|
+
id: 'INTEGER',
|
135
|
+
sql_type: 'INTEGER'
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
},
|
140
|
+
{
|
141
|
+
name: 'struct',
|
142
|
+
type: {
|
143
|
+
id: 'STRUCT',
|
144
|
+
sql_type: 'STRUCT(a INTEGER, b VARCHAR)',
|
145
|
+
children: [
|
146
|
+
{
|
147
|
+
name: 'a',
|
148
|
+
type: {
|
149
|
+
id: 'INTEGER',
|
150
|
+
sql_type: 'INTEGER'
|
151
|
+
}
|
152
|
+
},
|
153
|
+
{
|
154
|
+
name: 'b',
|
155
|
+
type: {
|
156
|
+
id: 'VARCHAR',
|
157
|
+
sql_type: 'VARCHAR'
|
158
|
+
}
|
159
|
+
}
|
160
|
+
]
|
161
|
+
}
|
162
|
+
},
|
163
|
+
{
|
164
|
+
name: 'struct_of_arrays',
|
165
|
+
type: {
|
166
|
+
id: 'STRUCT',
|
167
|
+
sql_type: 'STRUCT(a INTEGER[], b VARCHAR[])',
|
168
|
+
children: [
|
169
|
+
{
|
170
|
+
name: 'a',
|
171
|
+
type: {
|
172
|
+
id: 'LIST',
|
173
|
+
sql_type: 'INTEGER[]',
|
174
|
+
child: {
|
175
|
+
id: 'INTEGER',
|
176
|
+
sql_type: 'INTEGER'
|
177
|
+
}
|
178
|
+
}
|
179
|
+
},
|
180
|
+
{
|
181
|
+
name: 'b',
|
182
|
+
type: {
|
183
|
+
id: 'LIST',
|
184
|
+
sql_type: 'VARCHAR[]',
|
185
|
+
child: {
|
186
|
+
id: 'VARCHAR',
|
187
|
+
sql_type: 'VARCHAR'
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
]
|
192
|
+
}
|
193
|
+
},
|
194
|
+
{
|
195
|
+
name: 'array_of_structs',
|
196
|
+
type: {
|
197
|
+
id: 'LIST',
|
198
|
+
sql_type: 'STRUCT(a INTEGER, b VARCHAR)[]',
|
199
|
+
child: {
|
200
|
+
id: 'STRUCT',
|
201
|
+
sql_type: 'STRUCT(a INTEGER, b VARCHAR)',
|
202
|
+
children: [
|
203
|
+
{
|
204
|
+
name: 'a',
|
205
|
+
type: {
|
206
|
+
id: 'INTEGER',
|
207
|
+
sql_type: 'INTEGER'
|
208
|
+
}
|
209
|
+
},
|
210
|
+
{
|
211
|
+
name: 'b',
|
212
|
+
type: {
|
213
|
+
id: 'VARCHAR',
|
214
|
+
sql_type: 'VARCHAR'
|
215
|
+
}
|
216
|
+
}
|
217
|
+
]
|
218
|
+
}
|
219
|
+
}
|
220
|
+
},
|
221
|
+
{
|
222
|
+
name: 'map',
|
223
|
+
type: {
|
224
|
+
id: 'MAP',
|
225
|
+
sql_type: 'MAP(VARCHAR, VARCHAR)',
|
226
|
+
key: {
|
227
|
+
id: 'VARCHAR',
|
228
|
+
sql_type: 'VARCHAR'
|
229
|
+
},
|
230
|
+
value: {
|
231
|
+
id: 'VARCHAR',
|
232
|
+
sql_type: 'VARCHAR'
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
]
|
237
|
+
|
238
|
+
assert.deepEqual(cols, expected);
|
239
|
+
|
240
|
+
});
|
241
|
+
stmt.finalize(done);
|
242
|
+
});
|
243
|
+
});
|