@qualithm/arrow-flight-sql-js 1.5.3 → 1.5.4
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/README.md +4 -0
- package/dist/results.d.ts +1 -1
- package/dist/results.d.ts.map +1 -1
- package/dist/results.js +21 -24
- package/dist/results.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -143,7 +143,11 @@ bun run build
|
|
|
143
143
|
### Testing
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
|
+
# Unit tests
|
|
146
147
|
bun test
|
|
148
|
+
|
|
149
|
+
# Integration tests (requires running Arrow Flight SQL server)
|
|
150
|
+
FLIGHT_HOST=localhost FLIGHT_PORT=50051 bun run test:integration
|
|
147
151
|
```
|
|
148
152
|
|
|
149
153
|
### Linting & Formatting
|
package/dist/results.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type FlightData, type FlightInfo, type Ticket } from "@qualithm/arrow-flight-js";
|
|
7
7
|
import { tableFromIPC } from "apache-arrow";
|
|
8
8
|
import type { FlightSqlClient, QueryOptions } from "./client.js";
|
|
9
9
|
/**
|
package/dist/results.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAGhE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAuBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAG1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CA+B1C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAuB,cAAc,CACnC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,UAAU,GACf,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAO7C;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAW1C"}
|
package/dist/results.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result set iteration utilities for Flight SQL queries.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { flightDataToIpc } from "@qualithm/arrow-flight-js";
|
|
1
7
|
import { tableFromIPC } from "apache-arrow";
|
|
2
8
|
import { FlightSqlError } from "./errors.js";
|
|
3
9
|
/**
|
|
4
10
|
* Collects all FlightData from a doGet stream into Arrow IPC bytes.
|
|
5
11
|
*
|
|
12
|
+
* Uses flightDataToIpc to properly frame the data with continuation tokens
|
|
13
|
+
* and metadata length prefixes as required by the Arrow IPC format.
|
|
14
|
+
*
|
|
6
15
|
* @param dataStream - The async iterable of FlightData messages
|
|
7
|
-
* @returns
|
|
16
|
+
* @returns Properly framed Arrow IPC bytes
|
|
8
17
|
*/
|
|
9
18
|
async function collectFlightData(dataStream) {
|
|
10
|
-
const
|
|
19
|
+
const messages = [];
|
|
11
20
|
for await (const data of dataStream) {
|
|
12
|
-
|
|
13
|
-
if (data.dataHeader.length > 0) {
|
|
14
|
-
chunks.push(data.dataHeader);
|
|
15
|
-
}
|
|
16
|
-
// Data body contains the actual record batch
|
|
17
|
-
if (data.dataBody.length > 0) {
|
|
18
|
-
chunks.push(data.dataBody);
|
|
19
|
-
}
|
|
21
|
+
messages.push(data);
|
|
20
22
|
}
|
|
21
|
-
return
|
|
23
|
+
return flightDataToIpc(messages);
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Executes a query and returns results as an Arrow Table.
|
|
@@ -79,15 +81,17 @@ export async function flightInfoToTable(client, info) {
|
|
|
79
81
|
continue;
|
|
80
82
|
}
|
|
81
83
|
const dataStream = client.doGet(endpoint.ticket);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
+
const ipcBytes = await collectFlightData(dataStream);
|
|
85
|
+
if (ipcBytes.length > 0) {
|
|
86
|
+
allChunks.push(ipcBytes);
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
if (allChunks.length === 0) {
|
|
86
90
|
throw new FlightSqlError("no data returned from query", "RESULT_ERROR", {
|
|
87
91
|
flightCode: "NOT_FOUND"
|
|
88
92
|
});
|
|
89
93
|
}
|
|
90
|
-
// Combine all
|
|
94
|
+
// Combine all endpoint data and parse as IPC
|
|
91
95
|
const totalLength = allChunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
92
96
|
const combined = new Uint8Array(totalLength);
|
|
93
97
|
let offset = 0;
|
|
@@ -134,19 +138,12 @@ export async function* iterateResults(client, info) {
|
|
|
134
138
|
*/
|
|
135
139
|
export async function ticketToTable(client, ticket) {
|
|
136
140
|
const dataStream = client.doGet(ticket);
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
141
|
+
const ipcBytes = await collectFlightData(dataStream);
|
|
142
|
+
if (ipcBytes.length === 0) {
|
|
139
143
|
throw new FlightSqlError("no data returned from ticket", "RESULT_ERROR", {
|
|
140
144
|
flightCode: "NOT_FOUND"
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
|
-
|
|
144
|
-
const combined = new Uint8Array(totalLength);
|
|
145
|
-
let offset = 0;
|
|
146
|
-
for (const chunk of chunks) {
|
|
147
|
-
combined.set(chunk, offset);
|
|
148
|
-
offset += chunk.length;
|
|
149
|
-
}
|
|
150
|
-
return tableFromIPC(combined);
|
|
147
|
+
return tableFromIPC(ipcBytes);
|
|
151
148
|
}
|
|
152
149
|
//# sourceMappingURL=results.js.map
|
package/dist/results.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEL,eAAe,EAGhB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAa5C;;;;;;;;GAQG;AACH,KAAK,UAAU,iBAAiB,CAC9B,UAAuD;IAEvD,MAAM,QAAQ,GAAiB,EAAE,CAAA;IAEjC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IAED,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,KAAa,EACb,OA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,MAAM,IAAI,KAAK,CAAC,MAAM,CAAA;IACxB,CAAC;IAED,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAA;AAC/B,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,cAAc,CACnC,MAAuB,EACvB,IAAgB;IAEhB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrB,SAAQ;QACV,CAAC;QACD,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAuB,EACvB,MAAc;IAEd,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAA;IAEpD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,cAAc,CAAC,8BAA8B,EAAE,cAAc,EAAE;YACvE,UAAU,EAAE,WAAW;SACxB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAA;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qualithm/arrow-flight-sql-js",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Arrow Flight SQL client for JavaScript and TypeScript runtimes.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -57,9 +57,10 @@
|
|
|
57
57
|
"proto:generate": "grpc_tools_node_protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --proto_path=./proto --ts_proto_out=./src/generated --ts_proto_opt=outputServices=grpc-js,esModuleInterop=true,importSuffix=.js,env=node,useExactTypes=false,snakeToCamel=true,outputPartialMethods=true,enumsAsLiterals=true proto/arrow/flight/protocol/sql/FlightSql.proto",
|
|
58
58
|
"start": "bun run src/index.ts",
|
|
59
59
|
"test:coverage": "bun test --coverage",
|
|
60
|
+
"test:integration": "bun test src/__tests__/integration",
|
|
60
61
|
"test:unit": "bun test src/__tests__/unit",
|
|
61
62
|
"test:watch": "bun test --watch",
|
|
62
|
-
"test": "bun test",
|
|
63
|
+
"test": "bun test src/__tests__/unit",
|
|
63
64
|
"typecheck": "tsc -p tsconfig.node.json --noEmit"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {},
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"apache-arrow": ">=17.0.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
|
-
"@qualithm/arrow-flight-js": "1.6.
|
|
72
|
+
"@qualithm/arrow-flight-js": "1.6.4",
|
|
72
73
|
"apache-arrow": "21.1.0",
|
|
73
74
|
"@eslint/js": "10.0.1",
|
|
74
75
|
"grpc-tools": "1.13.1",
|