@cqlite/node 0.10.0 → 0.12.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/cqlite-node.darwin-arm64.node +0 -0
- package/cqlite-node.darwin-x64.node +0 -0
- package/cqlite-node.linux-arm64-gnu.node +0 -0
- package/cqlite-node.linux-x64-gnu.node +0 -0
- package/cqlite-node.win32-x64-msvc.node +0 -0
- package/lib/error-wrapper.js +30 -0
- package/lib/index.d.ts +61 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/error-wrapper.js
CHANGED
|
@@ -351,6 +351,36 @@ function createWrappedDatabase(NativeDatabase, wrapPreparedStatement) {
|
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Export the results of a CQL query to a Parquet file.
|
|
356
|
+
*
|
|
357
|
+
* The query runs with streaming, so large result sets are written
|
|
358
|
+
* within bounded memory. The export runs off the JavaScript main
|
|
359
|
+
* thread.
|
|
360
|
+
*
|
|
361
|
+
* @param {string} query - CQL SELECT statement to execute
|
|
362
|
+
* @param {string} path - Destination file path (created or truncated)
|
|
363
|
+
* @param {Object} [options] - Optional export options
|
|
364
|
+
* @param {number} [options.rowGroupSize=10000] - Rows per Parquet row group
|
|
365
|
+
* @param {string} [options.compression='snappy'] - 'snappy', 'zstd', or 'none'
|
|
366
|
+
* @returns {Promise<number>} Number of rows written
|
|
367
|
+
* @throws {CqliteError} If the query fails or the file cannot be written
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* const rows = await db.exportParquet(
|
|
371
|
+
* 'SELECT * FROM my_ks.my_table',
|
|
372
|
+
* '/tmp/out.parquet',
|
|
373
|
+
* { rowGroupSize: 5000, compression: 'zstd' }
|
|
374
|
+
* );
|
|
375
|
+
*/
|
|
376
|
+
async exportParquet(query, path, options) {
|
|
377
|
+
try {
|
|
378
|
+
return await this._native.exportParquet(query, path, options);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
throw enhanceError(error);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
354
384
|
/**
|
|
355
385
|
* Prepare a CQL query for analysis.
|
|
356
386
|
*
|
package/lib/index.d.ts
CHANGED
|
@@ -503,6 +503,30 @@ export interface StreamingConfig {
|
|
|
503
503
|
chunkSize?: number;
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Options for `Database.exportParquet()`.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* await db.exportParquet(query, '/tmp/out.parquet', {
|
|
512
|
+
* rowGroupSize: 5000,
|
|
513
|
+
* compression: 'zstd',
|
|
514
|
+
* });
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
export interface ParquetExportOptions {
|
|
518
|
+
/**
|
|
519
|
+
* Rows per Parquet row group.
|
|
520
|
+
* Smaller groups reduce memory at some I/O cost. Default: 10000.
|
|
521
|
+
*/
|
|
522
|
+
rowGroupSize?: number;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Compression codec: 'snappy' (default), 'zstd', or 'none'.
|
|
526
|
+
*/
|
|
527
|
+
compression?: 'snappy' | 'zstd' | 'none';
|
|
528
|
+
}
|
|
529
|
+
|
|
506
530
|
/**
|
|
507
531
|
* Streaming query result for memory-efficient processing.
|
|
508
532
|
*
|
|
@@ -956,6 +980,43 @@ export declare class Database {
|
|
|
956
980
|
*/
|
|
957
981
|
executeStreaming(query: string, config?: StreamingConfig): StreamingResult;
|
|
958
982
|
|
|
983
|
+
/**
|
|
984
|
+
* Export the results of a CQL query to a Parquet file.
|
|
985
|
+
*
|
|
986
|
+
* The query runs with streaming, so arbitrarily large result sets are
|
|
987
|
+
* written within bounded memory (rows are flushed to Parquet row groups
|
|
988
|
+
* as they arrive). The export runs as an async task off the JavaScript
|
|
989
|
+
* main thread.
|
|
990
|
+
*
|
|
991
|
+
* Types use the high-fidelity schema-driven Arrow mapping: date -> Date32,
|
|
992
|
+
* time -> Time64(ns), decimal/varint -> Decimal128, uuid ->
|
|
993
|
+
* FixedSizeBinary(16) with the Arrow UUID extension, list/set -> List,
|
|
994
|
+
* map -> Map, UDT/tuple -> Struct. CQLite produces Parquet files only;
|
|
995
|
+
* committing files to Iceberg/Delta table formats is out of scope.
|
|
996
|
+
*
|
|
997
|
+
* @param query - CQL SELECT statement to execute
|
|
998
|
+
* @param path - Destination file path (created or truncated)
|
|
999
|
+
* @param options - Optional row group size and compression
|
|
1000
|
+
* @returns Promise resolving to the number of rows written
|
|
1001
|
+
* @throws {CqliteError} code "CONFIG" for invalid options, "IO" for
|
|
1002
|
+
* file/encoding failures, "QUERY"/"PARSE" for query failures
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```typescript
|
|
1006
|
+
* const rows = await db.exportParquet(
|
|
1007
|
+
* 'SELECT * FROM my_ks.my_table',
|
|
1008
|
+
* '/tmp/out.parquet',
|
|
1009
|
+
* { rowGroupSize: 5000, compression: 'zstd' }
|
|
1010
|
+
* );
|
|
1011
|
+
* console.log(`Exported ${rows} row(s)`);
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
exportParquet(
|
|
1015
|
+
query: string,
|
|
1016
|
+
path: string,
|
|
1017
|
+
options?: ParquetExportOptions
|
|
1018
|
+
): Promise<number>;
|
|
1019
|
+
|
|
959
1020
|
/**
|
|
960
1021
|
* Prepare a CQL query for analysis.
|
|
961
1022
|
*
|
package/package.json
CHANGED