lakeql 0.1.2 → 0.1.8
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/bin.js +205 -81
- package/dist/{chunk-MUTXXFOW.js → chunk-5K5JMJ2M.js} +772 -131
- package/dist/chunk-MXGEAVHL.js +11381 -0
- package/dist/chunk-TFD5RFKB.js +1152 -0
- package/dist/cloudflare.d.ts +21 -5
- package/dist/cloudflare.js +105 -5
- package/dist/geo-backend-TSQJWAAB.js +18 -0
- package/dist/index.d.ts +842 -232
- package/dist/index.js +3 -2
- package/dist/node.d.ts +29 -7
- package/dist/node.js +195 -35
- package/package.json +13 -10
- package/dist/chunk-D3A4VN3U.js +0 -5677
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { IcebergRestCatalog, IcebergTable, IcebergUnsupportedCatalog, ObjectStoreIcebergCommitCatalog, PACKAGE, applyIcebergDeletes, icebergGlueCatalog, icebergNessieCatalog, icebergRestCatalog, loadIcebergTable, loadIcebergTableFromObjectStore, loadIcebergTableFromRest, loadTable, planFiles, scanBatches, scanPlannedIcebergRows, scanRows } from './chunk-
|
|
2
|
-
export { AggregationBuilder, CacheApiCache,
|
|
1
|
+
export { IcebergRestCatalog, IcebergTable, IcebergUnsupportedCatalog, InMemoryRowsScanner, InMemoryRowsStore, ObjectStoreIcebergCommitCatalog, ObjectStoreJsonCache, PACKAGE, applyIcebergDeletes, createInMemoryLake, icebergGlueCatalog, icebergNessieCatalog, icebergRestCatalog, inMemoryRowsScanner, loadIcebergTable, loadIcebergTableFromObjectStore, loadIcebergTableFromRest, loadTable, objectStoreJsonCache, planFiles, scanBatches, scanPlannedIcebergRows, scanRows, vectorHashJoin } from './chunk-5K5JMJ2M.js';
|
|
2
|
+
export { AggregationBuilder, CacheApiCache, Lake, MemoryCache, MemoryCheckpointAdapter, MemoryObjectStore, MemorySpillAdapter, ParquetScanAdapter, QueryBuilder, QueryResult, ResumedQuery, SharedMemoryCache, add, advanceTaskCheckpoint, aggregateParquetGroupTask, aggregateParquetGroupTasks, aggregateParquetGroupTasksBatch, aggregateParquetTask, aggregateParquetTasks, and, assertBookmarkMatches, asyncBufferFromStore, batchExprValues, batchFromColumns, batchFromVectors, bboxMayIntersect, between, broadcastJoin, buildBBoxIndex, buildMinMaxIndex, cacheApiCache, cachedObjectStore, classifyPredicate, col, concatBatches, createBookmark, createParquetLake as createLake, createOutputManifest, createOutputManifestFromCheckpoints, createParquetLake, createParquetTableAs, createTaskManifest, createVectorAggregateStates, createVectorGroupByState, deserializeAggregateOperatorState, deserializeSortOperatorState, deserializeTopKOperatorState, div, enforceVectorGroupByBudget, eq, fanInWorkUnits, finalizeVectorAggregateStates, finalizeVectorGroupByBatch, finalizeVectorGroupByRows, fingerprint, fn, gatherBatch, getOrCreateVectorGroup, gt, gte, ilike, isIn, isNotNull, isNull, jsonWorkUnitBoundary, like, lit, lookupJoin, lt, lte, materializeBatchRows, materializeSelectedBatchRows, memoryCache, memoryCheckpointAdapter, memorySpillAdapter, memoryStore, mergeVectorAggregateStateSnapshots, mergeVectorAggregateStates, mergeVectorGroupByStates, mod, mul, ne, not, notIn, or, parquetScanner, parseHivePartitions, parseJsonQuery, partitionedParquetOutputEntries, planParquetTaskWorkUnits, planRowGroups, planRowGroupsFromMetadata, predicateSelection, pruneFilesWithIndex, readControlSignal, readIcebergParquetDeletes, readOutputManifest, readParquetColumnBatches, readParquetMetadata, readParquetObjectBatches, readParquetObjects, rejectUnsupportedParquetSchema, restoreVectorAggregateStates, restoreVectorGroupByState, rowGroupMayMatch, rowGroupMustMatch, scalarVectorValue, scanParquetTaskBatches, scanParquetTaskColumnBatches, selectedRowCount, selectedRowIndices, serializeAggregateOperatorState, serializeSortOperatorState, serializeTopKOperatorState, signPaginationToken, snapshotVectorAggregateStates, snapshotVectorGroupByState, stableStringify, sub, throwIfAborted, transitionTaskCheckpoint, tryPredicateSelection, updateVectorAggregateStateValue, updateVectorAggregateStates, updateVectorGroupAggregateValue, updateVectorGroupByState, uriObjectStore, vectorAggregateBatch, vectorFromValues, vectorGroupByBatch, vectorLength, vectorOrderByBatch, vectorProjectBatch, vectorSortIndices, vectorTopKBatch, vectorTopKIndices, vectorValue, verifyPaginationToken, withObjectStoreReadControls, writeOutputManifest, writeParquet, writePartitionedParquet, writePartitionedParquetTask } from './chunk-MXGEAVHL.js';
|
|
3
|
+
export { ERROR_CODES, LakeqlError, TimestampValue, bboxIntersects, compareTimestampValues, encodeJsonLine, ensureGeoBackendForExprs, envelopeFromGeometry, envelopeOf, evaluate, isLakeqlError, isTimestampValue, jsonSafeValue, loadGeoBackend, matches, parseGeometry, requireGeoBackend, setGeoBackend, timestampEpochForUnit, timestampFromEpoch, timestampToIsoString, timestampValueFromIso, toGeometry } from './chunk-TFD5RFKB.js';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { ObjectInfo, ObjectStore, ConditionalObjectStore } from './index.js';
|
|
2
|
-
export { AggregateExpr, AggregateGroupSnapshot, AggregateOp, AggregateOperatorState, AggregateOptions, AggregateResult, AggregateSnapshotValue, AggregateSpec, AggregateStateSnapshot, AggregationBuilder, ApplyIcebergDeletesOptions, ArithmeticExpr, BBoxIndex, BetweenExpr, Bookmark, BookmarkInit, BookmarkPosition, BookmarkQuery, BroadcastJoinOptions,
|
|
3
|
-
import 'hyparquet/src/types.js';
|
|
4
|
-
import 'hyparquet';
|
|
1
|
+
import { CacheAdapter, ObjectInfo, ObjectStore, ConditionalObjectStore } from './index.js';
|
|
2
|
+
export { AggregateExpr, AggregateGroupSnapshot, AggregateOp, AggregateOperatorState, AggregateOptions, AggregateParquetGroupTaskOptions, AggregateParquetGroupTasksOptions, AggregateParquetTaskOptions, AggregateParquetTasksOptions, AggregateResult, AggregateSnapshotValue, AggregateSpec, AggregateStateSnapshot, AggregationBuilder, ApplyIcebergDeletesOptions, ArithmeticExpr, BBox, BBoxIndex, Batch, BatchExprValues, BetweenExpr, Bookmark, BookmarkInit, BookmarkPosition, BookmarkQuery, BroadcastJoinOptions, CacheApiCache, CacheApiCacheOptions, CacheEntry, CachePolicy, CallExpr, CaseExpr, CaseWhenExpr, CheckpointAdapter, CheckpointStore, Clock, ColumnExpr, ColumnInput, CompareExpr, CompareOp, ConditionalPutOptions, CreateParquetTableAsOptions, CreateParquetTableAsQuery, CreateParquetTableAsResult, CsvStreamOptions, DecodedIcebergDeletes, DecodedIcebergParquetDeletes, ERROR_CODES, EngineFilePlan, EngineTable, ErrorDetails, ExplainJson, ExplainResult, Expr, GeoBackend, GeoJsonGeometry, IcebergAppendFile, IcebergAppendOptions, IcebergAppendOutputManifestOptions, IcebergAppendResult, IcebergCatalog, IcebergCommitCatalog, IcebergCommitInput, IcebergCommitResult, IcebergDeleteFile, IcebergDeletionVector, IcebergEnginePlan, IcebergEngineTable, IcebergEqualityDelete, IcebergField, IcebergGlueCatalogOptions, IcebergLoadTableOptions, IcebergNessieCatalogOptions, IcebergParquetDeleteFile, IcebergParquetDeleteFileContent, IcebergPartitionField, IcebergPartitionSpec, IcebergPlan, IcebergPositionDelete, IcebergReadMode, IcebergRestAccessDelegation, IcebergRestCatalog, IcebergRestCatalogConfig, IcebergRestCatalogOptions, IcebergRestLoadContext, IcebergRestLoadTableOptions, IcebergRestLoadTableResult, IcebergRestStorageCredential, IcebergRowBatch, IcebergSortOrder, IcebergTable, IcebergTableIdentifier, IcebergUnsupportedCatalog, IdGenerator, InExpr, InMemoryLakeOptions, InMemoryRowsScanner, InMemoryRowsStore, InMemoryTableOptions, IndexPruneResult, IndexValue, InsertValidationRules, JoinKey, JoinType, JsonExpr, JsonOrderByTerm, JsonQueryV1, Lake, LakeConfig, LakeqlError, LakeqlErrorCode, LikeExpr, ListOptions, LiteralExpr, LoadIcebergEngineTableOptions, LoadIcebergTableFromObjectStoreOptions, LoadIcebergTableFromRestOptions, LoadIcebergTableOptions, LoadParquetEngineTableOptions, LoadTableOptions, LockAdapter, LogHook, LogicalExpr, LookupJoinFunction, LookupJoinOptions, Manifest, ManifestDeleteFile, ManifestFile, MemoryCache, MemoryCheckpointAdapter, MemoryObjectStore, MemorySpillAdapter, MemorySpillAdapterOptions, MetadataFile, MetricsHook, MinMaxColumnIndex, NotExpr, NullCheckExpr, ObjectHead, ObjectStoreCacheOptions, ObjectStoreIcebergCommitCatalog, ObjectStoreJsonCache, ObjectStoreJsonCacheOptions, ObjectStoreReadControls, ObjectStoreUriAuthority, OperatorSnapshotValue, OrderByTerm, OutputManifest, OutputManifestEntry, PACKAGE, ParquetColumnBatch, ParquetEnginePlan, ParquetEngineTable, ParquetLakeConfig, ParquetMetadata, ParquetRowBatch, ParquetRowGroupPlan, ParquetScanAdapter, PartitionedParquetOutputEntryOptions, PathQueryInit, PlanIcebergFilesOptions, PlanParquetRowGroupsOptions, PlanParquetTaskWorkUnitsOptions, PlannedIcebergFile, PlannedParquetRowGroup, PredicatePlan, PredicatePlanOptions, ProjectIcebergRowOptions, PutOptions, QueryBudget, QueryBuilder, QueryPolicy, QueryPolicyContext, QueryResult, QueryRunOptions, QueryStats, QueueAdapter, ReadParquetBatchOptions, ReadParquetOptions, ResumableBatchOptions, ResumedQuery, Row, RuntimeSubstrate, Scalar, ScanAdapter, ScanBatch, ScanColumnBatch, ScanEngineOptions, ScanOptions, ScanParquetTaskOptions, ScanPlannedIcebergRowsOptions, ScanTaskPlan, ScanTaskPlanOptions, ScanVectorBatch, Selection, SharedCacheEntry, SharedCacheSetOptions, SharedMemoryCache, SidecarFileIndex, SliceOptions, SliceResult, Snapshot, SortOperatorState, SortOptions, SortResult, SortRunState, SpillAdapter, SpillRef, SpillUsage, SqlBoolean, TaskCheckpoint, TaskInput, TaskManifest, TaskManifestTask, TaskState, TaskTransitionInput, TimestampUnit, TimestampValue, TopKOperatorState, TopKOptions, TopKResult, ValueInput, Vector, VectorAggregateOptions, VectorAggregateSnapshotValue, VectorAggregateState, VectorAggregateStateSnapshot, VectorAggregateStateSnapshots, VectorAggregateStates, VectorAggregateValue, VectorGroup, VectorGroupByGroupSnapshot, VectorGroupByOptions, VectorGroupBySnapshotValue, VectorGroupByState, VectorGroupByStateSnapshot, VectorHashJoinOptions, VectorProjectionSpec, VectorTopKOptions, WorkUnitFanInOptions, WriteParquetOptions, WriteParquetRowsOptions, WritePartitionedParquetFile, WritePartitionedParquetResult, WritePartitionedParquetTaskOptions, WritePartitionedParquetTaskResult, add, advanceTaskCheckpoint, aggregateParquetGroupTask, aggregateParquetGroupTasks, aggregateParquetGroupTasksBatch, aggregateParquetTask, aggregateParquetTasks, and, applyIcebergDeletes, assertBookmarkMatches, asyncBufferFromStore, batchExprValues, batchFromColumns, batchFromVectors, bboxIntersects, bboxMayIntersect, between, broadcastJoin, buildBBoxIndex, buildMinMaxIndex, cacheApiCache, cachedObjectStore, classifyPredicate, col, compareTimestampValues, concatBatches, createBookmark, createInMemoryLake, createLake, createOutputManifest, createOutputManifestFromCheckpoints, createLake as createParquetLake, createParquetTableAs, createTaskManifest, createVectorAggregateStates, createVectorGroupByState, deserializeAggregateOperatorState, deserializeSortOperatorState, deserializeTopKOperatorState, div, encodeJsonLine, enforceVectorGroupByBudget, ensureGeoBackendForExprs, envelopeFromGeometry, envelopeOf, eq, evaluate, fanInWorkUnits, finalizeVectorAggregateStates, finalizeVectorGroupByBatch, finalizeVectorGroupByRows, fingerprint, fn, gatherBatch, getOrCreateVectorGroup, gt, gte, icebergGlueCatalog, icebergNessieCatalog, icebergRestCatalog, ilike, inMemoryRowsScanner, isIn, isLakeqlError, isNotNull, isNull, isTimestampValue, jsonSafeValue, jsonWorkUnitBoundary, like, lit, loadGeoBackend, loadIcebergTable, loadIcebergTableFromObjectStore, loadIcebergTableFromRest, loadTable, lookupJoin, lt, lte, matches, materializeBatchRows, materializeSelectedBatchRows, memoryCache, memoryCheckpointAdapter, memorySpillAdapter, memoryStore, mergeVectorAggregateStateSnapshots, mergeVectorAggregateStates, mergeVectorGroupByStates, mod, mul, ne, not, notIn, objectStoreJsonCache, or, parquetScanner, parseGeometry, parseHivePartitions, parseJsonQuery, partitionedParquetOutputEntries, planFiles, planParquetTaskWorkUnits, planRowGroups, planRowGroupsFromMetadata, predicateSelection, pruneFilesWithIndex, readControlSignal, readIcebergParquetDeletes, readOutputManifest, readParquetColumnBatches, readParquetMetadata, readParquetObjectBatches, readParquetObjects, rejectUnsupportedParquetSchema, requireGeoBackend, restoreVectorAggregateStates, restoreVectorGroupByState, rowGroupMayMatch, rowGroupMustMatch, scalarVectorValue, scanBatches, scanParquetTaskBatches, scanParquetTaskColumnBatches, scanPlannedIcebergRows, scanRows, selectedRowCount, selectedRowIndices, serializeAggregateOperatorState, serializeSortOperatorState, serializeTopKOperatorState, setGeoBackend, signPaginationToken, snapshotVectorAggregateStates, snapshotVectorGroupByState, stableStringify, sub, throwIfAborted, timestampEpochForUnit, timestampFromEpoch, timestampToIsoString, timestampValueFromIso, toGeometry, transitionTaskCheckpoint, tryPredicateSelection, updateVectorAggregateStateValue, updateVectorAggregateStates, updateVectorGroupAggregateValue, updateVectorGroupByState, uriObjectStore, vectorAggregateBatch, vectorFromValues, vectorGroupByBatch, vectorHashJoin, vectorLength, vectorOrderByBatch, vectorProjectBatch, vectorSortIndices, vectorTopKBatch, vectorTopKIndices, vectorValue, verifyPaginationToken, withObjectStoreReadControls, writeOutputManifest, writeParquet, writePartitionedParquet, writePartitionedParquetTask } from './index.js';
|
|
5
3
|
import 'hyparquet-writer';
|
|
4
|
+
import 'hyparquet';
|
|
5
|
+
|
|
6
|
+
interface FsJsonCacheOptions {
|
|
7
|
+
root: string;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
space?: number;
|
|
12
|
+
}
|
|
13
|
+
declare function fsJsonCache<T = unknown>(options: FsJsonCacheOptions): CacheAdapter<T>;
|
|
6
14
|
|
|
7
15
|
interface HttpStoreOptions {
|
|
8
16
|
baseUrl: string;
|
|
@@ -12,16 +20,30 @@ interface HttpStoreOptions {
|
|
|
12
20
|
}
|
|
13
21
|
declare function httpStore(options: HttpStoreOptions): ObjectStore;
|
|
14
22
|
|
|
23
|
+
interface S3Credentials {
|
|
24
|
+
accessKeyId: string;
|
|
25
|
+
secretAccessKey: string;
|
|
26
|
+
sessionToken?: string;
|
|
27
|
+
expiresAt?: Date;
|
|
28
|
+
}
|
|
29
|
+
type S3CredentialsProvider = () => S3Credentials | Promise<S3Credentials>;
|
|
15
30
|
interface S3StoreOptions {
|
|
16
31
|
endpoint: string;
|
|
17
32
|
bucket: string;
|
|
18
33
|
region: string;
|
|
19
|
-
accessKeyId
|
|
20
|
-
secretAccessKey
|
|
34
|
+
accessKeyId?: string;
|
|
35
|
+
secretAccessKey?: string;
|
|
21
36
|
sessionToken?: string;
|
|
37
|
+
credentials?: S3CredentialsProvider;
|
|
38
|
+
credentialRefreshWindowMs?: number;
|
|
22
39
|
fetch?: typeof fetch;
|
|
23
40
|
now?: () => Date;
|
|
24
41
|
}
|
|
42
|
+
interface S3JsonCacheOptions extends S3StoreOptions {
|
|
43
|
+
prefix: string;
|
|
44
|
+
ttlMs?: number;
|
|
45
|
+
}
|
|
25
46
|
declare function s3Store(options: S3StoreOptions): ConditionalObjectStore;
|
|
47
|
+
declare function s3JsonCache<T = unknown>(options: S3JsonCacheOptions): CacheAdapter<T>;
|
|
26
48
|
|
|
27
|
-
export { ConditionalObjectStore, ObjectInfo, ObjectStore, httpStore, s3Store };
|
|
49
|
+
export { CacheAdapter, ConditionalObjectStore, ObjectInfo, ObjectStore, fsJsonCache, httpStore, s3JsonCache, s3Store };
|
package/dist/node.js
CHANGED
|
@@ -1,9 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { AggregationBuilder, CacheApiCache,
|
|
1
|
+
import { objectStoreJsonCache } from './chunk-5K5JMJ2M.js';
|
|
2
|
+
export { IcebergRestCatalog, IcebergTable, IcebergUnsupportedCatalog, InMemoryRowsScanner, InMemoryRowsStore, ObjectStoreIcebergCommitCatalog, ObjectStoreJsonCache, PACKAGE, applyIcebergDeletes, createInMemoryLake, icebergGlueCatalog, icebergNessieCatalog, icebergRestCatalog, inMemoryRowsScanner, loadIcebergTable, loadIcebergTableFromObjectStore, loadIcebergTableFromRest, loadTable, objectStoreJsonCache, planFiles, scanBatches, scanPlannedIcebergRows, scanRows, vectorHashJoin } from './chunk-5K5JMJ2M.js';
|
|
3
|
+
export { AggregationBuilder, CacheApiCache, Lake, MemoryCache, MemoryCheckpointAdapter, MemoryObjectStore, MemorySpillAdapter, ParquetScanAdapter, QueryBuilder, QueryResult, ResumedQuery, SharedMemoryCache, add, advanceTaskCheckpoint, aggregateParquetGroupTask, aggregateParquetGroupTasks, aggregateParquetGroupTasksBatch, aggregateParquetTask, aggregateParquetTasks, and, assertBookmarkMatches, asyncBufferFromStore, batchExprValues, batchFromColumns, batchFromVectors, bboxMayIntersect, between, broadcastJoin, buildBBoxIndex, buildMinMaxIndex, cacheApiCache, cachedObjectStore, classifyPredicate, col, concatBatches, createBookmark, createParquetLake as createLake, createOutputManifest, createOutputManifestFromCheckpoints, createParquetLake, createParquetTableAs, createTaskManifest, createVectorAggregateStates, createVectorGroupByState, deserializeAggregateOperatorState, deserializeSortOperatorState, deserializeTopKOperatorState, div, enforceVectorGroupByBudget, eq, fanInWorkUnits, finalizeVectorAggregateStates, finalizeVectorGroupByBatch, finalizeVectorGroupByRows, fingerprint, fn, gatherBatch, getOrCreateVectorGroup, gt, gte, ilike, isIn, isNotNull, isNull, jsonWorkUnitBoundary, like, lit, lookupJoin, lt, lte, materializeBatchRows, materializeSelectedBatchRows, memoryCache, memoryCheckpointAdapter, memorySpillAdapter, memoryStore, mergeVectorAggregateStateSnapshots, mergeVectorAggregateStates, mergeVectorGroupByStates, mod, mul, ne, not, notIn, or, parquetScanner, parseHivePartitions, parseJsonQuery, partitionedParquetOutputEntries, planParquetTaskWorkUnits, planRowGroups, planRowGroupsFromMetadata, predicateSelection, pruneFilesWithIndex, readControlSignal, readIcebergParquetDeletes, readOutputManifest, readParquetColumnBatches, readParquetMetadata, readParquetObjectBatches, readParquetObjects, rejectUnsupportedParquetSchema, restoreVectorAggregateStates, restoreVectorGroupByState, rowGroupMayMatch, rowGroupMustMatch, scalarVectorValue, scanParquetTaskBatches, scanParquetTaskColumnBatches, selectedRowCount, selectedRowIndices, serializeAggregateOperatorState, serializeSortOperatorState, serializeTopKOperatorState, signPaginationToken, snapshotVectorAggregateStates, snapshotVectorGroupByState, stableStringify, sub, throwIfAborted, transitionTaskCheckpoint, tryPredicateSelection, updateVectorAggregateStateValue, updateVectorAggregateStates, updateVectorGroupAggregateValue, updateVectorGroupByState, uriObjectStore, vectorAggregateBatch, vectorFromValues, vectorGroupByBatch, vectorLength, vectorOrderByBatch, vectorProjectBatch, vectorSortIndices, vectorTopKBatch, vectorTopKIndices, vectorValue, verifyPaginationToken, withObjectStoreReadControls, writeOutputManifest, writeParquet, writePartitionedParquet, writePartitionedParquetTask } from './chunk-MXGEAVHL.js';
|
|
4
|
+
import { LakeqlError } from './chunk-TFD5RFKB.js';
|
|
5
|
+
export { ERROR_CODES, LakeqlError, TimestampValue, bboxIntersects, compareTimestampValues, encodeJsonLine, ensureGeoBackendForExprs, envelopeFromGeometry, envelopeOf, evaluate, isLakeqlError, isTimestampValue, jsonSafeValue, loadGeoBackend, matches, parseGeometry, requireGeoBackend, setGeoBackend, timestampEpochForUnit, timestampFromEpoch, timestampToIsoString, timestampValueFromIso, toGeometry } from './chunk-TFD5RFKB.js';
|
|
6
|
+
import { readFile, mkdir, writeFile, rm } from 'fs/promises';
|
|
7
|
+
import { join } from 'path';
|
|
4
8
|
import { AwsClient } from 'aws4fetch';
|
|
5
9
|
import { XMLParser } from 'fast-xml-parser';
|
|
6
10
|
|
|
11
|
+
function fsJsonCache(options) {
|
|
12
|
+
return new FsJsonCache(options);
|
|
13
|
+
}
|
|
14
|
+
var FsJsonCache = class {
|
|
15
|
+
root;
|
|
16
|
+
prefix;
|
|
17
|
+
ttlMs;
|
|
18
|
+
now;
|
|
19
|
+
space;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.root = options.root;
|
|
22
|
+
this.prefix = normalizedPrefix(options.prefix ?? "lakeql");
|
|
23
|
+
this.ttlMs = options.ttlMs;
|
|
24
|
+
this.now = options.now ?? Date.now;
|
|
25
|
+
this.space = options.space;
|
|
26
|
+
}
|
|
27
|
+
async get(key) {
|
|
28
|
+
const path = this.pathFor(key);
|
|
29
|
+
let bytes;
|
|
30
|
+
try {
|
|
31
|
+
bytes = await readFile(path);
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
if (isNodeError(cause) && cause.code === "ENOENT")
|
|
34
|
+
return void 0;
|
|
35
|
+
throw cause;
|
|
36
|
+
}
|
|
37
|
+
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
38
|
+
if (!isStoredFsJsonCacheEntry(parsed)) {
|
|
39
|
+
throw new LakeqlError("LAKEQL_CATALOG_ERROR", `Invalid filesystem cache entry at ${path}`, {
|
|
40
|
+
path
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (parsed.expiresAt !== void 0 && parsed.expiresAt <= this.now()) {
|
|
44
|
+
await this.delete(key);
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
const entry = { value: parsed.value };
|
|
48
|
+
if (parsed.expiresAt !== void 0)
|
|
49
|
+
entry.expiresAt = parsed.expiresAt;
|
|
50
|
+
return entry;
|
|
51
|
+
}
|
|
52
|
+
async set(key, entry) {
|
|
53
|
+
const path = this.pathFor(key);
|
|
54
|
+
await mkdir(join(this.root, this.prefix), { recursive: true });
|
|
55
|
+
const stored = { value: entry.value };
|
|
56
|
+
if (entry.expiresAt !== void 0) {
|
|
57
|
+
stored.expiresAt = entry.expiresAt;
|
|
58
|
+
} else if (this.ttlMs !== void 0) {
|
|
59
|
+
stored.expiresAt = this.now() + this.ttlMs;
|
|
60
|
+
}
|
|
61
|
+
await writeFile(path, jsonCacheValue(stored, key, this.space));
|
|
62
|
+
}
|
|
63
|
+
async delete(key) {
|
|
64
|
+
await rm(this.pathFor(key), { force: true });
|
|
65
|
+
}
|
|
66
|
+
pathFor(key) {
|
|
67
|
+
if (key.length === 0) {
|
|
68
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", "filesystem cache key must not be empty");
|
|
69
|
+
}
|
|
70
|
+
return join(this.root, this.prefix, `${encodeURIComponent(key)}.json`);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function normalizedPrefix(prefix) {
|
|
74
|
+
const parts = prefix.split("/").filter((part) => part.length > 0);
|
|
75
|
+
if (parts.length === 0 || parts.some((part) => part === "." || part === "..")) {
|
|
76
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", "filesystem cache prefix must be relative", {
|
|
77
|
+
prefix
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return parts.join("/");
|
|
81
|
+
}
|
|
82
|
+
function isStoredFsJsonCacheEntry(value) {
|
|
83
|
+
return typeof value === "object" && value !== null && "value" in value;
|
|
84
|
+
}
|
|
85
|
+
function jsonCacheValue(value, key, space) {
|
|
86
|
+
if (value.value === void 0) {
|
|
87
|
+
throw new LakeqlError("LAKEQL_TYPE_ERROR", "filesystem JSON cache value is not JSON serializable", { key });
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const json = JSON.stringify(value, void 0, space);
|
|
91
|
+
if (json === void 0) {
|
|
92
|
+
throw new LakeqlError("LAKEQL_TYPE_ERROR", "filesystem JSON cache value is not JSON serializable", { key });
|
|
93
|
+
}
|
|
94
|
+
return json;
|
|
95
|
+
} catch (cause) {
|
|
96
|
+
if (cause instanceof LakeqlError)
|
|
97
|
+
throw cause;
|
|
98
|
+
throw new LakeqlError("LAKEQL_TYPE_ERROR", "filesystem JSON cache value is not JSON serializable", {
|
|
99
|
+
key,
|
|
100
|
+
cause
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function isNodeError(value) {
|
|
105
|
+
return value instanceof Error && "code" in value;
|
|
106
|
+
}
|
|
107
|
+
|
|
7
108
|
// ../http/dist/index.js
|
|
8
109
|
function httpStore(options) {
|
|
9
110
|
return new HttpObjectStore(options);
|
|
@@ -28,7 +129,10 @@ var HttpObjectStore = class {
|
|
|
28
129
|
}
|
|
29
130
|
async getRange(path, range) {
|
|
30
131
|
if (range.offset < 0 || range.length < 0) {
|
|
31
|
-
throw new
|
|
132
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `Invalid range for ${path}`, {
|
|
133
|
+
path,
|
|
134
|
+
range
|
|
135
|
+
});
|
|
32
136
|
}
|
|
33
137
|
const response = await this.fetchPath(path, {
|
|
34
138
|
method: "GET",
|
|
@@ -54,7 +158,7 @@ var HttpObjectStore = class {
|
|
|
54
158
|
}
|
|
55
159
|
async *list(prefix, options) {
|
|
56
160
|
if (!this.objects) {
|
|
57
|
-
throw new
|
|
161
|
+
throw new LakeqlError("LAKEQL_UNSUPPORTED_PUSHDOWN", "HTTP store list requires an object index", {
|
|
58
162
|
prefix
|
|
59
163
|
});
|
|
60
164
|
}
|
|
@@ -79,7 +183,7 @@ var HttpObjectStore = class {
|
|
|
79
183
|
const contentLength = response.headers.get("content-length");
|
|
80
184
|
const size = total ?? (contentLength ? Number(contentLength) : Number.NaN);
|
|
81
185
|
if (!Number.isFinite(size)) {
|
|
82
|
-
throw new
|
|
186
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `Missing size for ${path}`, { path });
|
|
83
187
|
}
|
|
84
188
|
const head = { size };
|
|
85
189
|
const etag = response.headers.get("etag");
|
|
@@ -105,7 +209,7 @@ var HttpObjectStore = class {
|
|
|
105
209
|
const base = new URL(this.baseUrl);
|
|
106
210
|
const url = new URL(encodeObjectPath(path), base);
|
|
107
211
|
if (url.origin !== base.origin || !url.pathname.startsWith(base.pathname)) {
|
|
108
|
-
throw new
|
|
212
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path escapes HTTP base URL: ${path}`, {
|
|
109
213
|
path,
|
|
110
214
|
baseUrl: this.baseUrl
|
|
111
215
|
});
|
|
@@ -115,7 +219,7 @@ var HttpObjectStore = class {
|
|
|
115
219
|
};
|
|
116
220
|
function encodeObjectPath(path) {
|
|
117
221
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//iu.test(path) || path.startsWith("/")) {
|
|
118
|
-
throw new
|
|
222
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path must be relative: ${path}`, {
|
|
119
223
|
path
|
|
120
224
|
});
|
|
121
225
|
}
|
|
@@ -126,12 +230,12 @@ function encodeObjectPath(path) {
|
|
|
126
230
|
try {
|
|
127
231
|
decoded = decodeURIComponent(segment);
|
|
128
232
|
} catch {
|
|
129
|
-
throw new
|
|
233
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path has invalid encoding: ${path}`, {
|
|
130
234
|
path
|
|
131
235
|
});
|
|
132
236
|
}
|
|
133
237
|
if (decoded === "." || decoded === "..") {
|
|
134
|
-
throw new
|
|
238
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path contains traversal: ${path}`, {
|
|
135
239
|
path
|
|
136
240
|
});
|
|
137
241
|
}
|
|
@@ -151,9 +255,9 @@ function assertOk(response, path) {
|
|
|
151
255
|
if (response.ok || response.status === 206)
|
|
152
256
|
return;
|
|
153
257
|
if (response.status === 404) {
|
|
154
|
-
throw new
|
|
258
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `No object at ${path}`, { path });
|
|
155
259
|
}
|
|
156
|
-
throw new
|
|
260
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `HTTP object request failed for ${path}`, {
|
|
157
261
|
path,
|
|
158
262
|
status: response.status
|
|
159
263
|
});
|
|
@@ -169,25 +273,26 @@ function bodyInit(body) {
|
|
|
169
273
|
function s3Store(options) {
|
|
170
274
|
return new S3ObjectStore(options);
|
|
171
275
|
}
|
|
276
|
+
function s3JsonCache(options) {
|
|
277
|
+
return objectStoreJsonCache({
|
|
278
|
+
store: s3Store(options),
|
|
279
|
+
prefix: options.prefix,
|
|
280
|
+
...options.ttlMs !== void 0 ? { ttlMs: options.ttlMs } : {}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
172
283
|
var S3ObjectStore = class {
|
|
173
284
|
options;
|
|
174
285
|
fetchImpl;
|
|
175
286
|
now;
|
|
176
|
-
|
|
287
|
+
credentialsSnapshot;
|
|
288
|
+
credentialsPromise;
|
|
177
289
|
constructor(options) {
|
|
178
290
|
this.options = options;
|
|
179
291
|
this.fetchImpl = options.fetch ?? fetch;
|
|
180
292
|
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
region: options.region,
|
|
185
|
-
service: "s3",
|
|
186
|
-
retries: 0
|
|
187
|
-
};
|
|
188
|
-
if (options.sessionToken !== void 0)
|
|
189
|
-
awsOptions.sessionToken = options.sessionToken;
|
|
190
|
-
this.aws = new AwsClient(awsOptions);
|
|
293
|
+
if (options.credentials === void 0) {
|
|
294
|
+
this.credentialsSnapshot = staticCredentials(options);
|
|
295
|
+
}
|
|
191
296
|
}
|
|
192
297
|
async get(path) {
|
|
193
298
|
const response = await this.request("GET", path);
|
|
@@ -258,7 +363,7 @@ var S3ObjectStore = class {
|
|
|
258
363
|
assertOk2(response, path);
|
|
259
364
|
const contentLength = response.headers.get("content-length");
|
|
260
365
|
if (contentLength === null) {
|
|
261
|
-
throw new
|
|
366
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `Missing S3 content-length for ${path}`, {
|
|
262
367
|
path
|
|
263
368
|
});
|
|
264
369
|
}
|
|
@@ -282,19 +387,41 @@ var S3ObjectStore = class {
|
|
|
282
387
|
url,
|
|
283
388
|
headers,
|
|
284
389
|
region: this.options.region,
|
|
285
|
-
|
|
286
|
-
secretAccessKey: this.options.secretAccessKey,
|
|
390
|
+
...await this.currentCredentials(),
|
|
287
391
|
now: this.now()
|
|
288
392
|
};
|
|
289
|
-
if (this.options.sessionToken !== void 0)
|
|
290
|
-
signRequest.sessionToken = this.options.sessionToken;
|
|
291
393
|
const requestBody = body === void 0 ? void 0 : bodyInit2(body);
|
|
292
|
-
const signed = await signS3Request(signRequest,
|
|
394
|
+
const signed = await signS3Request(signRequest, void 0, requestBody);
|
|
293
395
|
const init = { method, headers: signed };
|
|
294
396
|
if (requestBody !== void 0)
|
|
295
397
|
init.body = requestBody;
|
|
296
398
|
return this.fetchImpl(url, init);
|
|
297
399
|
}
|
|
400
|
+
async currentCredentials() {
|
|
401
|
+
if (this.options.credentials === void 0) {
|
|
402
|
+
if (this.credentialsSnapshot === void 0)
|
|
403
|
+
this.credentialsSnapshot = staticCredentials(this.options);
|
|
404
|
+
return this.credentialsSnapshot;
|
|
405
|
+
}
|
|
406
|
+
if (this.credentialsSnapshot !== void 0 && !credentialsNeedRefresh(this.credentialsSnapshot, this.now(), this.credentialRefreshWindowMs())) {
|
|
407
|
+
return this.credentialsSnapshot;
|
|
408
|
+
}
|
|
409
|
+
if (this.credentialsPromise === void 0) {
|
|
410
|
+
this.credentialsPromise = Promise.resolve(this.options.credentials()).then((credentials) => {
|
|
411
|
+
const normalized = validateCredentials(credentials);
|
|
412
|
+
this.credentialsSnapshot = normalized;
|
|
413
|
+
this.credentialsPromise = void 0;
|
|
414
|
+
return normalized;
|
|
415
|
+
}).catch((cause) => {
|
|
416
|
+
this.credentialsPromise = void 0;
|
|
417
|
+
throw cause;
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
return await this.credentialsPromise;
|
|
421
|
+
}
|
|
422
|
+
credentialRefreshWindowMs() {
|
|
423
|
+
return this.options.credentialRefreshWindowMs ?? 3e5;
|
|
424
|
+
}
|
|
298
425
|
};
|
|
299
426
|
async function signS3Request(request, client = s3SignerClient(request), body) {
|
|
300
427
|
const headers = new Headers(request.headers);
|
|
@@ -325,6 +452,39 @@ function s3SignerClient(request) {
|
|
|
325
452
|
options.sessionToken = request.sessionToken;
|
|
326
453
|
return new AwsClient(options);
|
|
327
454
|
}
|
|
455
|
+
function staticCredentials(options) {
|
|
456
|
+
if (options.accessKeyId === void 0 || options.secretAccessKey === void 0) {
|
|
457
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", "S3 credentials are required", {
|
|
458
|
+
bucket: options.bucket
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return validateCredentials({
|
|
462
|
+
accessKeyId: options.accessKeyId,
|
|
463
|
+
secretAccessKey: options.secretAccessKey,
|
|
464
|
+
...options.sessionToken !== void 0 ? { sessionToken: options.sessionToken } : {}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function validateCredentials(credentials) {
|
|
468
|
+
const accessKeyId = credentials.accessKeyId.trim();
|
|
469
|
+
const secretAccessKey = credentials.secretAccessKey.trim();
|
|
470
|
+
if (accessKeyId === "" || secretAccessKey === "") {
|
|
471
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", "S3 credentials are required");
|
|
472
|
+
}
|
|
473
|
+
const normalized = {
|
|
474
|
+
accessKeyId,
|
|
475
|
+
secretAccessKey
|
|
476
|
+
};
|
|
477
|
+
if (credentials.sessionToken !== void 0)
|
|
478
|
+
normalized.sessionToken = credentials.sessionToken;
|
|
479
|
+
if (credentials.expiresAt !== void 0)
|
|
480
|
+
normalized.expiresAt = credentials.expiresAt;
|
|
481
|
+
return normalized;
|
|
482
|
+
}
|
|
483
|
+
function credentialsNeedRefresh(credentials, now, refreshWindowMs) {
|
|
484
|
+
if (credentials.expiresAt === void 0)
|
|
485
|
+
return false;
|
|
486
|
+
return credentials.expiresAt.getTime() - now.getTime() <= refreshWindowMs;
|
|
487
|
+
}
|
|
328
488
|
var listObjectsParser = new XMLParser({
|
|
329
489
|
ignoreAttributes: true,
|
|
330
490
|
parseTagValue: false,
|
|
@@ -372,7 +532,7 @@ function ensureSlash(value) {
|
|
|
372
532
|
}
|
|
373
533
|
function encodeObjectPath2(path) {
|
|
374
534
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//iu.test(path) || path.startsWith("/")) {
|
|
375
|
-
throw new
|
|
535
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path must be relative: ${path}`, {
|
|
376
536
|
path
|
|
377
537
|
});
|
|
378
538
|
}
|
|
@@ -383,12 +543,12 @@ function encodeObjectPath2(path) {
|
|
|
383
543
|
try {
|
|
384
544
|
decoded = decodeURIComponent(segment);
|
|
385
545
|
} catch {
|
|
386
|
-
throw new
|
|
546
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path has invalid encoding: ${path}`, {
|
|
387
547
|
path
|
|
388
548
|
});
|
|
389
549
|
}
|
|
390
550
|
if (decoded === "." || decoded === "..") {
|
|
391
|
-
throw new
|
|
551
|
+
throw new LakeqlError("LAKEQL_VALIDATION_ERROR", `Object path contains traversal: ${path}`, {
|
|
392
552
|
path
|
|
393
553
|
});
|
|
394
554
|
}
|
|
@@ -399,9 +559,9 @@ function assertOk2(response, path) {
|
|
|
399
559
|
if (response.ok || response.status === 206)
|
|
400
560
|
return;
|
|
401
561
|
if (response.status === 404) {
|
|
402
|
-
throw new
|
|
562
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `No object at ${path}`, { path });
|
|
403
563
|
}
|
|
404
|
-
throw new
|
|
564
|
+
throw new LakeqlError("LAKEQL_OBJECT_NOT_FOUND", `S3 request failed for ${path}`, {
|
|
405
565
|
path,
|
|
406
566
|
status: response.status
|
|
407
567
|
});
|
|
@@ -420,4 +580,4 @@ function arrayBuffer(bytes) {
|
|
|
420
580
|
return copy.buffer;
|
|
421
581
|
}
|
|
422
582
|
|
|
423
|
-
export { httpStore, s3Store };
|
|
583
|
+
export { fsJsonCache, httpStore, s3JsonCache, s3Store };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakeql",
|
|
3
|
-
"
|
|
3
|
+
"sideEffects": false,
|
|
4
|
+
"version": "0.1.8",
|
|
4
5
|
"description": "lakeql: lightweight TypeScript query engine for Iceberg + Parquet on object storage",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"lakehouse",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"repository": {
|
|
40
41
|
"type": "git",
|
|
41
42
|
"url": "https://github.com/earonesty/lakeql.git",
|
|
42
|
-
"directory": "packages/
|
|
43
|
+
"directory": "packages/lakeql"
|
|
43
44
|
},
|
|
44
45
|
"homepage": "https://lakeql.com",
|
|
45
46
|
"engines": {
|
|
@@ -54,20 +55,22 @@
|
|
|
54
55
|
"avsc": "^5.7.9",
|
|
55
56
|
"aws4fetch": "^1.0.20",
|
|
56
57
|
"fast-xml-parser": "^5.9.0",
|
|
58
|
+
"fzstd": "^0.1.1",
|
|
57
59
|
"h3-js": "^4.4.0",
|
|
58
60
|
"hyparquet": "^1.26.0",
|
|
59
61
|
"hyparquet-writer": "^0.15.6"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
62
64
|
"tsup": "^8.5.0",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
65
|
+
"lakeql-fixtures": "0.0.1",
|
|
66
|
+
"lakeql-core": "0.1.3",
|
|
67
|
+
"lakeql-fs": "0.0.2",
|
|
68
|
+
"lakeql-iceberg": "0.0.5",
|
|
69
|
+
"lakeql-parquet": "0.0.5",
|
|
70
|
+
"lakeql-http": "0.0.5",
|
|
71
|
+
"lakeql-r2": "0.0.5",
|
|
72
|
+
"lakeql-s3": "0.0.5",
|
|
73
|
+
"lakeql-sql": "0.0.5"
|
|
71
74
|
},
|
|
72
75
|
"scripts": {
|
|
73
76
|
"build": "tsup"
|