@databricks/zerobus-ingest-sdk 1.2.0 → 1.3.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/Cargo.lock CHANGED
@@ -409,7 +409,7 @@ dependencies = [
409
409
 
410
410
  [[package]]
411
411
  name = "databricks-zerobus-ingest-sdk"
412
- version = "2.7.1"
412
+ version = "2.8.0"
413
413
  dependencies = [
414
414
  "arrow-array",
415
415
  "arrow-flight",
@@ -2962,7 +2962,7 @@ dependencies = [
2962
2962
 
2963
2963
  [[package]]
2964
2964
  name = "zerobus-sdk-ts"
2965
- version = "1.2.0"
2965
+ version = "1.3.0"
2966
2966
  dependencies = [
2967
2967
  "arrow-array",
2968
2968
  "arrow-ipc",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "zerobus-sdk-ts"
3
- version = "1.2.0"
3
+ version = "1.3.0"
4
4
  authors = ["Databricks"]
5
5
  edition = "2021"
6
6
  license = "Apache-2.0"
@@ -16,7 +16,7 @@ crate-type = ["cdylib"]
16
16
  napi = { version = "2", features = ["async", "tokio_rt", "serde-json", "napi6"] }
17
17
  napi-derive = "2"
18
18
 
19
- databricks-zerobus-ingest-sdk = { path = "../rust/sdk", version = "2.7.1" }
19
+ databricks-zerobus-ingest-sdk = { path = "../rust/sdk", version = "2.8.0" }
20
20
 
21
21
  tokio = { version = "1.52", features = ["macros", "rt-multi-thread"] }
22
22
 
@@ -41,7 +41,7 @@ napi-build = "2"
41
41
 
42
42
  [features]
43
43
  default = []
44
- # Arrow Flight is in Beta - enable with: npm run build:arrow
44
+ # Enable with: npm run build:arrow
45
45
  arrow-flight = [
46
46
  "databricks-zerobus-ingest-sdk/arrow-flight",
47
47
  "dep:arrow-array",
package/README.md CHANGED
@@ -28,7 +28,7 @@ The Databricks Zerobus Ingest SDK for TypeScript provides a high-performance cli
28
28
  - **High-throughput ingestion**: Optimized for high-volume data ingestion with native Rust implementation
29
29
  - **Automatic recovery**: Built-in retry and recovery mechanisms for transient failures
30
30
  - **Flexible configuration**: Customizable stream behavior and timeouts
31
- - **Multiple serialization formats**: Support for JSON, Protocol Buffers, and Arrow Flight (Beta) with optional LZ4 / ZSTD compression
31
+ - **Multiple serialization formats**: Support for JSON, Protocol Buffers, and Arrow Flight ingestion with optional LZ4 / ZSTD compression
32
32
  - **Type widening**: Accept high-level types (plain objects, protobuf messages) or low-level types (strings, buffers) - automatically handles serialization
33
33
  - **Batch ingestion**: Ingest multiple records with a single acknowledgment for higher throughput
34
34
  - **OAuth 2.0 authentication**: Secure authentication with client credentials
@@ -90,10 +90,11 @@ npm run build
90
90
 
91
91
  ### Choose Your Serialization Format
92
92
 
93
- The SDK supports two serialization formats. **Protocol Buffers is the default** and recommended for production use:
93
+ The SDK supports three ingestion formats. Protocol Buffers is the default record format and recommended for production row-oriented workloads:
94
94
 
95
95
  - **Protocol Buffers (Default)** - Strongly-typed schemas, efficient binary encoding, better performance. This is the default format.
96
96
  - **JSON** - Simple, no schema compilation needed. Good for getting started quickly or when schema flexibility is needed.
97
+ - Arrow Flight - High-performance columnar ingestion for applications that already produce Arrow data. See the [Arrow example](examples/arrow/README.md).
97
98
 
98
99
  > **Note:** If you don't specify `recordType`, the SDK will use Protocol Buffers by default. To use JSON, explicitly set `recordType: RecordType.Json`.
99
100
 
package/index.d.ts CHANGED
@@ -102,6 +102,133 @@ export interface ZerobusSdkOptions {
102
102
  /** Identifier appended to the `user-agent` header */
103
103
  applicationName?: string
104
104
  }
105
+ /**
106
+ * IPC compression type for Arrow Flight streams.
107
+ *
108
+ */
109
+ export const enum IpcCompressionType {
110
+ /** LZ4 frame compression - fast compression with moderate ratio */
111
+ Lz4Frame = 0,
112
+ /** Zstandard compression - better compression ratio, slightly slower */
113
+ Zstd = 1
114
+ }
115
+ /**
116
+ * Configuration options for Arrow Flight streams.
117
+ *
118
+ */
119
+ export interface ArrowStreamConfigurationOptions {
120
+ /**
121
+ * Maximum number of batches that can be in-flight (sent but not acknowledged).
122
+ * Default: 1,000
123
+ */
124
+ maxInflightBatches?: number
125
+ /**
126
+ * Whether to enable automatic stream recovery on failure.
127
+ * Default: true
128
+ */
129
+ recovery?: boolean
130
+ /**
131
+ * Timeout for recovery operations in milliseconds.
132
+ * Default: 15,000 (15 seconds)
133
+ */
134
+ recoveryTimeoutMs?: number
135
+ /**
136
+ * Delay between recovery retry attempts in milliseconds.
137
+ * Default: 2,000 (2 seconds)
138
+ */
139
+ recoveryBackoffMs?: number
140
+ /**
141
+ * Maximum number of recovery attempts before giving up.
142
+ * Default: 4
143
+ */
144
+ recoveryRetries?: number
145
+ /**
146
+ * Timeout waiting for server acknowledgments in milliseconds.
147
+ * Default: 60,000 (1 minute)
148
+ */
149
+ serverLackOfAckTimeoutMs?: number
150
+ /**
151
+ * Timeout for flush operations in milliseconds.
152
+ * Default: 300,000 (5 minutes)
153
+ */
154
+ flushTimeoutMs?: number
155
+ /**
156
+ * Timeout for connection establishment in milliseconds.
157
+ * Default: 30,000 (30 seconds)
158
+ */
159
+ connectionTimeoutMs?: number
160
+ /** Optional IPC compression type (0 = LZ4Frame, 1 = Zstd, undefined = no compression) */
161
+ ipcCompression?: number
162
+ }
163
+ /**
164
+ * Arrow data type enum for schema definition.
165
+ *
166
+ */
167
+ export const enum ArrowDataType {
168
+ /** Boolean type */
169
+ Boolean = 0,
170
+ /** Signed 8-bit integer */
171
+ Int8 = 1,
172
+ /** Signed 16-bit integer */
173
+ Int16 = 2,
174
+ /** Signed 32-bit integer */
175
+ Int32 = 3,
176
+ /** Signed 64-bit integer */
177
+ Int64 = 4,
178
+ /** Unsigned 8-bit integer */
179
+ UInt8 = 5,
180
+ /** Unsigned 16-bit integer */
181
+ UInt16 = 6,
182
+ /** Unsigned 32-bit integer */
183
+ UInt32 = 7,
184
+ /** Unsigned 64-bit integer */
185
+ UInt64 = 8,
186
+ /** 32-bit floating point */
187
+ Float32 = 9,
188
+ /** 64-bit floating point */
189
+ Float64 = 10,
190
+ /** UTF-8 encoded string */
191
+ Utf8 = 11,
192
+ /** Large UTF-8 encoded string (64-bit offsets) */
193
+ LargeUtf8 = 12,
194
+ /** Binary data */
195
+ Binary = 13,
196
+ /** Large binary data (64-bit offsets) */
197
+ LargeBinary = 14,
198
+ /** Date (32-bit days since epoch) */
199
+ Date32 = 15,
200
+ /** Date (64-bit milliseconds since epoch) */
201
+ Date64 = 16,
202
+ /** Timestamp with microsecond precision (UTC) */
203
+ TimestampMicros = 17,
204
+ /** Timestamp with nanosecond precision (UTC) */
205
+ TimestampNanos = 18
206
+ }
207
+ /**
208
+ * Arrow field definition for schema.
209
+ *
210
+ */
211
+ export interface ArrowField {
212
+ /** Field name */
213
+ name: string
214
+ /** Field data type (ArrowDataType enum value) */
215
+ dataType: number
216
+ /** Whether the field is nullable */
217
+ nullable?: boolean
218
+ }
219
+ /**
220
+ * Properties of the target Delta table for Arrow Flight ingestion.
221
+ *
222
+ * Unlike `TableProperties` which uses Protocol Buffers, Arrow Flight streams
223
+ * require an Arrow schema definition.
224
+ *
225
+ */
226
+ export interface ArrowTableProperties {
227
+ /** Full table name in Unity Catalog (e.g., "catalog.schema.table") */
228
+ tableName: string
229
+ /** Arrow schema fields */
230
+ schemaFields: Array<ArrowField>
231
+ }
105
232
  /**
106
233
  * Custom error type for Zerobus operations.
107
234
  *
@@ -117,8 +244,9 @@ export declare class ZerobusError {
117
244
  /**
118
245
  * A stream for ingesting data into a Databricks Delta table.
119
246
  *
120
- * The stream manages a bidirectional gRPC connection, handles acknowledgments,
121
- * and provides automatic recovery on transient failures.
247
+ * The stream manages JSON or Protocol Buffer ingestion over a bidirectional
248
+ * gRPC connection, handles acknowledgments, and provides automatic recovery
249
+ * on transient failures.
122
250
  *
123
251
  * # Example
124
252
  *
@@ -426,7 +554,7 @@ export declare class ZerobusSdk {
426
554
  /**
427
555
  * Creates a new ingestion stream to a Delta table.
428
556
  *
429
- * This method establishes a bidirectional gRPC connection to the Zerobus service
557
+ * This method opens a JSON or Protocol Buffer stream to the Zerobus service
430
558
  * and prepares it for data ingestion. By default, it uses OAuth 2.0 Client Credentials
431
559
  * authentication. For custom authentication (e.g., Personal Access Tokens), provide
432
560
  * a custom headers_provider.
@@ -526,4 +654,146 @@ export declare class ZerobusSdk {
526
654
  * ```
527
655
  */
528
656
  recreateStream(stream: ZerobusStream): Promise<ZerobusStream>
657
+ /**
658
+ * Creates a new Arrow Flight stream to a Delta table.
659
+ *
660
+ * This method establishes an Arrow Flight connection to the Zerobus service
661
+ * for high-performance columnar data ingestion.
662
+ *
663
+ * # Arguments
664
+ *
665
+ * * `table_properties` - Properties of the target table including name and Arrow schema
666
+ * * `client_id` - OAuth 2.0 client ID
667
+ * * `client_secret` - OAuth 2.0 client secret
668
+ * * `options` - Optional stream configuration
669
+ *
670
+ * # Returns
671
+ *
672
+ * A Promise that resolves to a ZerobusArrowStream ready for data ingestion.
673
+ *
674
+ * # Example
675
+ *
676
+ * ```typescript
677
+ * const tableProps = {
678
+ * tableName: 'catalog.schema.table',
679
+ * schemaFields: [
680
+ * { name: 'device_name', dataType: ArrowDataType.Utf8 },
681
+ * { name: 'temp', dataType: ArrowDataType.Int32 },
682
+ * { name: 'humidity', dataType: ArrowDataType.Int64 }
683
+ * ]
684
+ * };
685
+ *
686
+ * const arrowStream = await sdk.createArrowStream(
687
+ * tableProps,
688
+ * clientId,
689
+ * clientSecret,
690
+ * { maxInflightBatches: 100 }
691
+ * );
692
+ * ```
693
+ */
694
+ createArrowStream(tableProperties: ArrowTableProperties, clientId: string, clientSecret: string, options?: ArrowStreamConfigurationOptions | undefined | null): Promise<ZerobusArrowStream>
695
+ /**
696
+ * Recreates an Arrow stream with the same configuration and re-ingests unacknowledged batches.
697
+ *
698
+ * # Arguments
699
+ *
700
+ * * `stream` - The terminally failed Arrow stream to recreate. The TypeScript wrapper
701
+ * must not have been closed because `close()` releases its native handle.
702
+ *
703
+ * # Returns
704
+ *
705
+ * A Promise that resolves to a new ZerobusArrowStream with all unacknowledged batches re-ingested.
706
+ */
707
+ recreateArrowStream(stream: ZerobusArrowStream): Promise<ZerobusArrowStream>
708
+ }
709
+ /**
710
+ * An Arrow Flight stream for ingesting Arrow RecordBatches into a Delta table.
711
+ *
712
+ * This stream provides a high-performance interface for streaming Arrow data
713
+ * to Databricks Delta tables using the Arrow Flight protocol.
714
+ *
715
+ * # Lifecycle
716
+ *
717
+ * 1. Create a stream via `sdk.createArrowStream()`
718
+ * 2. Ingest Arrow IPC buffers with `ingestBatch()`
719
+ * 3. Use `waitForOffset()` to wait for acknowledgments
720
+ * 4. Call `flush()` to ensure all batches are persisted
721
+ * 5. Close the stream with `close()`
722
+ *
723
+ * # Example
724
+ *
725
+ * ```typescript
726
+ * import { tableToIPC } from 'apache-arrow';
727
+ *
728
+ * const arrowStream = await sdk.createArrowStream(
729
+ * arrowTableProps,
730
+ * clientId,
731
+ * clientSecret,
732
+ * options
733
+ * );
734
+ *
735
+ * const ipcBuffer = tableToIPC(arrowTable, 'stream');
736
+ * const offset = await arrowStream.ingestBatch(Buffer.from(ipcBuffer));
737
+ * await arrowStream.waitForOffset(offset);
738
+ * await arrowStream.close();
739
+ * ```
740
+ */
741
+ export declare class ZerobusArrowStream {
742
+ /**
743
+ * Ingests a single Arrow IPC buffer into the stream.
744
+ *
745
+ * The buffer should be an Arrow IPC stream format containing one or more RecordBatches.
746
+ * You can create this using `tableToIPC(table, 'stream')` from the apache-arrow package.
747
+ *
748
+ * # Arguments
749
+ *
750
+ * * `ipc_buffer` - Arrow IPC stream format buffer
751
+ *
752
+ * # Returns
753
+ *
754
+ * The offset ID (bigint) assigned to this batch.
755
+ *
756
+ * # Example
757
+ *
758
+ * ```typescript
759
+ * const table = tableFromArrays({
760
+ * device_name: ['sensor-1'],
761
+ * temp: [25],
762
+ * humidity: [60]
763
+ * });
764
+ * const ipcBuffer = tableToIPC(table, 'stream');
765
+ * const offset = await stream.ingestBatch(Buffer.from(ipcBuffer));
766
+ * await stream.waitForOffset(offset);
767
+ * ```
768
+ */
769
+ ingestBatch(ipcBuffer: Buffer): Promise<bigint>
770
+ /**
771
+ * Waits for a specific offset to be acknowledged by the server.
772
+ *
773
+ * Use this method with `ingestBatch()` to selectively wait for acknowledgments.
774
+ *
775
+ * # Arguments
776
+ *
777
+ * * `offset_id` - The offset ID to wait for (returned by ingestBatch)
778
+ */
779
+ waitForOffset(offsetId: bigint): Promise<void>
780
+ /** Flushes all pending batches and waits for acknowledgments. */
781
+ flush(): Promise<void>
782
+ /** Closes the stream gracefully. */
783
+ close(): Promise<void>
784
+ /** Returns whether the stream has been closed. */
785
+ get isClosed(): boolean
786
+ /** Returns the table name for this stream. */
787
+ get tableName(): string
788
+ /**
789
+ * Gets unacknowledged batches as Arrow IPC buffers.
790
+ *
791
+ * This method should only be called after a stream failure to retrieve batches
792
+ * that were sent but not acknowledged. These can be re-ingested into a new stream.
793
+ *
794
+ * # Returns
795
+ *
796
+ * An array of Buffers containing the unacknowledged batches in Arrow IPC format.
797
+ */
798
+ getUnackedBatches(): Promise<Array<Buffer>>
529
799
  }
package/index.js CHANGED
@@ -310,9 +310,12 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { RecordType, ZerobusError, ZerobusStream, ZerobusSdk } = nativeBinding
313
+ const { RecordType, ZerobusError, ZerobusStream, ZerobusSdk, IpcCompressionType, ArrowDataType, ZerobusArrowStream } = nativeBinding
314
314
 
315
315
  module.exports.RecordType = RecordType
316
316
  module.exports.ZerobusError = ZerobusError
317
317
  module.exports.ZerobusStream = ZerobusStream
318
318
  module.exports.ZerobusSdk = ZerobusSdk
319
+ module.exports.IpcCompressionType = IpcCompressionType
320
+ module.exports.ArrowDataType = ArrowDataType
321
+ module.exports.ZerobusArrowStream = ZerobusArrowStream
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databricks/zerobus-ingest-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "TypeScript/Node.js SDK for streaming data ingestion into Databricks Delta tables using Zerobus",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -76,11 +76,11 @@
76
76
  "example:arrow": "tsx examples/arrow/batch.ts"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@databricks/zerobus-ingest-sdk-linux-x64-gnu": "1.2.0",
80
- "@databricks/zerobus-ingest-sdk-linux-arm64-gnu": "1.2.0",
81
- "@databricks/zerobus-ingest-sdk-win32-x64-msvc": "1.2.0",
82
- "@databricks/zerobus-ingest-sdk-darwin-x64": "1.2.0",
83
- "@databricks/zerobus-ingest-sdk-darwin-arm64": "1.2.0"
79
+ "@databricks/zerobus-ingest-sdk-linux-x64-gnu": "1.3.0",
80
+ "@databricks/zerobus-ingest-sdk-linux-arm64-gnu": "1.3.0",
81
+ "@databricks/zerobus-ingest-sdk-win32-x64-msvc": "1.3.0",
82
+ "@databricks/zerobus-ingest-sdk-darwin-x64": "1.3.0",
83
+ "@databricks/zerobus-ingest-sdk-darwin-arm64": "1.3.0"
84
84
  },
85
85
  "dependencies": {
86
86
  "protobufjs": "^8.7.1"
package/src/lib.rs CHANGED
@@ -214,8 +214,9 @@ fn convert_js_to_record_payload(env: &Env, payload: Unknown) -> Result<RustRecor
214
214
 
215
215
  /// A stream for ingesting data into a Databricks Delta table.
216
216
  ///
217
- /// The stream manages a bidirectional gRPC connection, handles acknowledgments,
218
- /// and provides automatic recovery on transient failures.
217
+ /// The stream manages JSON or Protocol Buffer ingestion over a bidirectional
218
+ /// gRPC connection, handles acknowledgments, and provides automatic recovery
219
+ /// on transient failures.
219
220
  ///
220
221
  /// # Example
221
222
  ///
@@ -926,7 +927,7 @@ impl ZerobusSdk {
926
927
 
927
928
  /// Creates a new ingestion stream to a Delta table.
928
929
  ///
929
- /// This method establishes a bidirectional gRPC connection to the Zerobus service
930
+ /// This method opens a JSON or Protocol Buffer stream to the Zerobus service
930
931
  /// and prepares it for data ingestion. By default, it uses OAuth 2.0 Client Credentials
931
932
  /// authentication. For custom authentication (e.g., Personal Access Tokens), provide
932
933
  /// a custom headers_provider.
@@ -1181,8 +1182,8 @@ fn base64_decode(input: &str) -> std::result::Result<Vec<u8>, String> {
1181
1182
  }
1182
1183
 
1183
1184
  // =============================================================================
1184
- // Arrow Flight Support (Beta)
1185
- // Enabled with feature flag: cargo build --features arrow-flight
1185
+ // Arrow Flight support
1186
+ // Behind the arrow-flight feature. Enable with: npm run build:arrow
1186
1187
  // =============================================================================
1187
1188
 
1188
1189
  #[cfg(feature = "arrow-flight")]
@@ -1197,8 +1198,6 @@ use databricks_zerobus_ingest_sdk::{
1197
1198
 
1198
1199
  /// IPC compression type for Arrow Flight streams.
1199
1200
  ///
1200
- /// **Beta**: Arrow Flight support is in Beta. The API is stabilising but
1201
- /// may still change before reaching GA.
1202
1201
  #[cfg(feature = "arrow-flight")]
1203
1202
  #[napi]
1204
1203
  pub enum IpcCompressionType {
@@ -1210,8 +1209,6 @@ pub enum IpcCompressionType {
1210
1209
 
1211
1210
  /// Configuration options for Arrow Flight streams.
1212
1211
  ///
1213
- /// **Beta**: Arrow Flight support is in Beta. The API is stabilising but
1214
- /// may still change before reaching GA.
1215
1212
  #[cfg(feature = "arrow-flight")]
1216
1213
  #[napi(object)]
1217
1214
  #[derive(Debug, Clone)]
@@ -1268,7 +1265,6 @@ fn map_ipc_compression(value: Option<i32>) -> Option<arrow_ipc::CompressionType>
1268
1265
 
1269
1266
  /// Arrow data type enum for schema definition.
1270
1267
  ///
1271
- /// **Beta**: Arrow Flight support is in Beta.
1272
1268
  #[cfg(feature = "arrow-flight")]
1273
1269
  #[napi]
1274
1270
  pub enum ArrowDataType {
@@ -1340,7 +1336,6 @@ fn convert_arrow_data_type(dt: i32) -> RustDataType {
1340
1336
 
1341
1337
  /// Arrow field definition for schema.
1342
1338
  ///
1343
- /// **Beta**: Arrow Flight support is in Beta.
1344
1339
  #[cfg(feature = "arrow-flight")]
1345
1340
  #[napi(object)]
1346
1341
  #[derive(Debug, Clone)]
@@ -1358,8 +1353,6 @@ pub struct ArrowField {
1358
1353
  /// Unlike `TableProperties` which uses Protocol Buffers, Arrow Flight streams
1359
1354
  /// require an Arrow schema definition.
1360
1355
  ///
1361
- /// **Beta**: Arrow Flight support is in Beta. The API is stabilising but
1362
- /// may still change before reaching GA.
1363
1356
  #[cfg(feature = "arrow-flight")]
1364
1357
  #[napi(object)]
1365
1358
  #[derive(Debug, Clone)]
@@ -1393,9 +1386,6 @@ fn build_arrow_schema(fields: &[ArrowField]) -> Arc<RustArrowSchema> {
1393
1386
  /// This stream provides a high-performance interface for streaming Arrow data
1394
1387
  /// to Databricks Delta tables using the Arrow Flight protocol.
1395
1388
  ///
1396
- /// **Beta**: Arrow Flight support is in Beta. The API is stabilising but
1397
- /// may still change before reaching GA.
1398
- ///
1399
1389
  /// # Lifecycle
1400
1390
  ///
1401
1391
  /// 1. Create a stream via `sdk.createArrowStream()`
@@ -1617,9 +1607,6 @@ impl ZerobusArrowStream {
1617
1607
  impl ZerobusSdk {
1618
1608
  /// Creates a new Arrow Flight stream to a Delta table.
1619
1609
  ///
1620
- /// **Beta**: Arrow Flight support is in Beta. The API is stabilising
1621
- /// but may still change before reaching GA.
1622
- ///
1623
1610
  /// This method establishes an Arrow Flight connection to the Zerobus service
1624
1611
  /// for high-performance columnar data ingestion.
1625
1612
  ///
@@ -1733,8 +1720,6 @@ impl ZerobusSdk {
1733
1720
 
1734
1721
  /// Recreates an Arrow stream with the same configuration and re-ingests unacknowledged batches.
1735
1722
  ///
1736
- /// **Beta**: Arrow Flight support is in Beta.
1737
- ///
1738
1723
  /// # Arguments
1739
1724
  ///
1740
1725
  /// * `stream` - The terminally failed Arrow stream to recreate. The TypeScript wrapper