@@ -39,10 +39,14 @@ const assist = require('./dataTypeAssist.js');
39
39
40
40
describe ( '294. dataTypeVector1.js' , function ( ) {
41
41
let connection = null , isRunnable = false , defaultFetchTypeHandler ;
42
+ let isVectorBinaryRunnable = false ;
42
43
43
44
before ( 'Get connection' , async function ( ) {
44
45
isRunnable = await testsUtil . checkPrerequisites ( 2304000000 , 2304000000 ) ;
45
46
if ( ! isRunnable ) this . skip ( ) ;
47
+ if ( await testsUtil . isVectorBinaryRunnable ( ) ) {
48
+ isVectorBinaryRunnable = true ;
49
+ }
46
50
47
51
defaultFetchTypeHandler = oracledb . fetchTypeHandler ;
48
52
connection = await oracledb . getConnection ( dbConfig ) ;
@@ -58,25 +62,43 @@ describe('294. dataTypeVector1.js', function() {
58
62
const tableName = 'nodb_vectorDbTable' ;
59
63
60
64
before ( 'Create table' , async function ( ) {
61
- const sql = `CREATE TABLE ${ tableName } (
62
- IntCol NUMBER(9) NOT NULL,
63
- VectorCol VECTOR,
64
- VectorFixedCol VECTOR(2),
65
- Vector32Col VECTOR(10, float32),
66
- Vector64Col VECTOR(10, float64),
67
- VectorInt8Col VECTOR(4, int8),
68
- VectorBinaryCol VECTOR(16, binary),
69
- VectorFlexCol VECTOR(*, *),
70
- VectorFlex32Col VECTOR(*, float32),
71
- VectorFlex64Col VECTOR(*, float64),
72
- VectorFlex8Col VECTOR(*, int8),
73
- VectorFlexBinaryCol VECTOR(*, binary)
74
- )` ;
65
+ let sql ;
66
+ if ( isVectorBinaryRunnable ) {
67
+ sql = `CREATE TABLE ${ tableName } (
68
+ IntCol NUMBER(9) NOT NULL,
69
+ VectorCol VECTOR,
70
+ VectorFixedCol VECTOR(2),
71
+ Vector32Col VECTOR(10, float32),
72
+ Vector64Col VECTOR(10, float64),
73
+ VectorInt8Col VECTOR(4, int8),
74
+ VectorBinaryCol VECTOR(16, binary),
75
+ VectorFlexCol VECTOR(*, *),
76
+ VectorFlex32Col VECTOR(*, float32),
77
+ VectorFlex64Col VECTOR(*, float64),
78
+ VectorFlex8Col VECTOR(*, int8),
79
+ VectorFlexBinaryCol VECTOR(*, binary)
80
+ )` ;
81
+ } else {
82
+ sql = `CREATE TABLE ${ tableName } (
83
+ IntCol NUMBER(9) NOT NULL,
84
+ VectorCol VECTOR,
85
+ VectorFixedCol VECTOR(2),
86
+ Vector32Col VECTOR(10, float32),
87
+ Vector64Col VECTOR(10, float64),
88
+ VectorInt8Col VECTOR(4, int8),
89
+ VectorFlexCol VECTOR(*, *),
90
+ VectorFlex32Col VECTOR(*, float32),
91
+ VectorFlex64Col VECTOR(*, float64),
92
+ VectorFlex8Col VECTOR(*, int8)
93
+ )` ;
94
+ }
95
+
75
96
const plsql = testsUtil . sqlCreateTable ( tableName , sql ) ;
76
97
await connection . execute ( plsql ) ;
77
98
} ) ;
78
99
79
100
after ( 'Release connection' , async function ( ) {
101
+ isVectorBinaryRunnable = false ;
80
102
await connection . execute ( testsUtil . sqlDropTable ( tableName ) ) ;
81
103
} ) ;
82
104
@@ -185,6 +207,8 @@ describe('294. dataTypeVector1.js', function() {
185
207
} ) ; // 294.1.4
186
208
187
209
it ( '294.1.5 binding a binary vector type with various number typed arrays' , async function ( ) {
210
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
211
+
188
212
const uInt8Arr1 = new Uint8Array ( [ 3 , 4 ] ) ;
189
213
let binds = [
190
214
{ type : oracledb . DB_TYPE_VECTOR , val : uInt8Arr1 } ,
@@ -210,6 +234,8 @@ describe('294. dataTypeVector1.js', function() {
210
234
} ) ; // 294.1.5
211
235
212
236
it ( '294.1.6 update binary vector type into table' , async function ( ) {
237
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
238
+
213
239
const uInt8Arr1 = new Uint8Array ( [ 3 , 4 ] ) ;
214
240
let binds = [
215
241
{ type : oracledb . DB_TYPE_VECTOR , val : uInt8Arr1 } ,
@@ -237,23 +263,25 @@ describe('294. dataTypeVector1.js', function() {
237
263
`SELECT VECTOR('[34.6, 77.8]', 2, float32) FROM dual` ,
238
264
`SELECT VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual` ,
239
265
`SELECT TO_VECTOR('[34.6, 77.8]', 2, float32) FROM dual` ,
240
- `SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual` ,
241
- `SELECT TO_VECTOR('[1]', 8, binary) FROM dual`
266
+ `SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual`
242
267
] ;
268
+ if ( isVectorBinaryRunnable )
269
+ statements . push ( `SELECT TO_VECTOR('[1]', 8, binary) FROM dual` ) ;
243
270
244
271
/* eslint-disable no-loss-of-precision */
245
272
246
- const expected_vectors = [
273
+ const expectedVectors = [
247
274
[ 34.599998474121094 , 77.80000305175781 ] ,
248
275
[ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ] ,
249
276
[ 34.599998474121094 , 77.80000305175781 ] ,
250
- [ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ] ,
251
- [ 1 ]
277
+ [ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ]
252
278
] ;
279
+ if ( isVectorBinaryRunnable )
280
+ expectedVectors . push ( [ 1 ] ) ;
253
281
254
282
for ( let i = 0 ; i < statements . length ; i ++ ) {
255
283
const result = await connection . execute ( statements [ i ] ) ;
256
- assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors [ i ] ) ;
284
+ assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expectedVectors [ i ] ) ;
257
285
}
258
286
} ) ; // 294.1.7
259
287
@@ -354,6 +382,8 @@ describe('294. dataTypeVector1.js', function() {
354
382
} ) ; // 294.1.12
355
383
356
384
it ( '294.1.13 insert a float32 vector into an Binary column (negative)' , async function ( ) {
385
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
386
+
357
387
// Create a Float32Array
358
388
const float32Array = new Float32Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
359
389
@@ -434,6 +464,8 @@ describe('294. dataTypeVector1.js', function() {
434
464
} ) ; // 294.1.16
435
465
436
466
it ( '294.1.17 insert a float32 typed array into an binary vector column' , async function ( ) {
467
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
468
+
437
469
// Create a Float32Array
438
470
const float32Array = new Float32Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
439
471
@@ -526,6 +558,8 @@ describe('294. dataTypeVector1.js', function() {
526
558
} ) ; // 294.1.21
527
559
528
560
it ( '294.1.22 insert a float64 typed array into an Binary vector column' , async function ( ) {
561
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
562
+
529
563
// Create a Float32Array
530
564
const float64Array = new Float64Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
531
565
@@ -715,6 +749,7 @@ describe('294. dataTypeVector1.js', function() {
715
749
} ) ; // 294.1.30
716
750
717
751
it ( '294.1.31 inserting vector binary with invalid values' , async function ( ) {
752
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
718
753
719
754
const sql = `INSERT INTO ${ tableName } (IntCol, VectorBinaryCol)
720
755
VALUES(2, :1)` ;
@@ -1187,6 +1222,8 @@ describe('294. dataTypeVector1.js', function() {
1187
1222
} ) ; // 294.1.48
1188
1223
1189
1224
it ( '294.1.49 dml returning vector binary type' , async function ( ) {
1225
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1226
+
1190
1227
const sql = `INSERT INTO ${ tableName } (IntCol, VectorBinaryCol)
1191
1228
VALUES(1, :value)
1192
1229
RETURNING VectorBinaryCol INTO :vector_val` ;
@@ -1253,6 +1290,8 @@ describe('294. dataTypeVector1.js', function() {
1253
1290
} ) ; // 294.1.51
1254
1291
1255
1292
it ( '294.1.52 executeMany with positional args in vector binary flex column' , async function ( ) {
1293
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1294
+
1256
1295
const rows = [
1257
1296
[ 1 , [ 1 , 2 ] ] ,
1258
1297
[ 2 , [ 3 , 4 ] ] ,
@@ -1277,6 +1316,8 @@ describe('294. dataTypeVector1.js', function() {
1277
1316
} ) ; // 294.1.52
1278
1317
1279
1318
it ( '294.1.53 handling of NULLs and default values for vector binary type' , async function ( ) {
1319
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1320
+
1280
1321
// insert with default value
1281
1322
await connection . execute ( `
1282
1323
INSERT INTO ${ tableName } (IntCol) VALUES (1)
@@ -1305,6 +1346,8 @@ describe('294. dataTypeVector1.js', function() {
1305
1346
} ) ; // 294.1.53
1306
1347
1307
1348
it ( '294.1.54 ORDER BY and GROUP BY with vector binary type as negative test' , async function ( ) {
1349
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1350
+
1308
1351
await assert . rejects (
1309
1352
async ( ) => await connection . execute ( `SELECT VectorFlexBinaryCol, COUNT(*) as count
1310
1353
FROM ${ tableName }
@@ -1449,6 +1492,8 @@ describe('294. dataTypeVector1.js', function() {
1449
1492
} ) ; // 294.1.58
1450
1493
1451
1494
it ( '294.1.59 typed arrays with strings' , async function ( ) {
1495
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1496
+
1452
1497
// Create a Float32Array with strings
1453
1498
const float32ArrayWithString = new Float32Array ( [ 1 , 'invalid' , 3 , 4 ] ) ;
1454
1499
@@ -1489,6 +1534,8 @@ describe('294. dataTypeVector1.js', function() {
1489
1534
} ) ; // 294.1.60
1490
1535
1491
1536
it ( '294.1.61 typed arrays with boolean values' , async function ( ) {
1537
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1538
+
1492
1539
// Create a uint8Arr with boolean values
1493
1540
const uInt8Arr = new Uint8Array ( [ true , false ] ) ;
1494
1541
// Bind the uint8Arr using oracledb.DB_TYPE_VECTOR
@@ -1506,6 +1553,8 @@ describe('294. dataTypeVector1.js', function() {
1506
1553
} ) ; // 294.1.61
1507
1554
1508
1555
it ( '294.1.62 typed arrays with undefined value in vector binary type column' , async function ( ) {
1556
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1557
+
1509
1558
// Create a uint8Arr with undefined value
1510
1559
const uInt8Arr = new Uint8Array ( [ 1 , undefined ] ) ;
1511
1560
@@ -1524,6 +1573,8 @@ describe('294. dataTypeVector1.js', function() {
1524
1573
} ) ; // 294.1.62
1525
1574
1526
1575
it ( '294.1.63 typed arrays with null values' , async function ( ) {
1576
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1577
+
1527
1578
// Create a Float32Array with null values
1528
1579
const uInt8Arr = new Uint8Array ( [ 1 , null ] ) ;
1529
1580
@@ -1806,25 +1857,39 @@ describe('294. dataTypeVector1.js', function() {
1806
1857
it ( '294.2.3 fetching vector metadata' , async function ( ) {
1807
1858
// Using the same table name as the previous test gives an error
1808
1859
table = 'nodb_vectorDbTable2' ;
1809
- const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1860
+ let sql ;
1861
+ if ( isVectorBinaryRunnable ) {
1862
+ sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1810
1863
IntCol NUMBER,
1811
1864
VectorFixedCol VECTOR(2),
1812
1865
Vector32Col VECTOR(10, float32),
1813
1866
Vector64Col VECTOR(10, float64),
1814
1867
VectorInt8Col VECTOR(4, int8),
1815
1868
VectorBinaryCol VECTOR(16, binary)
1816
1869
)` ;
1870
+ } else {
1871
+ sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1872
+ IntCol NUMBER,
1873
+ VectorFixedCol VECTOR(2),
1874
+ Vector32Col VECTOR(10, float32),
1875
+ Vector64Col VECTOR(10, float64),
1876
+ VectorInt8Col VECTOR(4, int8)
1877
+ )` ;
1878
+ }
1879
+
1817
1880
const plsql = testsUtil . sqlCreateTable ( table , sql ) ;
1818
1881
await connection . execute ( plsql ) ;
1819
1882
1820
1883
const testValues = [
1821
1884
{ name : 'VectorFixedCol' , dimensions : 2 , format : undefined } ,
1822
- { name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
1823
- { name : 'Vector32Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT32 } ,
1824
- { name : 'Vector64Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT64 } ,
1825
- { name : 'VectorBinaryCol' , dimensions : 16 , format : oracledb . VECTOR_FORMAT_BINARY } ,
1885
+ { name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
1886
+ { name : 'Vector32Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT32 } ,
1887
+ { name : 'Vector64Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT64 } ,
1826
1888
] ;
1827
1889
1890
+ if ( isVectorBinaryRunnable )
1891
+ testValues . push ( { name : 'VectorBinaryCol' , dimensions : 16 , format : oracledb . VECTOR_FORMAT_BINARY } ) ;
1892
+
1828
1893
for ( const { name, dimensions, format } of testValues ) {
1829
1894
const vectorData = name === 'VectorBinaryCol' ?
1830
1895
new Uint8Array ( [ 3 , 4 ] ) : Array . from ( { length : dimensions } , ( _ , i ) => 0.125 * i ) ;
@@ -2016,6 +2081,8 @@ describe('294. dataTypeVector1.js', function() {
2016
2081
} ) ; // 294.2.10
2017
2082
2018
2083
it ( '294.2.11 insert a uint8 vector with 65536 dimensions to flex binary column' , async function ( ) {
2084
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2085
+
2019
2086
table = 'nodb_vectorDbTable1' ;
2020
2087
const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
2021
2088
IntCol NUMBER,
@@ -2029,6 +2096,8 @@ describe('294. dataTypeVector1.js', function() {
2029
2096
} ) ; // 294.2.11
2030
2097
2031
2098
it ( '294.2.12 insert a uint8 vector with max 65528 dimensions to flex binary column' , async function ( ) {
2099
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2100
+
2032
2101
const arr = Array ( 8191 ) . fill ( 1 ) ;
2033
2102
const vecUint8 = new Uint8Array ( arr ) ;
2034
2103
@@ -2054,6 +2123,8 @@ describe('294. dataTypeVector1.js', function() {
2054
2123
} ) ; // 294.2.12
2055
2124
2056
2125
it ( '294.2.13 vector binary column with no multiple of eight dimensions' , async function ( ) {
2126
+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2127
+
2057
2128
table = 'nodb_vectorDbTable1' ;
2058
2129
const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
2059
2130
IntCol NUMBER,
0 commit comments