@useairfoil/flight 0.4.0 → 0.4.2

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/src/proto/any.ts CHANGED
@@ -242,24 +242,17 @@ function base64FromBytes(arr: Uint8Array): string {
242
242
 
243
243
  type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
244
244
 
245
- export type DeepPartial<T> = T extends Builtin
246
- ? T
247
- : T extends globalThis.Array<infer U>
248
- ? globalThis.Array<DeepPartial<U>>
249
- : T extends ReadonlyArray<infer U>
250
- ? ReadonlyArray<DeepPartial<U>>
251
- : T extends { readonly $case: string }
252
- ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
253
- : T extends {}
254
- ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
255
- : Partial<T>;
245
+ export type DeepPartial<T> = T extends Builtin ? T
246
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
247
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
248
+ : T extends { readonly $case: string }
249
+ ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
250
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
251
+ : Partial<T>;
256
252
 
257
253
  type KeysOfUnion<T> = T extends T ? keyof T : never;
258
- export type Exact<P, I extends P> = P extends Builtin
259
- ? P
260
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
261
- [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never;
262
- };
254
+ export type Exact<P, I extends P> = P extends Builtin ? P
255
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
263
256
 
264
257
  function isSet(value: any): boolean {
265
258
  return value !== null && value !== undefined;
@@ -34,6 +34,8 @@ PROTO3 = 999,
34
34
  */
35
35
  2023 = 1000,
36
36
  2024 = 1001,
37
+ /** UNSTABLE - A placeholder edition for developing and testing unscheduled features. */
38
+ UNSTABLE = 9999,
37
39
  /**
38
40
  * 1_TEST_ONLY - Placeholder editions for testing feature resolution. These should not be
39
41
  * used or relied on outside of tests.
@@ -72,6 +74,9 @@ case 1000:
72
74
  case 1001:
73
75
  case "EDITION_2024":
74
76
  return Edition.2024;
77
+ case 9999:
78
+ case "EDITION_UNSTABLE":
79
+ return Edition.UNSTABLE;
75
80
  case 1:
76
81
  case "EDITION_1_TEST_ONLY":
77
82
  return Edition.1_TEST_ONLY;
@@ -105,6 +110,7 @@ case Edition.PROTO2: return "EDITION_PROTO2";
105
110
  case Edition.PROTO3: return "EDITION_PROTO3";
106
111
  case Edition.2023: return "EDITION_2023";
107
112
  case Edition.2024: return "EDITION_2024";
113
+ case Edition.UNSTABLE: return "EDITION_UNSTABLE";
108
114
  case Edition.1_TEST_ONLY: return "EDITION_1_TEST_ONLY";
109
115
  case Edition.2_TEST_ONLY: return "EDITION_2_TEST_ONLY";
110
116
  case Edition.99997_TEST_ONLY: return "EDITION_99997_TEST_ONLY";
@@ -1001,7 +1007,12 @@ readonly unverifiedLazy?: boolean | undefined,
1001
1007
  * is a formalization for deprecating fields.
1002
1008
  */
1003
1009
  readonly deprecated?: boolean | undefined,
1004
- /** For Google-internal migration only. Do not use. */
1010
+ /**
1011
+ * DEPRECATED. DO NOT USE!
1012
+ * For Google-internal migration only. Do not use.
1013
+ *
1014
+ * @deprecated
1015
+ */
1005
1016
  readonly weak?: boolean | undefined,
1006
1017
  /**
1007
1018
  * Indicate that the field value should not be printed out when using debug
@@ -104,15 +104,16 @@ export const protobufPackage = "google.protobuf";
104
104
  export interface Timestamp {
105
105
  $type: "google.protobuf.Timestamp";
106
106
  /**
107
- * Represents seconds of UTC time since Unix epoch
108
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
109
- * 9999-12-31T23:59:59Z inclusive.
107
+ * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
108
+ * be between -315576000000 and 315576000000 inclusive (which corresponds to
109
+ * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).
110
110
  */
111
111
  readonly seconds: bigint;
112
112
  /**
113
- * Non-negative fractions of a second at nanosecond resolution. Negative
114
- * second values with fractions must still have non-negative nanos values
115
- * that count forward in time. Must be from 0 to 999,999,999
113
+ * Non-negative fractions of a second at nanosecond resolution. This field is
114
+ * the nanosecond portion of the duration, not an alternative to seconds.
115
+ * Negative second values with fractions must still have non-negative nanos
116
+ * values that count forward in time. Must be between 0 and 999,999,999
116
117
  * inclusive.
117
118
  */
118
119
  readonly nanos: number;
@@ -128,9 +129,7 @@ export const Timestamp: MessageFns<Timestamp, "google.protobuf.Timestamp"> = {
128
129
  encode(message: Timestamp, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
129
130
  if (message.seconds !== 0n) {
130
131
  if (BigInt.asIntN(64, message.seconds) !== message.seconds) {
131
- throw new globalThis.Error(
132
- "value provided for field message.seconds of type int64 too large",
133
- );
132
+ throw new globalThis.Error("value provided for field message.seconds of type int64 too large");
134
133
  }
135
134
  writer.uint32(8).int64(message.seconds);
136
135
  }
@@ -206,24 +205,17 @@ messageTypeRegistry.set(Timestamp.$type, Timestamp);
206
205
 
207
206
  type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
208
207
 
209
- export type DeepPartial<T> = T extends Builtin
210
- ? T
211
- : T extends globalThis.Array<infer U>
212
- ? globalThis.Array<DeepPartial<U>>
213
- : T extends ReadonlyArray<infer U>
214
- ? ReadonlyArray<DeepPartial<U>>
215
- : T extends { readonly $case: string }
216
- ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
217
- : T extends {}
218
- ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
219
- : Partial<T>;
208
+ export type DeepPartial<T> = T extends Builtin ? T
209
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
210
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
211
+ : T extends { readonly $case: string }
212
+ ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
213
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
214
+ : Partial<T>;
220
215
 
221
216
  type KeysOfUnion<T> = T extends T ? keyof T : never;
222
- export type Exact<P, I extends P> = P extends Builtin
223
- ? P
224
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
225
- [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never;
226
- };
217
+ export type Exact<P, I extends P> = P extends Builtin ? P
218
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
227
219
 
228
220
  function isSet(value: any): boolean {
229
221
  return value !== null && value !== undefined;
@@ -20,14 +20,10 @@ export type UnknownMessage = { $type: string };
20
20
  export const messageTypeRegistry = new Map<string, MessageType>();
21
21
 
22
22
  type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
23
- export type DeepPartial<T> = T extends Builtin
24
- ? T
25
- : T extends globalThis.Array<infer U>
26
- ? globalThis.Array<DeepPartial<U>>
27
- : T extends ReadonlyArray<infer U>
28
- ? ReadonlyArray<DeepPartial<U>>
29
- : T extends { readonly $case: string }
30
- ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
31
- : T extends {}
32
- ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
33
- : Partial<T>;
23
+ export type DeepPartial<T> = T extends Builtin ? T
24
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
25
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
26
+ : T extends { readonly $case: string }
27
+ ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
28
+ : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
29
+ : Partial<T>;
@@ -49,6 +49,7 @@ import { CompressedVectorLoader, VectorLoader } from "apache-arrow/visitor/vecto
49
49
  import * as flatbuffers from "flatbuffers";
50
50
 
51
51
  import type { FlightData } from "./proto/Flight";
52
+ import type { RecordBatchWithMetadata } from "./record-batch-with-metadata";
52
53
 
53
54
  const invalidMessageType = (type: MessageHeader) =>
54
55
  `Expected ${MessageHeader[type]} Message in stream, but was null or length 0.`;
@@ -240,7 +241,7 @@ abstract class RecordBatchReaderImpl<T extends TypeMap = any> implements RecordB
240
241
 
241
242
  export class RecordBatchStreamReaderFromFlightData<T extends TypeMap = any>
242
243
  extends RecordBatchReaderImpl<T>
243
- implements AsyncIterableIterator<RecordBatch<T>>
244
+ implements AsyncIterableIterator<RecordBatchWithMetadata<T>>
244
245
  {
245
246
  protected _reader: AsyncIterator<FlightData>;
246
247
 
@@ -261,8 +262,8 @@ export class RecordBatchStreamReaderFromFlightData<T extends TypeMap = any>
261
262
  // return true;
262
263
  // }
263
264
 
264
- public [Symbol.asyncIterator](): AsyncIterableIterator<RecordBatch<T>> {
265
- return this as AsyncIterableIterator<RecordBatch<T>>;
265
+ public [Symbol.asyncIterator](): AsyncIterableIterator<RecordBatchWithMetadata<T>> {
266
+ return this as AsyncIterableIterator<RecordBatchWithMetadata<T>>;
266
267
  }
267
268
 
268
269
  /*
@@ -320,7 +321,13 @@ export class RecordBatchStreamReaderFromFlightData<T extends TypeMap = any>
320
321
  this._recordBatchIndex++;
321
322
  const header = message.header();
322
323
  const recordBatch = this._loadRecordBatch(header, flight.dataBody);
323
- return { done: false, value: recordBatch };
324
+ return {
325
+ done: false,
326
+ value: {
327
+ batch: recordBatch,
328
+ appMetadata: flight.appMetadata,
329
+ },
330
+ };
324
331
  } else if (message.isDictionaryBatch()) {
325
332
  this._dictionaryIndex++;
326
333
  const header = message.header();
@@ -333,7 +340,10 @@ export class RecordBatchStreamReaderFromFlightData<T extends TypeMap = any>
333
340
  this._recordBatchIndex++;
334
341
  return {
335
342
  done: false,
336
- value: new _InternalEmptyPlaceholderRecordBatch<T>(this.schema),
343
+ value: {
344
+ batch: new _InternalEmptyPlaceholderRecordBatch<T>(this.schema),
345
+ appMetadata: new Uint8Array(0),
346
+ },
337
347
  };
338
348
  }
339
349
 
@@ -0,0 +1,6 @@
1
+ import type { RecordBatch, TypeMap } from "apache-arrow";
2
+
3
+ export type RecordBatchWithMetadata<T extends TypeMap = any> = {
4
+ readonly batch: RecordBatch<T>;
5
+ readonly appMetadata: Uint8Array;
6
+ };
@@ -1,98 +0,0 @@
1
- import type { CallOptions } from "nice-grpc";
2
-
3
- import type { ClientOptions, HostOrChannel, RemoveTypeUrl } from "./proto-utils";
4
-
5
- import { ArrowFlightClient } from "./arrow-flight";
6
- import { Any } from "./proto/any";
7
- import {
8
- FlightDescriptor,
9
- FlightDescriptor_DescriptorType,
10
- type FlightInfo,
11
- type FlightServiceDefinition,
12
- } from "./proto/Flight";
13
- import {
14
- CommandGetCatalogs,
15
- CommandGetDbSchemas,
16
- CommandGetTables,
17
- CommandGetTableTypes,
18
- CommandStatementQuery,
19
- } from "./proto/FlightSql";
20
-
21
- export class ArrowFlightSqlClient {
22
- private inner: ArrowFlightClient;
23
-
24
- constructor(config: HostOrChannel, options: ClientOptions<FlightServiceDefinition> = {}) {
25
- this.inner = new ArrowFlightClient(config, options);
26
- }
27
-
28
- executeFlightInfo(request: FlightInfo, options?: CallOptions) {
29
- return this.inner.executeFlightInfo(request, options);
30
- }
31
-
32
- async getCatalogs(request: RemoveTypeUrl<CommandGetCatalogs>, options?: CallOptions) {
33
- const descriptor = createCommandDescriptor(
34
- CommandGetCatalogs.$type,
35
- CommandGetCatalogs.encode({
36
- $type: CommandGetCatalogs.$type,
37
- ...request,
38
- }).finish(),
39
- );
40
- return this.inner.getFlightInfo(descriptor, options);
41
- }
42
-
43
- async getDbSchemas(request: RemoveTypeUrl<CommandGetDbSchemas>, options?: CallOptions) {
44
- const descriptor = createCommandDescriptor(
45
- CommandGetDbSchemas.$type,
46
- CommandGetDbSchemas.encode({
47
- $type: CommandGetDbSchemas.$type,
48
- ...request,
49
- }).finish(),
50
- );
51
- return this.inner.getFlightInfo(descriptor, options);
52
- }
53
-
54
- async getTables(request: RemoveTypeUrl<CommandGetTables>, options?: CallOptions) {
55
- const descriptor = createCommandDescriptor(
56
- CommandGetTables.$type,
57
- CommandGetTables.encode({
58
- $type: CommandGetTables.$type,
59
- ...request,
60
- }).finish(),
61
- );
62
- return this.inner.getFlightInfo(descriptor, options);
63
- }
64
-
65
- async getTableTypes(request: RemoveTypeUrl<CommandGetTableTypes>, options?: CallOptions) {
66
- const descriptor = createCommandDescriptor(
67
- CommandGetTableTypes.$type,
68
- CommandGetTableTypes.encode({
69
- $type: CommandGetTableTypes.$type,
70
- ...request,
71
- }).finish(),
72
- );
73
- return this.inner.getFlightInfo(descriptor, options);
74
- }
75
-
76
- async executeQuery(request: RemoveTypeUrl<CommandStatementQuery>, options?: CallOptions) {
77
- const descriptor = createCommandDescriptor(
78
- CommandStatementQuery.$type,
79
- CommandStatementQuery.encode({
80
- $type: CommandStatementQuery.$type,
81
- ...request,
82
- }).finish(),
83
- );
84
- return this.inner.getFlightInfo(descriptor, options);
85
- }
86
- }
87
-
88
- function createCommandDescriptor(typeUrl: string, value: Uint8Array): FlightDescriptor {
89
- const cmd = Any.create({
90
- typeUrl: `type.googleapis.com/${typeUrl}`,
91
- value,
92
- });
93
-
94
- return FlightDescriptor.create({
95
- type: FlightDescriptor_DescriptorType.CMD,
96
- cmd: Any.encode(cmd).finish(),
97
- });
98
- }
@@ -1,126 +0,0 @@
1
- import type { RecordBatch, Schema } from "apache-arrow";
2
-
3
- import { type CallOptions, createClient } from "nice-grpc";
4
-
5
- import { decodeFlightDataStream, decodeSchemaFromFlightInfo } from "./arrow-utils";
6
- import { type ClientOptions, createChannelFromConfig, type HostOrChannel } from "./proto-utils";
7
- import {
8
- type FlightData,
9
- type FlightDescriptor,
10
- type FlightInfo,
11
- type FlightServiceClient,
12
- FlightServiceDefinition,
13
- type HandshakeRequest,
14
- type HandshakeResponse,
15
- type PutResult,
16
- type Ticket,
17
- } from "./proto/Flight";
18
-
19
- export class ArrowFlightClient {
20
- private client: FlightServiceClient;
21
-
22
- constructor(config: HostOrChannel, options: ClientOptions<FlightServiceDefinition> = {}) {
23
- const channel = createChannelFromConfig(config);
24
-
25
- this.client = createClient(FlightServiceDefinition, channel, options.defaultCallOptions);
26
- }
27
-
28
- executeFlightInfo(info: FlightInfo, options?: CallOptions): AsyncGenerator<RecordBatch> {
29
- const schema = decodeSchemaFromFlightInfo(info);
30
- if (!schema) {
31
- throw new Error("FlightInfo must have a schema");
32
- }
33
-
34
- // oxlint-disable-next-line no-this-alias
35
- const client = this;
36
-
37
- return (async function* () {
38
- for (const endpoint of info.endpoint) {
39
- if (endpoint.ticket === undefined) {
40
- continue;
41
- }
42
-
43
- yield* client.doGet(endpoint.ticket, { schema, ...options });
44
- }
45
- })();
46
- }
47
-
48
- /**
49
- * Handshake between client and server.
50
- *
51
- * Depending on the server, the handshake may be required to determine the
52
- * token that should be used for future operations. Both request and response
53
- * are streams to allow multiple round-trips depending on auth mechanism.
54
- */
55
- handshake(
56
- request: AsyncIterable<HandshakeRequest>,
57
- options?: CallOptions,
58
- ): AsyncIterable<HandshakeResponse> {
59
- return this.client.handshake(request, options);
60
- }
61
-
62
- /** Get a list of available streams given a particular criteria. */
63
- // listFlights(
64
- // request: proto.arrow_flight.Criteria,
65
- // options?: ClientCallOptions,
66
- // ): AsyncIterable<proto.arrow_flight.FlightInfo>;
67
-
68
- getFlightInfo(request: FlightDescriptor, options?: CallOptions): Promise<FlightInfo> {
69
- return this.client.getFlightInfo(request, options);
70
- }
71
-
72
- // /** Start a query and get information to poll its execution status. */
73
- // pollFlightInfo(
74
- // request: proto.arrow_flight.FlightDescriptor,
75
- // options?: ClientCallOptions,
76
- // ): Promise<proto.arrow_flight.PollInfo>;
77
-
78
- // /** Get the schema for a given FlightDescriptor. */
79
- // getSchema(
80
- // request: proto.arrow_flight.FlightDescriptor,
81
- // options?: ClientCallOptions,
82
- // ): Promise<proto.arrow_flight.SchemaResult>;
83
-
84
- /**
85
- * Retrieve a single stream associated with a particular descriptor
86
- * associated with the referenced ticket. A Flight can be composed of one or
87
- * more streams where each stream can be retrieved using a separate opaque
88
- * ticket that the flight service uses for managing a collection of streams.
89
- */
90
- doGet(request: Ticket, options: { schema: Schema } & CallOptions): AsyncIterable<RecordBatch> {
91
- const { schema: expectedSchema } = options;
92
- return decodeFlightDataStream(this.client.doGet(request, options), {
93
- expectedSchema,
94
- });
95
- }
96
-
97
- /**
98
- * Push a stream to the flight service associated with a particular
99
- * flight stream. This allows a client of a flight service to upload a stream
100
- * of data. Depending on the particular flight service, a client consumer
101
- * could be allowed to upload a single stream per descriptor or an unlimited
102
- * number. In the latter, the service might implement a 'seal' action that
103
- * can be applied to a descriptor once all streams are uploaded.
104
- */
105
- doPut(request: AsyncIterable<FlightData>, options?: CallOptions): AsyncIterable<PutResult> {
106
- return this.client.doPut(request, options);
107
- }
108
-
109
- // /** Open a bidirectional data channel for a given descriptor. */
110
- // doExchange(
111
- // request: AsyncIterable<proto.arrow_flight.FlightData>,
112
- // options?: ClientCallOptions,
113
- // ): AsyncIterable<proto.arrow_flight.FlightData>;
114
-
115
- // /** Execute a specific action against the flight service. */
116
- // doAction(
117
- // request: proto.arrow_flight.Action,
118
- // options?: ClientCallOptions,
119
- // ): AsyncIterable<proto.arrow_flight.Result>;
120
-
121
- // /** Get all available action types. */
122
- // listActions(
123
- // request: proto.arrow_flight.Empty,
124
- // options?: ClientCallOptions,
125
- // ): AsyncIterable<proto.arrow_flight.ActionType>;
126
- }