@useairfoil/flight 0.3.0 → 0.4.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/dist/{src/index.d.ts → index.d.ts} +16 -16
- package/dist/{src/index.js → index.js} +8 -8
- package/dist/index.js.map +1 -0
- package/package.json +24 -30
- package/src/arrow-flight-sql.ts +10 -33
- package/src/arrow-flight.ts +11 -34
- package/src/arrow-utils.ts +3 -3
- package/src/flight-data-encoder.ts +5 -13
- package/src/index.ts +1 -5
- package/src/proto/Flight.ts +215 -97
- package/src/proto/FlightSql.ts +537 -291
- package/src/proto/any.ts +16 -9
- package/src/proto/google/protobuf/timestamp.ts +19 -10
- package/src/proto/typeRegistry.ts +11 -7
- package/src/proto-utils.ts +1 -5
- package/src/record-batch-decoder.ts +17 -61
- package/dist/src/index.js.map +0 -1
- package/dist/test/index.d.ts +0 -30
- package/dist/test/index.js +0 -80
- package/dist/test/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,51 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useairfoil/flight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"repository": "useairfoil/typescript-sdk",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src",
|
|
8
8
|
"README.md"
|
|
9
9
|
],
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/
|
|
16
|
-
"default": "./dist/
|
|
17
|
-
},
|
|
18
|
-
"./test": {
|
|
19
|
-
"types": "./dist/test/index.d.ts",
|
|
20
|
-
"import": "./dist/test/index.js",
|
|
21
|
-
"default": "./dist/test/index.js"
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
22
18
|
}
|
|
23
19
|
},
|
|
24
20
|
"scripts": {
|
|
25
21
|
"build": "tsdown",
|
|
26
22
|
"build:proto": "buf generate proto",
|
|
27
23
|
"typecheck": "tsc --noEmit",
|
|
28
|
-
"format": "biome format --write .",
|
|
29
|
-
"lint": "biome check .",
|
|
30
|
-
"lint:fix": "biome check . --write",
|
|
31
24
|
"test": "vitest",
|
|
32
25
|
"test:ci": "vitest run"
|
|
33
26
|
},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"effect": "^4.0.0-beta.25"
|
|
36
|
-
},
|
|
37
|
-
"optionalDependencies": {
|
|
38
|
-
"testcontainers": "^11.11.0"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@bufbuild/buf": "^1.57.2",
|
|
42
|
-
"@effect/vitest": "4.0.0-beta.25",
|
|
43
|
-
"@rollup/plugin-typescript": "^12.1.4",
|
|
44
|
-
"effect": "^4.0.0-beta.25",
|
|
45
|
-
"testcontainers": "^11.11.0",
|
|
46
|
-
"tsdown": "^0.15.6",
|
|
47
|
-
"vitest": "^3.2.4"
|
|
48
|
-
},
|
|
49
27
|
"dependencies": {
|
|
50
28
|
"@bufbuild/protobuf": "^2.9.0",
|
|
51
29
|
"apache-arrow": "^21.1.0",
|
|
@@ -54,5 +32,21 @@
|
|
|
54
32
|
"long": "^5.3.2",
|
|
55
33
|
"nice-grpc": "^2.1.13",
|
|
56
34
|
"nice-grpc-common": "^2.0.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@bufbuild/buf": "^1.5.7",
|
|
38
|
+
"@effect/vitest": "4.0.0-beta.54",
|
|
39
|
+
"@types/node": "^24.2.0",
|
|
40
|
+
"@useairfoil/wings-testing": "0.1.0",
|
|
41
|
+
"effect": "4.0.0-beta.54",
|
|
42
|
+
"testcontainers": "^11.14.0",
|
|
43
|
+
"tsdown": "^0.15.6",
|
|
44
|
+
"vitest": "^3.2.4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"effect": "4.0.0-beta.54"
|
|
48
|
+
},
|
|
49
|
+
"optionalDependencies": {
|
|
50
|
+
"testcontainers": "^11.14.0"
|
|
57
51
|
}
|
|
58
52
|
}
|
package/src/arrow-flight-sql.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CallOptions } from "nice-grpc";
|
|
2
|
+
|
|
3
|
+
import type { ClientOptions, HostOrChannel, RemoveTypeUrl } from "./proto-utils";
|
|
4
|
+
|
|
2
5
|
import { ArrowFlightClient } from "./arrow-flight";
|
|
3
6
|
import { Any } from "./proto/any";
|
|
4
7
|
import {
|
|
@@ -14,19 +17,11 @@ import {
|
|
|
14
17
|
CommandGetTableTypes,
|
|
15
18
|
CommandStatementQuery,
|
|
16
19
|
} from "./proto/FlightSql";
|
|
17
|
-
import type {
|
|
18
|
-
ClientOptions,
|
|
19
|
-
HostOrChannel,
|
|
20
|
-
RemoveTypeUrl,
|
|
21
|
-
} from "./proto-utils";
|
|
22
20
|
|
|
23
21
|
export class ArrowFlightSqlClient {
|
|
24
22
|
private inner: ArrowFlightClient;
|
|
25
23
|
|
|
26
|
-
constructor(
|
|
27
|
-
config: HostOrChannel,
|
|
28
|
-
options: ClientOptions<FlightServiceDefinition> = {},
|
|
29
|
-
) {
|
|
24
|
+
constructor(config: HostOrChannel, options: ClientOptions<FlightServiceDefinition> = {}) {
|
|
30
25
|
this.inner = new ArrowFlightClient(config, options);
|
|
31
26
|
}
|
|
32
27
|
|
|
@@ -34,10 +29,7 @@ export class ArrowFlightSqlClient {
|
|
|
34
29
|
return this.inner.executeFlightInfo(request, options);
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
async getCatalogs(
|
|
38
|
-
request: RemoveTypeUrl<CommandGetCatalogs>,
|
|
39
|
-
options?: CallOptions,
|
|
40
|
-
) {
|
|
32
|
+
async getCatalogs(request: RemoveTypeUrl<CommandGetCatalogs>, options?: CallOptions) {
|
|
41
33
|
const descriptor = createCommandDescriptor(
|
|
42
34
|
CommandGetCatalogs.$type,
|
|
43
35
|
CommandGetCatalogs.encode({
|
|
@@ -48,10 +40,7 @@ export class ArrowFlightSqlClient {
|
|
|
48
40
|
return this.inner.getFlightInfo(descriptor, options);
|
|
49
41
|
}
|
|
50
42
|
|
|
51
|
-
async getDbSchemas(
|
|
52
|
-
request: RemoveTypeUrl<CommandGetDbSchemas>,
|
|
53
|
-
options?: CallOptions,
|
|
54
|
-
) {
|
|
43
|
+
async getDbSchemas(request: RemoveTypeUrl<CommandGetDbSchemas>, options?: CallOptions) {
|
|
55
44
|
const descriptor = createCommandDescriptor(
|
|
56
45
|
CommandGetDbSchemas.$type,
|
|
57
46
|
CommandGetDbSchemas.encode({
|
|
@@ -62,10 +51,7 @@ export class ArrowFlightSqlClient {
|
|
|
62
51
|
return this.inner.getFlightInfo(descriptor, options);
|
|
63
52
|
}
|
|
64
53
|
|
|
65
|
-
async getTables(
|
|
66
|
-
request: RemoveTypeUrl<CommandGetTables>,
|
|
67
|
-
options?: CallOptions,
|
|
68
|
-
) {
|
|
54
|
+
async getTables(request: RemoveTypeUrl<CommandGetTables>, options?: CallOptions) {
|
|
69
55
|
const descriptor = createCommandDescriptor(
|
|
70
56
|
CommandGetTables.$type,
|
|
71
57
|
CommandGetTables.encode({
|
|
@@ -76,10 +62,7 @@ export class ArrowFlightSqlClient {
|
|
|
76
62
|
return this.inner.getFlightInfo(descriptor, options);
|
|
77
63
|
}
|
|
78
64
|
|
|
79
|
-
async getTableTypes(
|
|
80
|
-
request: RemoveTypeUrl<CommandGetTableTypes>,
|
|
81
|
-
options?: CallOptions,
|
|
82
|
-
) {
|
|
65
|
+
async getTableTypes(request: RemoveTypeUrl<CommandGetTableTypes>, options?: CallOptions) {
|
|
83
66
|
const descriptor = createCommandDescriptor(
|
|
84
67
|
CommandGetTableTypes.$type,
|
|
85
68
|
CommandGetTableTypes.encode({
|
|
@@ -90,10 +73,7 @@ export class ArrowFlightSqlClient {
|
|
|
90
73
|
return this.inner.getFlightInfo(descriptor, options);
|
|
91
74
|
}
|
|
92
75
|
|
|
93
|
-
async executeQuery(
|
|
94
|
-
request: RemoveTypeUrl<CommandStatementQuery>,
|
|
95
|
-
options?: CallOptions,
|
|
96
|
-
) {
|
|
76
|
+
async executeQuery(request: RemoveTypeUrl<CommandStatementQuery>, options?: CallOptions) {
|
|
97
77
|
const descriptor = createCommandDescriptor(
|
|
98
78
|
CommandStatementQuery.$type,
|
|
99
79
|
CommandStatementQuery.encode({
|
|
@@ -105,10 +85,7 @@ export class ArrowFlightSqlClient {
|
|
|
105
85
|
}
|
|
106
86
|
}
|
|
107
87
|
|
|
108
|
-
function createCommandDescriptor(
|
|
109
|
-
typeUrl: string,
|
|
110
|
-
value: Uint8Array,
|
|
111
|
-
): FlightDescriptor {
|
|
88
|
+
function createCommandDescriptor(typeUrl: string, value: Uint8Array): FlightDescriptor {
|
|
112
89
|
const cmd = Any.create({
|
|
113
90
|
typeUrl: `type.googleapis.com/${typeUrl}`,
|
|
114
91
|
value,
|
package/src/arrow-flight.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RecordBatch, Schema } from "apache-arrow";
|
|
2
|
+
|
|
2
3
|
import { type CallOptions, createClient } from "nice-grpc";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./arrow-utils";
|
|
4
|
+
|
|
5
|
+
import { decodeFlightDataStream, decodeSchemaFromFlightInfo } from "./arrow-utils";
|
|
6
|
+
import { type ClientOptions, createChannelFromConfig, type HostOrChannel } from "./proto-utils";
|
|
7
7
|
import {
|
|
8
8
|
type FlightData,
|
|
9
9
|
type FlightDescriptor,
|
|
@@ -15,37 +15,23 @@ import {
|
|
|
15
15
|
type PutResult,
|
|
16
16
|
type Ticket,
|
|
17
17
|
} from "./proto/Flight";
|
|
18
|
-
import {
|
|
19
|
-
type ClientOptions,
|
|
20
|
-
createChannelFromConfig,
|
|
21
|
-
type HostOrChannel,
|
|
22
|
-
} from "./proto-utils";
|
|
23
18
|
|
|
24
19
|
export class ArrowFlightClient {
|
|
25
20
|
private client: FlightServiceClient;
|
|
26
21
|
|
|
27
|
-
constructor(
|
|
28
|
-
config: HostOrChannel,
|
|
29
|
-
options: ClientOptions<FlightServiceDefinition> = {},
|
|
30
|
-
) {
|
|
22
|
+
constructor(config: HostOrChannel, options: ClientOptions<FlightServiceDefinition> = {}) {
|
|
31
23
|
const channel = createChannelFromConfig(config);
|
|
32
24
|
|
|
33
|
-
this.client = createClient(
|
|
34
|
-
FlightServiceDefinition,
|
|
35
|
-
channel,
|
|
36
|
-
options.defaultCallOptions,
|
|
37
|
-
);
|
|
25
|
+
this.client = createClient(FlightServiceDefinition, channel, options.defaultCallOptions);
|
|
38
26
|
}
|
|
39
27
|
|
|
40
|
-
executeFlightInfo(
|
|
41
|
-
info: FlightInfo,
|
|
42
|
-
options?: CallOptions,
|
|
43
|
-
): AsyncGenerator<RecordBatch> {
|
|
28
|
+
executeFlightInfo(info: FlightInfo, options?: CallOptions): AsyncGenerator<RecordBatch> {
|
|
44
29
|
const schema = decodeSchemaFromFlightInfo(info);
|
|
45
30
|
if (!schema) {
|
|
46
31
|
throw new Error("FlightInfo must have a schema");
|
|
47
32
|
}
|
|
48
33
|
|
|
34
|
+
// oxlint-disable-next-line no-this-alias
|
|
49
35
|
const client = this;
|
|
50
36
|
|
|
51
37
|
return (async function* () {
|
|
@@ -79,10 +65,7 @@ export class ArrowFlightClient {
|
|
|
79
65
|
// options?: ClientCallOptions,
|
|
80
66
|
// ): AsyncIterable<proto.arrow_flight.FlightInfo>;
|
|
81
67
|
|
|
82
|
-
getFlightInfo(
|
|
83
|
-
request: FlightDescriptor,
|
|
84
|
-
options?: CallOptions,
|
|
85
|
-
): Promise<FlightInfo> {
|
|
68
|
+
getFlightInfo(request: FlightDescriptor, options?: CallOptions): Promise<FlightInfo> {
|
|
86
69
|
return this.client.getFlightInfo(request, options);
|
|
87
70
|
}
|
|
88
71
|
|
|
@@ -104,10 +87,7 @@ export class ArrowFlightClient {
|
|
|
104
87
|
* more streams where each stream can be retrieved using a separate opaque
|
|
105
88
|
* ticket that the flight service uses for managing a collection of streams.
|
|
106
89
|
*/
|
|
107
|
-
doGet(
|
|
108
|
-
request: Ticket,
|
|
109
|
-
options: { schema: Schema } & CallOptions,
|
|
110
|
-
): AsyncIterable<RecordBatch> {
|
|
90
|
+
doGet(request: Ticket, options: { schema: Schema } & CallOptions): AsyncIterable<RecordBatch> {
|
|
111
91
|
const { schema: expectedSchema } = options;
|
|
112
92
|
return decodeFlightDataStream(this.client.doGet(request, options), {
|
|
113
93
|
expectedSchema,
|
|
@@ -122,10 +102,7 @@ export class ArrowFlightClient {
|
|
|
122
102
|
* number. In the latter, the service might implement a 'seal' action that
|
|
123
103
|
* can be applied to a descriptor once all streams are uploaded.
|
|
124
104
|
*/
|
|
125
|
-
doPut(
|
|
126
|
-
request: AsyncIterable<FlightData>,
|
|
127
|
-
options?: CallOptions,
|
|
128
|
-
): AsyncIterable<PutResult> {
|
|
105
|
+
doPut(request: AsyncIterable<FlightData>, options?: CallOptions): AsyncIterable<PutResult> {
|
|
129
106
|
return this.client.doPut(request, options);
|
|
130
107
|
}
|
|
131
108
|
|
package/src/arrow-utils.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Message, type Schema } from "apache-arrow";
|
|
2
|
+
|
|
2
3
|
import type { FlightData, FlightInfo } from "./proto/Flight";
|
|
4
|
+
|
|
3
5
|
import { RecordBatchStreamReaderFromFlightData } from "./record-batch-decoder";
|
|
4
6
|
|
|
5
|
-
export function decodeSchemaFromFlightInfo(
|
|
6
|
-
info: FlightInfo,
|
|
7
|
-
): Schema | undefined {
|
|
7
|
+
export function decodeSchemaFromFlightInfo(info: FlightInfo): Schema | undefined {
|
|
8
8
|
// Notice that the `info.schema` field has the following format:
|
|
9
9
|
// The schema of the dataset in its IPC form:
|
|
10
10
|
// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Message, type RecordBatch, type Schema } from "apache-arrow";
|
|
2
2
|
import * as metadata from "apache-arrow/ipc/metadata/message";
|
|
3
3
|
import { VectorAssembler } from "apache-arrow/visitor/vectorassembler";
|
|
4
|
+
|
|
4
5
|
import { FlightData, type FlightDescriptor } from "./proto/Flight";
|
|
5
6
|
|
|
6
7
|
export const FlightDataEncoder = {
|
|
@@ -23,21 +24,12 @@ export const FlightDataEncoder = {
|
|
|
23
24
|
{
|
|
24
25
|
appMetadata,
|
|
25
26
|
}: {
|
|
26
|
-
appMetadata?: (args: {
|
|
27
|
-
index: number;
|
|
28
|
-
length: number;
|
|
29
|
-
}) => Uint8Array | undefined;
|
|
27
|
+
appMetadata?: (args: { index: number; length: number }) => Uint8Array | undefined;
|
|
30
28
|
} = {},
|
|
31
29
|
): ReadonlyArray<FlightData> {
|
|
32
|
-
const { byteLength, nodes, bufferRegions, buffers } =
|
|
33
|
-
VectorAssembler.assemble(batch);
|
|
30
|
+
const { byteLength, nodes, bufferRegions, buffers } = VectorAssembler.assemble(batch);
|
|
34
31
|
|
|
35
|
-
const metadataRecordBatch = new metadata.RecordBatch(
|
|
36
|
-
batch.numRows,
|
|
37
|
-
nodes,
|
|
38
|
-
bufferRegions,
|
|
39
|
-
null,
|
|
40
|
-
);
|
|
32
|
+
const metadataRecordBatch = new metadata.RecordBatch(batch.numRows, nodes, bufferRegions, null);
|
|
41
33
|
|
|
42
34
|
const message = Message.from(metadataRecordBatch, byteLength);
|
|
43
35
|
|
|
@@ -77,7 +69,7 @@ function encodeRecordBatchContent(
|
|
|
77
69
|
): Uint8Array {
|
|
78
70
|
const out = new Uint8Array(byteLength);
|
|
79
71
|
const bufGroupSize = compression != null ? 2 : 1;
|
|
80
|
-
const bufs =
|
|
72
|
+
const bufs = Array.from<ArrayBufferView<ArrayBufferLike>>({ length: bufGroupSize });
|
|
81
73
|
let pos = 0;
|
|
82
74
|
|
|
83
75
|
for (let i = 0; i < buffers.length; i += bufGroupSize) {
|
package/src/index.ts
CHANGED
|
@@ -9,8 +9,4 @@ export {
|
|
|
9
9
|
PutResult,
|
|
10
10
|
Ticket,
|
|
11
11
|
} from "./proto/Flight";
|
|
12
|
-
export {
|
|
13
|
-
type ClientOptions,
|
|
14
|
-
createChannelFromConfig,
|
|
15
|
-
type HostOrChannel,
|
|
16
|
-
} from "./proto-utils";
|
|
12
|
+
export { type ClientOptions, createChannelFromConfig, type HostOrChannel } from "./proto-utils";
|