@dotdo/postgres 0.1.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/README.md +868 -0
- package/dist/cdc/change-stream.d.ts +44 -0
- package/dist/cdc/change-stream.d.ts.map +1 -0
- package/dist/cdc/change-stream.js +95 -0
- package/dist/cdc/change-stream.js.map +1 -0
- package/dist/cdc/filter.d.ts +58 -0
- package/dist/cdc/filter.d.ts.map +1 -0
- package/dist/cdc/filter.js +520 -0
- package/dist/cdc/filter.js.map +1 -0
- package/dist/cdc/index.d.ts +47 -0
- package/dist/cdc/index.d.ts.map +1 -0
- package/dist/cdc/index.js +50 -0
- package/dist/cdc/index.js.map +1 -0
- package/dist/cdc/resume-token.d.ts +60 -0
- package/dist/cdc/resume-token.d.ts.map +1 -0
- package/dist/cdc/resume-token.js +228 -0
- package/dist/cdc/resume-token.js.map +1 -0
- package/dist/cdc/transport/index.d.ts +7 -0
- package/dist/cdc/transport/index.d.ts.map +1 -0
- package/dist/cdc/transport/index.js +7 -0
- package/dist/cdc/transport/index.js.map +1 -0
- package/dist/cdc/transport/sse.d.ts +120 -0
- package/dist/cdc/transport/sse.d.ts.map +1 -0
- package/dist/cdc/transport/sse.js +590 -0
- package/dist/cdc/transport/sse.js.map +1 -0
- package/dist/cdc/transport/websocket.d.ts +130 -0
- package/dist/cdc/transport/websocket.d.ts.map +1 -0
- package/dist/cdc/transport/websocket.js +688 -0
- package/dist/cdc/transport/websocket.js.map +1 -0
- package/dist/cdc/types.d.ts +306 -0
- package/dist/cdc/types.d.ts.map +1 -0
- package/dist/cdc/types.js +8 -0
- package/dist/cdc/types.js.map +1 -0
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +25 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/memory.d.ts +139 -0
- package/dist/config/memory.d.ts.map +1 -0
- package/dist/config/memory.js +157 -0
- package/dist/config/memory.js.map +1 -0
- package/dist/config/storage.d.ts +157 -0
- package/dist/config/storage.d.ts.map +1 -0
- package/dist/config/storage.js +178 -0
- package/dist/config/storage.js.map +1 -0
- package/dist/config/streaming.d.ts +117 -0
- package/dist/config/streaming.d.ts.map +1 -0
- package/dist/config/streaming.js +132 -0
- package/dist/config/streaming.js.map +1 -0
- package/dist/config/timeouts.d.ts +168 -0
- package/dist/config/timeouts.d.ts.map +1 -0
- package/dist/config/timeouts.js +192 -0
- package/dist/config/timeouts.js.map +1 -0
- package/dist/extensions/config.d.ts +89 -0
- package/dist/extensions/config.d.ts.map +1 -0
- package/dist/extensions/config.js +216 -0
- package/dist/extensions/config.js.map +1 -0
- package/dist/extensions/geo.d.ts +452 -0
- package/dist/extensions/geo.d.ts.map +1 -0
- package/dist/extensions/geo.js +583 -0
- package/dist/extensions/geo.js.map +1 -0
- package/dist/extensions/index.d.ts +167 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +99 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/loader.d.ts +226 -0
- package/dist/extensions/loader.d.ts.map +1 -0
- package/dist/extensions/loader.js +456 -0
- package/dist/extensions/loader.js.map +1 -0
- package/dist/extensions/pgmq-lite.d.ts +330 -0
- package/dist/extensions/pgmq-lite.d.ts.map +1 -0
- package/dist/extensions/pgmq-lite.js +648 -0
- package/dist/extensions/pgmq-lite.js.map +1 -0
- package/dist/extensions/plugins.d.ts +260 -0
- package/dist/extensions/plugins.d.ts.map +1 -0
- package/dist/extensions/plugins.js +535 -0
- package/dist/extensions/plugins.js.map +1 -0
- package/dist/extensions/registry.d.ts +93 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/registry.js +182 -0
- package/dist/extensions/registry.js.map +1 -0
- package/dist/extensions/vector.d.ts +106 -0
- package/dist/extensions/vector.d.ts.map +1 -0
- package/dist/extensions/vector.js +129 -0
- package/dist/extensions/vector.js.map +1 -0
- package/dist/iceberg/analytics.d.ts +279 -0
- package/dist/iceberg/analytics.d.ts.map +1 -0
- package/dist/iceberg/analytics.js +448 -0
- package/dist/iceberg/analytics.js.map +1 -0
- package/dist/iceberg/catalog-api.d.ts +39 -0
- package/dist/iceberg/catalog-api.d.ts.map +1 -0
- package/dist/iceberg/catalog-api.js +388 -0
- package/dist/iceberg/catalog-api.js.map +1 -0
- package/dist/iceberg/catalog.d.ts +401 -0
- package/dist/iceberg/catalog.d.ts.map +1 -0
- package/dist/iceberg/catalog.js +677 -0
- package/dist/iceberg/catalog.js.map +1 -0
- package/dist/iceberg/duckdb-wasm.d.ts +447 -0
- package/dist/iceberg/duckdb-wasm.d.ts.map +1 -0
- package/dist/iceberg/duckdb-wasm.js +600 -0
- package/dist/iceberg/duckdb-wasm.js.map +1 -0
- package/dist/iceberg/index.d.ts +92 -0
- package/dist/iceberg/index.d.ts.map +1 -0
- package/dist/iceberg/index.js +119 -0
- package/dist/iceberg/index.js.map +1 -0
- package/dist/iceberg/metadata.d.ts +214 -0
- package/dist/iceberg/metadata.d.ts.map +1 -0
- package/dist/iceberg/metadata.js +535 -0
- package/dist/iceberg/metadata.js.map +1 -0
- package/dist/iceberg/optimizer.d.ts +296 -0
- package/dist/iceberg/optimizer.d.ts.map +1 -0
- package/dist/iceberg/optimizer.js +889 -0
- package/dist/iceberg/optimizer.js.map +1 -0
- package/dist/iceberg/parquet.d.ts +447 -0
- package/dist/iceberg/parquet.d.ts.map +1 -0
- package/dist/iceberg/parquet.js +1225 -0
- package/dist/iceberg/parquet.js.map +1 -0
- package/dist/iceberg/r2-organization.d.ts +422 -0
- package/dist/iceberg/r2-organization.d.ts.map +1 -0
- package/dist/iceberg/r2-organization.js +672 -0
- package/dist/iceberg/r2-organization.js.map +1 -0
- package/dist/iceberg/scheduler-do-example.d.ts +158 -0
- package/dist/iceberg/scheduler-do-example.d.ts.map +1 -0
- package/dist/iceberg/scheduler-do-example.js +261 -0
- package/dist/iceberg/scheduler-do-example.js.map +1 -0
- package/dist/iceberg/scheduler.d.ts +434 -0
- package/dist/iceberg/scheduler.d.ts.map +1 -0
- package/dist/iceberg/scheduler.js +818 -0
- package/dist/iceberg/scheduler.js.map +1 -0
- package/dist/iceberg/schema.d.ts +149 -0
- package/dist/iceberg/schema.d.ts.map +1 -0
- package/dist/iceberg/schema.js +525 -0
- package/dist/iceberg/schema.js.map +1 -0
- package/dist/iceberg/snapshot-manager.d.ts +406 -0
- package/dist/iceberg/snapshot-manager.d.ts.map +1 -0
- package/dist/iceberg/snapshot-manager.js +934 -0
- package/dist/iceberg/snapshot-manager.js.map +1 -0
- package/dist/iceberg/sql-router.d.ts +194 -0
- package/dist/iceberg/sql-router.d.ts.map +1 -0
- package/dist/iceberg/sql-router.js +180 -0
- package/dist/iceberg/sql-router.js.map +1 -0
- package/dist/iceberg/test-fixtures.d.ts +151 -0
- package/dist/iceberg/test-fixtures.d.ts.map +1 -0
- package/dist/iceberg/test-fixtures.js +446 -0
- package/dist/iceberg/test-fixtures.js.map +1 -0
- package/dist/iceberg/time-travel-api.d.ts +102 -0
- package/dist/iceberg/time-travel-api.d.ts.map +1 -0
- package/dist/iceberg/time-travel-api.js +437 -0
- package/dist/iceberg/time-travel-api.js.map +1 -0
- package/dist/iceberg/time-travel.d.ts +293 -0
- package/dist/iceberg/time-travel.d.ts.map +1 -0
- package/dist/iceberg/time-travel.js +689 -0
- package/dist/iceberg/time-travel.js.map +1 -0
- package/dist/iceberg/transformer.d.ts +356 -0
- package/dist/iceberg/transformer.d.ts.map +1 -0
- package/dist/iceberg/transformer.js +770 -0
- package/dist/iceberg/transformer.js.map +1 -0
- package/dist/iceberg/types.d.ts +318 -0
- package/dist/iceberg/types.d.ts.map +1 -0
- package/dist/iceberg/types.js +9 -0
- package/dist/iceberg/types.js.map +1 -0
- package/dist/iceberg/writer.d.ts +144 -0
- package/dist/iceberg/writer.d.ts.map +1 -0
- package/dist/iceberg/writer.js +452 -0
- package/dist/iceberg/writer.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/lineage/index.d.ts +11 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +11 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/integration.d.ts +134 -0
- package/dist/lineage/integration.d.ts.map +1 -0
- package/dist/lineage/integration.js +258 -0
- package/dist/lineage/integration.js.map +1 -0
- package/dist/lineage/tracker.d.ts +189 -0
- package/dist/lineage/tracker.d.ts.map +1 -0
- package/dist/lineage/tracker.js +1352 -0
- package/dist/lineage/tracker.js.map +1 -0
- package/dist/lineage/types.d.ts +318 -0
- package/dist/lineage/types.d.ts.map +1 -0
- package/dist/lineage/types.js +9 -0
- package/dist/lineage/types.js.map +1 -0
- package/dist/middleware/index.d.ts +11 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +16 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +397 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +507 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/migration-tooling/external-migration.d.ts +601 -0
- package/dist/migration-tooling/external-migration.d.ts.map +1 -0
- package/dist/migration-tooling/external-migration.js +1612 -0
- package/dist/migration-tooling/external-migration.js.map +1 -0
- package/dist/migration-tooling/index.d.ts +19 -0
- package/dist/migration-tooling/index.d.ts.map +1 -0
- package/dist/migration-tooling/index.js +19 -0
- package/dist/migration-tooling/index.js.map +1 -0
- package/dist/migrations/auto-migrator.d.ts +289 -0
- package/dist/migrations/auto-migrator.d.ts.map +1 -0
- package/dist/migrations/auto-migrator.js +396 -0
- package/dist/migrations/auto-migrator.js.map +1 -0
- package/dist/migrations/bulk-orchestrator.d.ts +403 -0
- package/dist/migrations/bulk-orchestrator.d.ts.map +1 -0
- package/dist/migrations/bulk-orchestrator.js +646 -0
- package/dist/migrations/bulk-orchestrator.js.map +1 -0
- package/dist/migrations/compatibility.d.ts +216 -0
- package/dist/migrations/compatibility.d.ts.map +1 -0
- package/dist/migrations/compatibility.js +651 -0
- package/dist/migrations/compatibility.js.map +1 -0
- package/dist/migrations/do-migrations.d.ts +101 -0
- package/dist/migrations/do-migrations.d.ts.map +1 -0
- package/dist/migrations/do-migrations.js +1060 -0
- package/dist/migrations/do-migrations.js.map +1 -0
- package/dist/migrations/do-migrations.types.d.ts +550 -0
- package/dist/migrations/do-migrations.types.d.ts.map +1 -0
- package/dist/migrations/do-migrations.types.js +15 -0
- package/dist/migrations/do-migrations.types.js.map +1 -0
- package/dist/migrations/drizzle-compat.d.ts +163 -0
- package/dist/migrations/drizzle-compat.d.ts.map +1 -0
- package/dist/migrations/drizzle-compat.js +273 -0
- package/dist/migrations/drizzle-compat.js.map +1 -0
- package/dist/migrations/index.d.ts +109 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +127 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migration-api.d.ts +161 -0
- package/dist/migrations/migration-api.d.ts.map +1 -0
- package/dist/migrations/migration-api.js +499 -0
- package/dist/migrations/migration-api.js.map +1 -0
- package/dist/migrations/progress-tracker-do.d.ts +195 -0
- package/dist/migrations/progress-tracker-do.d.ts.map +1 -0
- package/dist/migrations/progress-tracker-do.js +339 -0
- package/dist/migrations/progress-tracker-do.js.map +1 -0
- package/dist/migrations/progress-tracker-kv.d.ts +103 -0
- package/dist/migrations/progress-tracker-kv.d.ts.map +1 -0
- package/dist/migrations/progress-tracker-kv.js +231 -0
- package/dist/migrations/progress-tracker-kv.js.map +1 -0
- package/dist/migrations/progress-tracker.d.ts +320 -0
- package/dist/migrations/progress-tracker.d.ts.map +1 -0
- package/dist/migrations/progress-tracker.js +443 -0
- package/dist/migrations/progress-tracker.js.map +1 -0
- package/dist/migrations/registry.d.ts +231 -0
- package/dist/migrations/registry.d.ts.map +1 -0
- package/dist/migrations/registry.js +376 -0
- package/dist/migrations/registry.js.map +1 -0
- package/dist/migrations/runner.d.ts +197 -0
- package/dist/migrations/runner.d.ts.map +1 -0
- package/dist/migrations/runner.js +1167 -0
- package/dist/migrations/runner.js.map +1 -0
- package/dist/migrations/schema-generator.d.ts +111 -0
- package/dist/migrations/schema-generator.d.ts.map +1 -0
- package/dist/migrations/schema-generator.js +335 -0
- package/dist/migrations/schema-generator.js.map +1 -0
- package/dist/migrations/testing.d.ts +321 -0
- package/dist/migrations/testing.d.ts.map +1 -0
- package/dist/migrations/testing.js +645 -0
- package/dist/migrations/testing.js.map +1 -0
- package/dist/migrations/types.d.ts +503 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +11 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/migrations/validator.d.ts +215 -0
- package/dist/migrations/validator.d.ts.map +1 -0
- package/dist/migrations/validator.js +494 -0
- package/dist/migrations/validator.js.map +1 -0
- package/dist/observability/alerting.d.ts +116 -0
- package/dist/observability/alerting.d.ts.map +1 -0
- package/dist/observability/alerting.js +353 -0
- package/dist/observability/alerting.js.map +1 -0
- package/dist/observability/analytics-engine.d.ts +357 -0
- package/dist/observability/analytics-engine.d.ts.map +1 -0
- package/dist/observability/analytics-engine.js +430 -0
- package/dist/observability/analytics-engine.js.map +1 -0
- package/dist/observability/cost-metrics.d.ts +269 -0
- package/dist/observability/cost-metrics.d.ts.map +1 -0
- package/dist/observability/cost-metrics.js +560 -0
- package/dist/observability/cost-metrics.js.map +1 -0
- package/dist/observability/cross-do-tracing.d.ts +305 -0
- package/dist/observability/cross-do-tracing.d.ts.map +1 -0
- package/dist/observability/cross-do-tracing.js +431 -0
- package/dist/observability/cross-do-tracing.js.map +1 -0
- package/dist/observability/error-rate-collector.d.ts +163 -0
- package/dist/observability/error-rate-collector.d.ts.map +1 -0
- package/dist/observability/error-rate-collector.js +306 -0
- package/dist/observability/error-rate-collector.js.map +1 -0
- package/dist/observability/exporters.d.ts +231 -0
- package/dist/observability/exporters.d.ts.map +1 -0
- package/dist/observability/exporters.js +479 -0
- package/dist/observability/exporters.js.map +1 -0
- package/dist/observability/health-check.d.ts +106 -0
- package/dist/observability/health-check.d.ts.map +1 -0
- package/dist/observability/health-check.js +243 -0
- package/dist/observability/health-check.js.map +1 -0
- package/dist/observability/index.d.ts +297 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +455 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/instrumentation.d.ts +222 -0
- package/dist/observability/instrumentation.d.ts.map +1 -0
- package/dist/observability/instrumentation.js +532 -0
- package/dist/observability/instrumentation.js.map +1 -0
- package/dist/observability/memory-metrics.d.ts +227 -0
- package/dist/observability/memory-metrics.d.ts.map +1 -0
- package/dist/observability/memory-metrics.js +688 -0
- package/dist/observability/memory-metrics.js.map +1 -0
- package/dist/observability/metrics-endpoint.d.ts +91 -0
- package/dist/observability/metrics-endpoint.d.ts.map +1 -0
- package/dist/observability/metrics-endpoint.js +246 -0
- package/dist/observability/metrics-endpoint.js.map +1 -0
- package/dist/observability/metrics.d.ts +88 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +253 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/observability/observability-features.d.ts +488 -0
- package/dist/observability/observability-features.d.ts.map +1 -0
- package/dist/observability/observability-features.js +773 -0
- package/dist/observability/observability-features.js.map +1 -0
- package/dist/observability/prometheus.d.ts +39 -0
- package/dist/observability/prometheus.d.ts.map +1 -0
- package/dist/observability/prometheus.js +120 -0
- package/dist/observability/prometheus.js.map +1 -0
- package/dist/observability/propagation.d.ts +126 -0
- package/dist/observability/propagation.d.ts.map +1 -0
- package/dist/observability/propagation.js +234 -0
- package/dist/observability/propagation.js.map +1 -0
- package/dist/observability/query-latency.d.ts +243 -0
- package/dist/observability/query-latency.d.ts.map +1 -0
- package/dist/observability/query-latency.js +292 -0
- package/dist/observability/query-latency.js.map +1 -0
- package/dist/observability/query-performance.d.ts +169 -0
- package/dist/observability/query-performance.d.ts.map +1 -0
- package/dist/observability/query-performance.js +290 -0
- package/dist/observability/query-performance.js.map +1 -0
- package/dist/observability/storage-tier-metrics.d.ts +174 -0
- package/dist/observability/storage-tier-metrics.d.ts.map +1 -0
- package/dist/observability/storage-tier-metrics.js +306 -0
- package/dist/observability/storage-tier-metrics.js.map +1 -0
- package/dist/observability/tier-cost-optimizer.d.ts +155 -0
- package/dist/observability/tier-cost-optimizer.d.ts.map +1 -0
- package/dist/observability/tier-cost-optimizer.js +536 -0
- package/dist/observability/tier-cost-optimizer.js.map +1 -0
- package/dist/observability/tracer.d.ts +149 -0
- package/dist/observability/tracer.d.ts.map +1 -0
- package/dist/observability/tracer.js +435 -0
- package/dist/observability/tracer.js.map +1 -0
- package/dist/observability/types.d.ts +402 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +103 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pglite/workers-pglite.d.ts +138 -0
- package/dist/pglite/workers-pglite.d.ts.map +1 -0
- package/dist/pglite/workers-pglite.js +143 -0
- package/dist/pglite/workers-pglite.js.map +1 -0
- package/dist/pglite-assets/pglite.data +0 -0
- package/dist/pglite-assets/pglite.wasm +0 -0
- package/dist/playground/index.d.ts +52 -0
- package/dist/playground/index.d.ts.map +1 -0
- package/dist/playground/index.js +55 -0
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/keyboard-shortcuts.d.ts +116 -0
- package/dist/playground/keyboard-shortcuts.d.ts.map +1 -0
- package/dist/playground/keyboard-shortcuts.js +588 -0
- package/dist/playground/keyboard-shortcuts.js.map +1 -0
- package/dist/playground/playground.d.ts +82 -0
- package/dist/playground/playground.d.ts.map +1 -0
- package/dist/playground/playground.js +271 -0
- package/dist/playground/playground.js.map +1 -0
- package/dist/playground/query-executor.d.ts +115 -0
- package/dist/playground/query-executor.d.ts.map +1 -0
- package/dist/playground/query-executor.js +558 -0
- package/dist/playground/query-executor.js.map +1 -0
- package/dist/playground/query-history.d.ts +92 -0
- package/dist/playground/query-history.d.ts.map +1 -0
- package/dist/playground/query-history.js +259 -0
- package/dist/playground/query-history.js.map +1 -0
- package/dist/playground/result-formatter.d.ts +59 -0
- package/dist/playground/result-formatter.d.ts.map +1 -0
- package/dist/playground/result-formatter.js +341 -0
- package/dist/playground/result-formatter.js.map +1 -0
- package/dist/playground/sample-datasets.d.ts +77 -0
- package/dist/playground/sample-datasets.d.ts.map +1 -0
- package/dist/playground/sample-datasets.js +641 -0
- package/dist/playground/sample-datasets.js.map +1 -0
- package/dist/playground/sample-queries.d.ts +73 -0
- package/dist/playground/sample-queries.d.ts.map +1 -0
- package/dist/playground/sample-queries.js +1095 -0
- package/dist/playground/sample-queries.js.map +1 -0
- package/dist/playground/schema-explorer.d.ts +55 -0
- package/dist/playground/schema-explorer.d.ts.map +1 -0
- package/dist/playground/schema-explorer.js +473 -0
- package/dist/playground/schema-explorer.js.map +1 -0
- package/dist/playground/types.d.ts +430 -0
- package/dist/playground/types.d.ts.map +1 -0
- package/dist/playground/types.js +10 -0
- package/dist/playground/types.js.map +1 -0
- package/dist/readonly/cache-reader.d.ts +145 -0
- package/dist/readonly/cache-reader.d.ts.map +1 -0
- package/dist/readonly/cache-reader.js +198 -0
- package/dist/readonly/cache-reader.js.map +1 -0
- package/dist/readonly/config.d.ts +74 -0
- package/dist/readonly/config.d.ts.map +1 -0
- package/dist/readonly/config.js +67 -0
- package/dist/readonly/config.js.map +1 -0
- package/dist/readonly/index.d.ts +22 -0
- package/dist/readonly/index.d.ts.map +1 -0
- package/dist/readonly/index.js +17 -0
- package/dist/readonly/index.js.map +1 -0
- package/dist/readonly/pglite-wrapper.d.ts +82 -0
- package/dist/readonly/pglite-wrapper.d.ts.map +1 -0
- package/dist/readonly/pglite-wrapper.js +123 -0
- package/dist/readonly/pglite-wrapper.js.map +1 -0
- package/dist/readonly/worker.d.ts +142 -0
- package/dist/readonly/worker.d.ts.map +1 -0
- package/dist/readonly/worker.js +187 -0
- package/dist/readonly/worker.js.map +1 -0
- package/dist/readonly/write-blocker.d.ts +47 -0
- package/dist/readonly/write-blocker.d.ts.map +1 -0
- package/dist/readonly/write-blocker.js +136 -0
- package/dist/readonly/write-blocker.js.map +1 -0
- package/dist/recovery/disaster-recovery.d.ts +326 -0
- package/dist/recovery/disaster-recovery.d.ts.map +1 -0
- package/dist/recovery/disaster-recovery.js +799 -0
- package/dist/recovery/disaster-recovery.js.map +1 -0
- package/dist/recovery/index.d.ts +12 -0
- package/dist/recovery/index.d.ts.map +1 -0
- package/dist/recovery/index.js +12 -0
- package/dist/recovery/index.js.map +1 -0
- package/dist/recovery/parquet-parser.d.ts +321 -0
- package/dist/recovery/parquet-parser.d.ts.map +1 -0
- package/dist/recovery/parquet-parser.js +797 -0
- package/dist/recovery/parquet-parser.js.map +1 -0
- package/dist/retention/index.d.ts +50 -0
- package/dist/retention/index.d.ts.map +1 -0
- package/dist/retention/index.js +50 -0
- package/dist/retention/index.js.map +1 -0
- package/dist/retention/policy.d.ts +344 -0
- package/dist/retention/policy.d.ts.map +1 -0
- package/dist/retention/policy.js +472 -0
- package/dist/retention/policy.js.map +1 -0
- package/dist/retention/purger.d.ts +187 -0
- package/dist/retention/purger.d.ts.map +1 -0
- package/dist/retention/purger.js +411 -0
- package/dist/retention/purger.js.map +1 -0
- package/dist/rls/auth-integration.d.ts +280 -0
- package/dist/rls/auth-integration.d.ts.map +1 -0
- package/dist/rls/auth-integration.js +399 -0
- package/dist/rls/auth-integration.js.map +1 -0
- package/dist/rls/generator.d.ts +249 -0
- package/dist/rls/generator.d.ts.map +1 -0
- package/dist/rls/generator.js +495 -0
- package/dist/rls/generator.js.map +1 -0
- package/dist/rls/index.d.ts +26 -0
- package/dist/rls/index.d.ts.map +1 -0
- package/dist/rls/index.js +58 -0
- package/dist/rls/index.js.map +1 -0
- package/dist/rls/policy.d.ts +116 -0
- package/dist/rls/policy.d.ts.map +1 -0
- package/dist/rls/policy.js +77 -0
- package/dist/rls/policy.js.map +1 -0
- package/dist/rls/validator.d.ts +155 -0
- package/dist/rls/validator.d.ts.map +1 -0
- package/dist/rls/validator.js +792 -0
- package/dist/rls/validator.js.map +1 -0
- package/dist/routing/adaptive-router.d.ts +317 -0
- package/dist/routing/adaptive-router.d.ts.map +1 -0
- package/dist/routing/adaptive-router.js +554 -0
- package/dist/routing/adaptive-router.js.map +1 -0
- package/dist/routing/circuit-breaker.d.ts +339 -0
- package/dist/routing/circuit-breaker.d.ts.map +1 -0
- package/dist/routing/circuit-breaker.js +620 -0
- package/dist/routing/circuit-breaker.js.map +1 -0
- package/dist/routing/cost-metrics.d.ts +133 -0
- package/dist/routing/cost-metrics.d.ts.map +1 -0
- package/dist/routing/cost-metrics.js +259 -0
- package/dist/routing/cost-metrics.js.map +1 -0
- package/dist/routing/do-connection-pool.d.ts +243 -0
- package/dist/routing/do-connection-pool.d.ts.map +1 -0
- package/dist/routing/do-connection-pool.js +572 -0
- package/dist/routing/do-connection-pool.js.map +1 -0
- package/dist/routing/index.d.ts +59 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +59 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/query-complexity-estimator.d.ts +73 -0
- package/dist/routing/query-complexity-estimator.d.ts.map +1 -0
- package/dist/routing/query-complexity-estimator.js +327 -0
- package/dist/routing/query-complexity-estimator.js.map +1 -0
- package/dist/routing/request-coalescing.d.ts +178 -0
- package/dist/routing/request-coalescing.d.ts.map +1 -0
- package/dist/routing/request-coalescing.js +325 -0
- package/dist/routing/request-coalescing.js.map +1 -0
- package/dist/routing/runtime-router.d.ts +107 -0
- package/dist/routing/runtime-router.d.ts.map +1 -0
- package/dist/routing/runtime-router.js +246 -0
- package/dist/routing/runtime-router.js.map +1 -0
- package/dist/routing/tenant-router.d.ts +848 -0
- package/dist/routing/tenant-router.d.ts.map +1 -0
- package/dist/routing/tenant-router.js +1056 -0
- package/dist/routing/tenant-router.js.map +1 -0
- package/dist/routing/websocket-pool.d.ts +119 -0
- package/dist/routing/websocket-pool.d.ts.map +1 -0
- package/dist/routing/websocket-pool.js +436 -0
- package/dist/routing/websocket-pool.js.map +1 -0
- package/dist/storage/cache-layer.d.ts +159 -0
- package/dist/storage/cache-layer.d.ts.map +1 -0
- package/dist/storage/cache-layer.js +245 -0
- package/dist/storage/cache-layer.js.map +1 -0
- package/dist/storage/cost-aware-tiering.d.ts +258 -0
- package/dist/storage/cost-aware-tiering.d.ts.map +1 -0
- package/dist/storage/cost-aware-tiering.js +526 -0
- package/dist/storage/cost-aware-tiering.js.map +1 -0
- package/dist/storage/index.d.ts +87 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +78 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/interfaces.d.ts +856 -0
- package/dist/storage/interfaces.d.ts.map +1 -0
- package/dist/storage/interfaces.js +69 -0
- package/dist/storage/interfaces.js.map +1 -0
- package/dist/storage/r2-layer.d.ts +226 -0
- package/dist/storage/r2-layer.d.ts.map +1 -0
- package/dist/storage/r2-layer.js +307 -0
- package/dist/storage/r2-layer.js.map +1 -0
- package/dist/storage/r2-overflow.d.ts +344 -0
- package/dist/storage/r2-overflow.d.ts.map +1 -0
- package/dist/storage/r2-overflow.js +730 -0
- package/dist/storage/r2-overflow.js.map +1 -0
- package/dist/storage/r2-page-vfs.d.ts +374 -0
- package/dist/storage/r2-page-vfs.d.ts.map +1 -0
- package/dist/storage/r2-page-vfs.js +754 -0
- package/dist/storage/r2-page-vfs.js.map +1 -0
- package/dist/storage/swr-cache.d.ts +181 -0
- package/dist/storage/swr-cache.d.ts.map +1 -0
- package/dist/storage/swr-cache.js +295 -0
- package/dist/storage/swr-cache.js.map +1 -0
- package/dist/storage/tiered-orchestrator.d.ts +951 -0
- package/dist/storage/tiered-orchestrator.d.ts.map +1 -0
- package/dist/storage/tiered-orchestrator.js +1731 -0
- package/dist/storage/tiered-orchestrator.js.map +1 -0
- package/dist/storage/tiered-vfs-swr.d.ts +279 -0
- package/dist/storage/tiered-vfs-swr.d.ts.map +1 -0
- package/dist/storage/tiered-vfs-swr.js +584 -0
- package/dist/storage/tiered-vfs-swr.js.map +1 -0
- package/dist/storage/tiered-vfs.d.ts +405 -0
- package/dist/storage/tiered-vfs.d.ts.map +1 -0
- package/dist/storage/tiered-vfs.js +833 -0
- package/dist/storage/tiered-vfs.js.map +1 -0
- package/dist/streaming/backpressure-controller.d.ts +173 -0
- package/dist/streaming/backpressure-controller.d.ts.map +1 -0
- package/dist/streaming/backpressure-controller.js +344 -0
- package/dist/streaming/backpressure-controller.js.map +1 -0
- package/dist/streaming/buffer-pool.d.ts +241 -0
- package/dist/streaming/buffer-pool.d.ts.map +1 -0
- package/dist/streaming/buffer-pool.js +381 -0
- package/dist/streaming/buffer-pool.js.map +1 -0
- package/dist/streaming/cdc-iceberg-connector.d.ts +272 -0
- package/dist/streaming/cdc-iceberg-connector.d.ts.map +1 -0
- package/dist/streaming/cdc-iceberg-connector.js +408 -0
- package/dist/streaming/cdc-iceberg-connector.js.map +1 -0
- package/dist/streaming/index.d.ts +111 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +128 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/live-cdc-stream.d.ts +400 -0
- package/dist/streaming/live-cdc-stream.d.ts.map +1 -0
- package/dist/streaming/live-cdc-stream.js +703 -0
- package/dist/streaming/live-cdc-stream.js.map +1 -0
- package/dist/streaming/memory-bounded-stream.d.ts +207 -0
- package/dist/streaming/memory-bounded-stream.d.ts.map +1 -0
- package/dist/streaming/memory-bounded-stream.js +340 -0
- package/dist/streaming/memory-bounded-stream.js.map +1 -0
- package/dist/streaming/query-streamer.d.ts +379 -0
- package/dist/streaming/query-streamer.d.ts.map +1 -0
- package/dist/streaming/query-streamer.js +495 -0
- package/dist/streaming/query-streamer.js.map +1 -0
- package/dist/streaming/response-streaming.d.ts +203 -0
- package/dist/streaming/response-streaming.d.ts.map +1 -0
- package/dist/streaming/response-streaming.js +449 -0
- package/dist/streaming/response-streaming.js.map +1 -0
- package/dist/types/branded.d.ts +859 -0
- package/dist/types/branded.d.ts.map +1 -0
- package/dist/types/branded.js +891 -0
- package/dist/types/branded.js.map +1 -0
- package/dist/types/utilities.d.ts +757 -0
- package/dist/types/utilities.d.ts.map +1 -0
- package/dist/types/utilities.js +447 -0
- package/dist/types/utilities.js.map +1 -0
- package/dist/wal/replay-engine.d.ts +344 -0
- package/dist/wal/replay-engine.d.ts.map +1 -0
- package/dist/wal/replay-engine.js +975 -0
- package/dist/wal/replay-engine.js.map +1 -0
- package/dist/worker/__mocks__/capnweb.d.ts +13 -0
- package/dist/worker/__mocks__/capnweb.d.ts.map +1 -0
- package/dist/worker/__mocks__/capnweb.js +15 -0
- package/dist/worker/__mocks__/capnweb.js.map +1 -0
- package/dist/worker/__mocks__/cloudflare-workers.d.ts +31 -0
- package/dist/worker/__mocks__/cloudflare-workers.d.ts.map +1 -0
- package/dist/worker/__mocks__/cloudflare-workers.js +33 -0
- package/dist/worker/__mocks__/cloudflare-workers.js.map +1 -0
- package/dist/worker/__mocks__/pglite.data.d.ts +3 -0
- package/dist/worker/__mocks__/pglite.data.d.ts.map +1 -0
- package/dist/worker/__mocks__/pglite.data.js +20 -0
- package/dist/worker/__mocks__/pglite.data.js.map +1 -0
- package/dist/worker/__mocks__/pglite.wasm.d.ts +3 -0
- package/dist/worker/__mocks__/pglite.wasm.d.ts.map +1 -0
- package/dist/worker/__mocks__/pglite.wasm.js +30 -0
- package/dist/worker/__mocks__/pglite.wasm.js.map +1 -0
- package/dist/worker/auth-rate-limiter.d.ts +270 -0
- package/dist/worker/auth-rate-limiter.d.ts.map +1 -0
- package/dist/worker/auth-rate-limiter.js +332 -0
- package/dist/worker/auth-rate-limiter.js.map +1 -0
- package/dist/worker/auth.d.ts +345 -0
- package/dist/worker/auth.d.ts.map +1 -0
- package/dist/worker/auth.js +837 -0
- package/dist/worker/auth.js.map +1 -0
- package/dist/worker/cdc-backpressure.d.ts +338 -0
- package/dist/worker/cdc-backpressure.d.ts.map +1 -0
- package/dist/worker/cdc-backpressure.js +619 -0
- package/dist/worker/cdc-backpressure.js.map +1 -0
- package/dist/worker/cdc-sse.d.ts +277 -0
- package/dist/worker/cdc-sse.d.ts.map +1 -0
- package/dist/worker/cdc-sse.js +528 -0
- package/dist/worker/cdc-sse.js.map +1 -0
- package/dist/worker/cdc-websocket.d.ts +252 -0
- package/dist/worker/cdc-websocket.d.ts.map +1 -0
- package/dist/worker/cdc-websocket.js +940 -0
- package/dist/worker/cdc-websocket.js.map +1 -0
- package/dist/worker/cdc.d.ts +95 -0
- package/dist/worker/cdc.d.ts.map +1 -0
- package/dist/worker/cdc.js +211 -0
- package/dist/worker/cdc.js.map +1 -0
- package/dist/worker/concerns/auth-concern.d.ts +50 -0
- package/dist/worker/concerns/auth-concern.d.ts.map +1 -0
- package/dist/worker/concerns/auth-concern.js +131 -0
- package/dist/worker/concerns/auth-concern.js.map +1 -0
- package/dist/worker/concerns/cdc-concern.d.ts +99 -0
- package/dist/worker/concerns/cdc-concern.d.ts.map +1 -0
- package/dist/worker/concerns/cdc-concern.js +137 -0
- package/dist/worker/concerns/cdc-concern.js.map +1 -0
- package/dist/worker/concerns/index.d.ts +22 -0
- package/dist/worker/concerns/index.d.ts.map +1 -0
- package/dist/worker/concerns/index.js +13 -0
- package/dist/worker/concerns/index.js.map +1 -0
- package/dist/worker/concerns/query-execution-concern.d.ts +104 -0
- package/dist/worker/concerns/query-execution-concern.d.ts.map +1 -0
- package/dist/worker/concerns/query-execution-concern.js +95 -0
- package/dist/worker/concerns/query-execution-concern.js.map +1 -0
- package/dist/worker/concerns/storage-orchestration-concern.d.ts +78 -0
- package/dist/worker/concerns/storage-orchestration-concern.d.ts.map +1 -0
- package/dist/worker/concerns/storage-orchestration-concern.js +240 -0
- package/dist/worker/concerns/storage-orchestration-concern.js.map +1 -0
- package/dist/worker/do-auth-manager.d.ts +108 -0
- package/dist/worker/do-auth-manager.d.ts.map +1 -0
- package/dist/worker/do-auth-manager.js +212 -0
- package/dist/worker/do-auth-manager.js.map +1 -0
- package/dist/worker/do-pglite-manager.d.ts +137 -0
- package/dist/worker/do-pglite-manager.d.ts.map +1 -0
- package/dist/worker/do-pglite-manager.js +228 -0
- package/dist/worker/do-pglite-manager.js.map +1 -0
- package/dist/worker/do.d.ts +556 -0
- package/dist/worker/do.d.ts.map +1 -0
- package/dist/worker/do.js +1441 -0
- package/dist/worker/do.js.map +1 -0
- package/dist/worker/entry.d.ts +23 -0
- package/dist/worker/entry.d.ts.map +1 -0
- package/dist/worker/entry.js +362 -0
- package/dist/worker/entry.js.map +1 -0
- package/dist/worker/errors.d.ts +106 -0
- package/dist/worker/errors.d.ts.map +1 -0
- package/dist/worker/errors.js +178 -0
- package/dist/worker/errors.js.map +1 -0
- package/dist/worker/health-check-manager.d.ts +141 -0
- package/dist/worker/health-check-manager.d.ts.map +1 -0
- package/dist/worker/health-check-manager.js +145 -0
- package/dist/worker/health-check-manager.js.map +1 -0
- package/dist/worker/index.d.ts +60 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +67 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/memory-pressure.d.ts +892 -0
- package/dist/worker/memory-pressure.d.ts.map +1 -0
- package/dist/worker/memory-pressure.js +1990 -0
- package/dist/worker/memory-pressure.js.map +1 -0
- package/dist/worker/migration-manager.d.ts +153 -0
- package/dist/worker/migration-manager.d.ts.map +1 -0
- package/dist/worker/migration-manager.js +461 -0
- package/dist/worker/migration-manager.js.map +1 -0
- package/dist/worker/plugin-manager.d.ts +147 -0
- package/dist/worker/plugin-manager.d.ts.map +1 -0
- package/dist/worker/plugin-manager.js +408 -0
- package/dist/worker/plugin-manager.js.map +1 -0
- package/dist/worker/proxy.d.ts +330 -0
- package/dist/worker/proxy.d.ts.map +1 -0
- package/dist/worker/proxy.js +504 -0
- package/dist/worker/proxy.js.map +1 -0
- package/dist/worker/query-execution-manager.d.ts +107 -0
- package/dist/worker/query-execution-manager.d.ts.map +1 -0
- package/dist/worker/query-execution-manager.js +155 -0
- package/dist/worker/query-execution-manager.js.map +1 -0
- package/dist/worker/query-executor.d.ts +163 -0
- package/dist/worker/query-executor.d.ts.map +1 -0
- package/dist/worker/query-executor.js +413 -0
- package/dist/worker/query-executor.js.map +1 -0
- package/dist/worker/query-stats-manager.d.ts +117 -0
- package/dist/worker/query-stats-manager.d.ts.map +1 -0
- package/dist/worker/query-stats-manager.js +162 -0
- package/dist/worker/query-stats-manager.js.map +1 -0
- package/dist/worker/result-handler.d.ts +192 -0
- package/dist/worker/result-handler.d.ts.map +1 -0
- package/dist/worker/result-handler.js +346 -0
- package/dist/worker/result-handler.js.map +1 -0
- package/dist/worker/routes.d.ts +135 -0
- package/dist/worker/routes.d.ts.map +1 -0
- package/dist/worker/routes.js +460 -0
- package/dist/worker/routes.js.map +1 -0
- package/dist/worker/rpc-methods-manager.d.ts +142 -0
- package/dist/worker/rpc-methods-manager.d.ts.map +1 -0
- package/dist/worker/rpc-methods-manager.js +195 -0
- package/dist/worker/rpc-methods-manager.js.map +1 -0
- package/dist/worker/rpc.d.ts +259 -0
- package/dist/worker/rpc.d.ts.map +1 -0
- package/dist/worker/rpc.js +398 -0
- package/dist/worker/rpc.js.map +1 -0
- package/dist/worker/schema-version.d.ts +209 -0
- package/dist/worker/schema-version.d.ts.map +1 -0
- package/dist/worker/schema-version.js +450 -0
- package/dist/worker/schema-version.js.map +1 -0
- package/dist/worker/session-manager.d.ts +282 -0
- package/dist/worker/session-manager.d.ts.map +1 -0
- package/dist/worker/session-manager.js +523 -0
- package/dist/worker/session-manager.js.map +1 -0
- package/dist/worker/shutdown-manager.d.ts +188 -0
- package/dist/worker/shutdown-manager.d.ts.map +1 -0
- package/dist/worker/shutdown-manager.js +347 -0
- package/dist/worker/shutdown-manager.js.map +1 -0
- package/dist/worker/sql-transform.d.ts +61 -0
- package/dist/worker/sql-transform.d.ts.map +1 -0
- package/dist/worker/sql-transform.js +312 -0
- package/dist/worker/sql-transform.js.map +1 -0
- package/dist/worker/types.d.ts +738 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/dist/worker/types.js +6 -0
- package/dist/worker/types.js.map +1 -0
- package/dist/worker/user-routes.d.ts +76 -0
- package/dist/worker/user-routes.d.ts.map +1 -0
- package/dist/worker/user-routes.js +188 -0
- package/dist/worker/user-routes.js.map +1 -0
- package/dist/worker/wal-facade.d.ts +138 -0
- package/dist/worker/wal-facade.d.ts.map +1 -0
- package/dist/worker/wal-facade.js +184 -0
- package/dist/worker/wal-facade.js.map +1 -0
- package/dist/worker/wal-r2.d.ts +271 -0
- package/dist/worker/wal-r2.d.ts.map +1 -0
- package/dist/worker/wal-r2.js +689 -0
- package/dist/worker/wal-r2.js.map +1 -0
- package/dist/worker/wal-replay.d.ts +361 -0
- package/dist/worker/wal-replay.d.ts.map +1 -0
- package/dist/worker/wal-replay.js +628 -0
- package/dist/worker/wal-replay.js.map +1 -0
- package/dist/worker/wal-retention.d.ts +389 -0
- package/dist/worker/wal-retention.d.ts.map +1 -0
- package/dist/worker/wal-retention.js +763 -0
- package/dist/worker/wal-retention.js.map +1 -0
- package/dist/worker/wal.d.ts +278 -0
- package/dist/worker/wal.d.ts.map +1 -0
- package/dist/worker/wal.js +467 -0
- package/dist/worker/wal.js.map +1 -0
- package/dist/worker/websocket.d.ts +85 -0
- package/dist/worker/websocket.d.ts.map +1 -0
- package/dist/worker/websocket.js +227 -0
- package/dist/worker/websocket.js.map +1 -0
- package/package.json +108 -0
- package/src/cdc/change-stream.ts +137 -0
- package/src/cdc/filter.ts +646 -0
- package/src/cdc/index.ts +112 -0
- package/src/cdc/resume-token.ts +280 -0
- package/src/cdc/transport/index.ts +7 -0
- package/src/cdc/transport/sse.ts +723 -0
- package/src/cdc/transport/websocket.ts +873 -0
- package/src/cdc/types.ts +346 -0
- package/src/config/index.ts +25 -0
- package/src/config/memory.ts +177 -0
- package/src/config/storage.ts +204 -0
- package/src/config/streaming.ts +147 -0
- package/src/config/timeouts.ts +221 -0
- package/src/extensions/config.test.ts +187 -0
- package/src/extensions/config.ts +278 -0
- package/src/extensions/geo.test.ts +455 -0
- package/src/extensions/geo.ts +858 -0
- package/src/extensions/index.test.ts +259 -0
- package/src/extensions/index.ts +227 -0
- package/src/extensions/loader.test.ts +555 -0
- package/src/extensions/loader.ts +588 -0
- package/src/extensions/pgmq-lite.test.ts +727 -0
- package/src/extensions/pgmq-lite.ts +770 -0
- package/src/extensions/plugins.test.ts +528 -0
- package/src/extensions/plugins.ts +718 -0
- package/src/extensions/registry.test.ts +202 -0
- package/src/extensions/registry.ts +267 -0
- package/src/extensions/vector.test.ts +195 -0
- package/src/extensions/vector.ts +217 -0
- package/src/iceberg/SCHEDULER.md +580 -0
- package/src/iceberg/analytics.test.ts +703 -0
- package/src/iceberg/analytics.ts +727 -0
- package/src/iceberg/catalog-api.test.ts +838 -0
- package/src/iceberg/catalog-api.ts +520 -0
- package/src/iceberg/catalog.test.ts +680 -0
- package/src/iceberg/catalog.ts +1007 -0
- package/src/iceberg/iceberg.test.ts +705 -0
- package/src/iceberg/index.ts +406 -0
- package/src/iceberg/metadata.test.ts +632 -0
- package/src/iceberg/metadata.ts +649 -0
- package/src/iceberg/optimizer.test.ts +868 -0
- package/src/iceberg/optimizer.ts +1287 -0
- package/src/iceberg/parquet.test.ts +899 -0
- package/src/iceberg/parquet.ts +1640 -0
- package/src/iceberg/r2-organization.test.ts +615 -0
- package/src/iceberg/r2-organization.ts +951 -0
- package/src/iceberg/scheduler-do-example.ts +364 -0
- package/src/iceberg/scheduler.test.ts +861 -0
- package/src/iceberg/scheduler.ts +1201 -0
- package/src/iceberg/schema.test.ts +547 -0
- package/src/iceberg/schema.ts +616 -0
- package/src/iceberg/snapshot-manager.test.ts +919 -0
- package/src/iceberg/snapshot-manager.ts +1369 -0
- package/src/iceberg/sql-router.test.ts +334 -0
- package/src/iceberg/sql-router.ts +337 -0
- package/src/iceberg/test-fixtures.ts +605 -0
- package/src/iceberg/time-travel-api.test.ts +1029 -0
- package/src/iceberg/time-travel-api.ts +731 -0
- package/src/iceberg/time-travel.test.ts +1218 -0
- package/src/iceberg/time-travel.ts +1052 -0
- package/src/iceberg/transformer.test.ts +689 -0
- package/src/iceberg/transformer.ts +1029 -0
- package/src/iceberg/types.ts +373 -0
- package/src/iceberg/writer.test.ts +716 -0
- package/src/iceberg/writer.ts +590 -0
- package/src/index.ts +212 -0
- package/src/lineage/index.ts +42 -0
- package/src/lineage/integration.ts +334 -0
- package/src/lineage/tracker.ts +1618 -0
- package/src/lineage/types.ts +354 -0
- package/src/middleware/index.ts +36 -0
- package/src/middleware/rate-limit-concurrent.test.ts +794 -0
- package/src/middleware/rate-limit.test.ts +1568 -0
- package/src/middleware/rate-limit.ts +840 -0
- package/src/migration-tooling/external-migration.test.ts +1864 -0
- package/src/migration-tooling/external-migration.ts +2355 -0
- package/src/migration-tooling/index.ts +19 -0
- package/src/migrations/ARCHITECTURE.md +474 -0
- package/src/migrations/PROGRESS_TRACKING.md +485 -0
- package/src/migrations/auto-migrator.test.ts +732 -0
- package/src/migrations/auto-migrator.ts +531 -0
- package/src/migrations/bulk-orchestrator.test.ts +801 -0
- package/src/migrations/bulk-orchestrator.ts +1039 -0
- package/src/migrations/compatibility.test.ts +958 -0
- package/src/migrations/compatibility.ts +902 -0
- package/src/migrations/do-migrations.test.ts +2620 -0
- package/src/migrations/do-migrations.ts +1289 -0
- package/src/migrations/do-migrations.types.ts +715 -0
- package/src/migrations/drizzle-compat.test.ts +210 -0
- package/src/migrations/drizzle-compat.ts +337 -0
- package/src/migrations/index.ts +334 -0
- package/src/migrations/migration-api.test.ts +438 -0
- package/src/migrations/migration-api.ts +704 -0
- package/src/migrations/progress-tracker-do.ts +518 -0
- package/src/migrations/progress-tracker-kv.ts +305 -0
- package/src/migrations/progress-tracker.test.ts +937 -0
- package/src/migrations/progress-tracker.ts +665 -0
- package/src/migrations/registry.test.ts +331 -0
- package/src/migrations/registry.ts +468 -0
- package/src/migrations/rollback.test.ts +644 -0
- package/src/migrations/runner.test.ts +807 -0
- package/src/migrations/runner.test.ts.backup +759 -0
- package/src/migrations/runner.ts +1459 -0
- package/src/migrations/schema-generator.test.ts +649 -0
- package/src/migrations/schema-generator.ts +513 -0
- package/src/migrations/testing.ts +1037 -0
- package/src/migrations/types.ts +573 -0
- package/src/migrations/validator.test.ts +660 -0
- package/src/migrations/validator.ts +741 -0
- package/src/observability/alerting.test.ts +1133 -0
- package/src/observability/alerting.ts +455 -0
- package/src/observability/analytics-engine.ts +733 -0
- package/src/observability/cost-metrics.ts +804 -0
- package/src/observability/cross-do-tracing.test.ts +516 -0
- package/src/observability/cross-do-tracing.ts +588 -0
- package/src/observability/dashboards/postgres-do-overview.json +1656 -0
- package/src/observability/error-rate-collector.test.ts +977 -0
- package/src/observability/error-rate-collector.ts +518 -0
- package/src/observability/exporters.test.ts +365 -0
- package/src/observability/exporters.ts +650 -0
- package/src/observability/health-check.test.ts +353 -0
- package/src/observability/health-check.ts +341 -0
- package/src/observability/index.test.ts +298 -0
- package/src/observability/index.ts +885 -0
- package/src/observability/instrumentation.test.ts +428 -0
- package/src/observability/instrumentation.ts +788 -0
- package/src/observability/memory-metrics.test.ts +355 -0
- package/src/observability/memory-metrics.ts +990 -0
- package/src/observability/metrics-endpoint.test.ts +402 -0
- package/src/observability/metrics-endpoint.ts +374 -0
- package/src/observability/metrics.test.ts +291 -0
- package/src/observability/metrics.ts +315 -0
- package/src/observability/observability-features.ts +1296 -0
- package/src/observability/prometheus.test.ts +292 -0
- package/src/observability/prometheus.ts +170 -0
- package/src/observability/propagation.test.ts +417 -0
- package/src/observability/propagation.ts +294 -0
- package/src/observability/query-latency.ts +586 -0
- package/src/observability/query-performance.test.ts +406 -0
- package/src/observability/query-performance.ts +491 -0
- package/src/observability/storage-tier-metrics.test.ts +633 -0
- package/src/observability/storage-tier-metrics.ts +570 -0
- package/src/observability/tier-cost-optimizer.ts +740 -0
- package/src/observability/tracer.test.ts +346 -0
- package/src/observability/tracer.ts +585 -0
- package/src/observability/types.test.ts +726 -0
- package/src/observability/types.ts +434 -0
- package/src/pglite/auto-demotion.test.ts +477 -0
- package/src/pglite/auto-demotion.ts +385 -0
- package/src/pglite/auto-promotion.test.ts +824 -0
- package/src/pglite/auto-promotion.ts +547 -0
- package/src/pglite/cache-layer.test.ts +469 -0
- package/src/pglite/cache-layer.ts +271 -0
- package/src/pglite/cold-start-manager.ts +1260 -0
- package/src/pglite/cold-start-optimizer.test.ts +937 -0
- package/src/pglite/cold-start-optimizer.ts +1895 -0
- package/src/pglite/dovfs-adapter.ts +1122 -0
- package/src/pglite/dovfs.ts +1258 -0
- package/src/pglite/etag-cache.test.ts +844 -0
- package/src/pglite/etag-cache.ts +526 -0
- package/src/pglite/index.ts +442 -0
- package/src/pglite/init.test.ts +455 -0
- package/src/pglite/init.ts +574 -0
- package/src/pglite/lifecycle.test.ts +599 -0
- package/src/pglite/lifecycle.ts +704 -0
- package/src/pglite/parallel-loader.test.ts +586 -0
- package/src/pglite/parallel-loader.ts +481 -0
- package/src/pglite/production-pglite.test.ts +666 -0
- package/src/pglite/production-pglite.ts +537 -0
- package/src/pglite/query-executor.ts +614 -0
- package/src/pglite/r2-layer.test.ts +501 -0
- package/src/pglite/r2-layer.ts +322 -0
- package/src/pglite/tiered-init.test.ts +725 -0
- package/src/pglite/tiered-init.ts +556 -0
- package/src/pglite/tiered-vfs.test.ts +726 -0
- package/src/pglite/tiered-vfs.ts +33 -0
- package/src/pglite/tiering-stats.test.ts +531 -0
- package/src/pglite/tiering-stats.ts +407 -0
- package/src/pglite/transaction-hooks.ts +343 -0
- package/src/pglite/warm-loader.test.ts +1701 -0
- package/src/pglite/warm-loader.ts +528 -0
- package/src/pglite/workers-pglite.ts +224 -0
- package/src/pglite-assets/pglite.data +0 -0
- package/src/pglite-assets/pglite.wasm +0 -0
- package/src/pglite.d.ts +47 -0
- package/src/playground/index.ts +137 -0
- package/src/playground/keyboard-shortcuts.ts +677 -0
- package/src/playground/playground.ts +323 -0
- package/src/playground/query-executor.ts +669 -0
- package/src/playground/query-history.ts +328 -0
- package/src/playground/result-formatter.ts +420 -0
- package/src/playground/sample-datasets.ts +674 -0
- package/src/playground/sample-queries.ts +1168 -0
- package/src/playground/schema-explorer.ts +558 -0
- package/src/playground/types.ts +518 -0
- package/src/readonly/cache-reader.test.ts +460 -0
- package/src/readonly/cache-reader.ts +313 -0
- package/src/readonly/config.test.ts +187 -0
- package/src/readonly/config.ts +128 -0
- package/src/readonly/index.ts +50 -0
- package/src/readonly/pglite-wrapper.test.ts +278 -0
- package/src/readonly/pglite-wrapper.ts +184 -0
- package/src/readonly/worker.test.ts +533 -0
- package/src/readonly/worker.ts +341 -0
- package/src/readonly/write-blocker.test.ts +459 -0
- package/src/readonly/write-blocker.ts +175 -0
- package/src/recovery/disaster-recovery.test.ts +618 -0
- package/src/recovery/disaster-recovery.ts +1181 -0
- package/src/recovery/index.ts +43 -0
- package/src/recovery/parquet-parser.ts +974 -0
- package/src/retention/index.ts +74 -0
- package/src/retention/policy.test.ts +571 -0
- package/src/retention/policy.ts +774 -0
- package/src/retention/purger.test.ts +465 -0
- package/src/retention/purger.ts +558 -0
- package/src/rls/auth-integration.test.ts +752 -0
- package/src/rls/auth-integration.ts +533 -0
- package/src/rls/generator.test.ts +829 -0
- package/src/rls/generator.ts +573 -0
- package/src/rls/index.ts +128 -0
- package/src/rls/policy.ts +208 -0
- package/src/rls/rls.test.ts +1071 -0
- package/src/rls/validator.test.ts +930 -0
- package/src/rls/validator.ts +895 -0
- package/src/routing/adaptive-router.test.ts +884 -0
- package/src/routing/adaptive-router.ts +845 -0
- package/src/routing/circuit-breaker.test.ts +1505 -0
- package/src/routing/circuit-breaker.ts +852 -0
- package/src/routing/cost-metrics.test.ts +565 -0
- package/src/routing/cost-metrics.ts +408 -0
- package/src/routing/do-connection-pool.test.ts +1109 -0
- package/src/routing/do-connection-pool.ts +828 -0
- package/src/routing/index.ts +158 -0
- package/src/routing/query-complexity-estimator.test.ts +356 -0
- package/src/routing/query-complexity-estimator.ts +444 -0
- package/src/routing/request-coalescing.test.ts +738 -0
- package/src/routing/request-coalescing.ts +475 -0
- package/src/routing/runtime-router.test.ts +436 -0
- package/src/routing/runtime-router.ts +357 -0
- package/src/routing/tenant-router.test.ts +2493 -0
- package/src/routing/tenant-router.ts +1908 -0
- package/src/routing/websocket-pool.test.ts +551 -0
- package/src/routing/websocket-pool.ts +577 -0
- package/src/storage/access-pattern-tracker.test.ts +874 -0
- package/src/storage/cache-layer.test.ts +560 -0
- package/src/storage/cache-layer.ts +328 -0
- package/src/storage/cost-aware-tiering.test.ts +652 -0
- package/src/storage/cost-aware-tiering.ts +794 -0
- package/src/storage/do-sqlite-blobs.test.ts +937 -0
- package/src/storage/index.ts +272 -0
- package/src/storage/interfaces.ts +974 -0
- package/src/storage/r2-layer.test.ts +653 -0
- package/src/storage/r2-layer.ts +434 -0
- package/src/storage/r2-overflow.ts +920 -0
- package/src/storage/r2-page-vfs.test.ts +2348 -0
- package/src/storage/r2-page-vfs.ts +1054 -0
- package/src/storage/swr-cache.test.ts +832 -0
- package/src/storage/swr-cache.ts +398 -0
- package/src/storage/swr-tiered-integration.test.ts +617 -0
- package/src/storage/tiered-orchestrator.test.ts +2441 -0
- package/src/storage/tiered-orchestrator.ts +2081 -0
- package/src/storage/tiered-vfs-swr.test.ts +736 -0
- package/src/storage/tiered-vfs-swr.ts +735 -0
- package/src/storage/tiered-vfs.test.ts +793 -0
- package/src/storage/tiered-vfs.ts +1082 -0
- package/src/streaming/backpressure-controller.ts +452 -0
- package/src/streaming/buffer-pool.ts +484 -0
- package/src/streaming/cdc-iceberg-connector.ts +605 -0
- package/src/streaming/index.ts +225 -0
- package/src/streaming/live-cdc-stream.ts +985 -0
- package/src/streaming/memory-bounded-stream.ts +443 -0
- package/src/streaming/query-streamer.ts +662 -0
- package/src/streaming/response-streaming.ts +557 -0
- package/src/types/branded.ts +1075 -0
- package/src/types/branded.ts.backup +273 -0
- package/src/types/utilities.ts +1023 -0
- package/src/types/wasm.d.ts +30 -0
- package/src/validation/typed-errors.test.ts +420 -0
- package/src/wal/replay-engine.ts +1264 -0
- package/src/worker/__mocks__/capnweb.ts +15 -0
- package/src/worker/__mocks__/pglite.data.ts +22 -0
- package/src/worker/__mocks__/pglite.wasm.ts +33 -0
- package/src/worker/auth-rate-limiter.test.ts +272 -0
- package/src/worker/auth-rate-limiter.ts +448 -0
- package/src/worker/auth.security-red.test.ts +1236 -0
- package/src/worker/auth.security.test.ts +822 -0
- package/src/worker/auth.test.ts +469 -0
- package/src/worker/auth.ts +1104 -0
- package/src/worker/cdc-backpressure.test.ts +726 -0
- package/src/worker/cdc-backpressure.ts +866 -0
- package/src/worker/cdc-sse.test.ts +780 -0
- package/src/worker/cdc-sse.ts +728 -0
- package/src/worker/cdc-websocket.ts +1229 -0
- package/src/worker/cdc-ws.test.ts +1009 -0
- package/src/worker/cdc.test.ts +327 -0
- package/src/worker/cdc.ts +289 -0
- package/src/worker/concerns/auth-concern.ts +179 -0
- package/src/worker/concerns/cdc-concern.ts +247 -0
- package/src/worker/concerns/index.ts +58 -0
- package/src/worker/concerns/query-execution-concern.ts +194 -0
- package/src/worker/concerns/storage-orchestration-concern.ts +373 -0
- package/src/worker/discriminated-types.test.ts +280 -0
- package/src/worker/do-auth-manager.ts +257 -0
- package/src/worker/do-decomposition.test.ts +1236 -0
- package/src/worker/do-pglite-manager.ts +302 -0
- package/src/worker/do.test.ts +2254 -0
- package/src/worker/do.ts +1878 -0
- package/src/worker/entry.ts +417 -0
- package/src/worker/errors.ts +285 -0
- package/src/worker/health-check-manager.test.ts +261 -0
- package/src/worker/health-check-manager.ts +231 -0
- package/src/worker/index.ts +389 -0
- package/src/worker/memory-pressure.test.ts +1460 -0
- package/src/worker/memory-pressure.ts +2650 -0
- package/src/worker/migration-manager.ts +582 -0
- package/src/worker/neon-compat.test.ts +332 -0
- package/src/worker/plugin-manager.ts +485 -0
- package/src/worker/postgres.do-rpc.d.ts +76 -0
- package/src/worker/proxy.ts +694 -0
- package/src/worker/query-execution-manager.test.ts +303 -0
- package/src/worker/query-execution-manager.ts +219 -0
- package/src/worker/query-executor.test.ts +282 -0
- package/src/worker/query-executor.ts +560 -0
- package/src/worker/query-stats-manager.ts +229 -0
- package/src/worker/result-handler.test.ts +364 -0
- package/src/worker/result-handler.ts +510 -0
- package/src/worker/routes.test.ts +795 -0
- package/src/worker/routes.ts +650 -0
- package/src/worker/rpc-methods-manager.test.ts +326 -0
- package/src/worker/rpc-methods-manager.ts +276 -0
- package/src/worker/rpc.ts +524 -0
- package/src/worker/schema-version.ts +605 -0
- package/src/worker/session-manager.test.ts +506 -0
- package/src/worker/session-manager.ts +732 -0
- package/src/worker/shutdown-manager.ts +469 -0
- package/src/worker/sql-transform.test.ts +286 -0
- package/src/worker/sql-transform.ts +368 -0
- package/src/worker/supabase-compat.test.ts +621 -0
- package/src/worker/types.test.ts +292 -0
- package/src/worker/types.ts +873 -0
- package/src/worker/user-routes.test.ts +703 -0
- package/src/worker/user-routes.ts +303 -0
- package/src/worker/wal-facade.ts +235 -0
- package/src/worker/wal-r2.test.ts +570 -0
- package/src/worker/wal-r2.ts +930 -0
- package/src/worker/wal-replay.test.ts +845 -0
- package/src/worker/wal-replay.ts +897 -0
- package/src/worker/wal-retention.test.ts +758 -0
- package/src/worker/wal-retention.ts +1075 -0
- package/src/worker/wal.test.ts +618 -0
- package/src/worker/wal.ts +697 -0
- package/src/worker/websocket.test.ts +296 -0
- package/src/worker/websocket.ts +284 -0
|
@@ -0,0 +1,1218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time Travel Query Tests
|
|
3
|
+
* Task: postgres-3kc - Time travel query API (query as-of timestamp)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
7
|
+
import {
|
|
8
|
+
parseTimestamp,
|
|
9
|
+
parseTimeTravelSQL,
|
|
10
|
+
buildTimeTravelSQL,
|
|
11
|
+
formatTimestamp,
|
|
12
|
+
IcebergTimeTravelReader,
|
|
13
|
+
createTimeTravelReader,
|
|
14
|
+
TimestampOutOfRangeError,
|
|
15
|
+
NoSnapshotFoundError,
|
|
16
|
+
InvalidTimestampError,
|
|
17
|
+
type ParsedTimestamp,
|
|
18
|
+
type TimeTravelQueryOptions,
|
|
19
|
+
type RowOperation,
|
|
20
|
+
type VersionSystemColumns,
|
|
21
|
+
type RowVersion,
|
|
22
|
+
type VersionsBetweenResult,
|
|
23
|
+
} from './time-travel'
|
|
24
|
+
import type { IcebergTableMetadata, IcebergSnapshot } from './types'
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Timestamp Parsing Tests
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
describe('Timestamp Parsing', () => {
|
|
31
|
+
describe('parseTimestamp', () => {
|
|
32
|
+
it('should parse epoch milliseconds (number)', () => {
|
|
33
|
+
const result = parseTimestamp(1704067200000)
|
|
34
|
+
|
|
35
|
+
expect(result.timestampMs).toBe(1704067200000)
|
|
36
|
+
expect(result.isRelative).toBe(false)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should parse Date object', () => {
|
|
40
|
+
const date = new Date('2024-01-01T00:00:00Z')
|
|
41
|
+
const result = parseTimestamp(date)
|
|
42
|
+
|
|
43
|
+
expect(result.timestampMs).toBe(date.getTime())
|
|
44
|
+
expect(result.isRelative).toBe(false)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('should parse ISO date string', () => {
|
|
48
|
+
const result = parseTimestamp('2024-01-01T00:00:00Z')
|
|
49
|
+
|
|
50
|
+
expect(result.timestampMs).toBe(1704067200000)
|
|
51
|
+
expect(result.isRelative).toBe(false)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should parse numeric string', () => {
|
|
55
|
+
const result = parseTimestamp('1704067200000')
|
|
56
|
+
|
|
57
|
+
expect(result.timestampMs).toBe(1704067200000)
|
|
58
|
+
expect(result.isRelative).toBe(false)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
describe('relative timestamps', () => {
|
|
62
|
+
const referenceTime = 1704153600000 // 2024-01-02T00:00:00Z
|
|
63
|
+
|
|
64
|
+
it('should parse "X seconds ago"', () => {
|
|
65
|
+
const result = parseTimestamp('30 seconds ago', referenceTime)
|
|
66
|
+
|
|
67
|
+
expect(result.timestampMs).toBe(referenceTime - 30 * 1000)
|
|
68
|
+
expect(result.isRelative).toBe(true)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should parse "X minutes ago"', () => {
|
|
72
|
+
const result = parseTimestamp('5 minutes ago', referenceTime)
|
|
73
|
+
|
|
74
|
+
expect(result.timestampMs).toBe(referenceTime - 5 * 60 * 1000)
|
|
75
|
+
expect(result.isRelative).toBe(true)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should parse "X hours ago"', () => {
|
|
79
|
+
const result = parseTimestamp('2 hours ago', referenceTime)
|
|
80
|
+
|
|
81
|
+
expect(result.timestampMs).toBe(referenceTime - 2 * 60 * 60 * 1000)
|
|
82
|
+
expect(result.isRelative).toBe(true)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('should parse "X days ago"', () => {
|
|
86
|
+
const result = parseTimestamp('1 day ago', referenceTime)
|
|
87
|
+
|
|
88
|
+
expect(result.timestampMs).toBe(referenceTime - 24 * 60 * 60 * 1000)
|
|
89
|
+
expect(result.isRelative).toBe(true)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('should parse "X weeks ago"', () => {
|
|
93
|
+
const result = parseTimestamp('2 weeks ago', referenceTime)
|
|
94
|
+
|
|
95
|
+
expect(result.timestampMs).toBe(referenceTime - 2 * 7 * 24 * 60 * 60 * 1000)
|
|
96
|
+
expect(result.isRelative).toBe(true)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should parse short forms (h, m, s, d, w)', () => {
|
|
100
|
+
expect(parseTimestamp('1h ago', referenceTime).timestampMs).toBe(
|
|
101
|
+
referenceTime - 60 * 60 * 1000
|
|
102
|
+
)
|
|
103
|
+
expect(parseTimestamp('30m ago', referenceTime).timestampMs).toBe(
|
|
104
|
+
referenceTime - 30 * 60 * 1000
|
|
105
|
+
)
|
|
106
|
+
expect(parseTimestamp('10s ago', referenceTime).timestampMs).toBe(
|
|
107
|
+
referenceTime - 10 * 1000
|
|
108
|
+
)
|
|
109
|
+
expect(parseTimestamp('3d ago', referenceTime).timestampMs).toBe(
|
|
110
|
+
referenceTime - 3 * 24 * 60 * 60 * 1000
|
|
111
|
+
)
|
|
112
|
+
expect(parseTimestamp('1w ago', referenceTime).timestampMs).toBe(
|
|
113
|
+
referenceTime - 7 * 24 * 60 * 60 * 1000
|
|
114
|
+
)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should be case insensitive', () => {
|
|
118
|
+
const result1 = parseTimestamp('1 HOUR AGO', referenceTime)
|
|
119
|
+
const result2 = parseTimestamp('1 Hour Ago', referenceTime)
|
|
120
|
+
|
|
121
|
+
expect(result1.timestampMs).toBe(result2.timestampMs)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('should parse "X years ago"', () => {
|
|
125
|
+
const result = parseTimestamp('1 year ago', referenceTime)
|
|
126
|
+
|
|
127
|
+
expect(result.timestampMs).toBe(referenceTime - 365 * 24 * 60 * 60 * 1000)
|
|
128
|
+
expect(result.isRelative).toBe(true)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('should parse short form year (1y ago)', () => {
|
|
132
|
+
const result = parseTimestamp('1y ago', referenceTime)
|
|
133
|
+
|
|
134
|
+
expect(result.timestampMs).toBe(referenceTime - 365 * 24 * 60 * 60 * 1000)
|
|
135
|
+
expect(result.isRelative).toBe(true)
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('NOW() and CURRENT_TIMESTAMP', () => {
|
|
140
|
+
const referenceTime = 1704153600000 // 2024-01-02T00:00:00Z
|
|
141
|
+
|
|
142
|
+
it('should parse NOW()', () => {
|
|
143
|
+
const result = parseTimestamp('NOW()', referenceTime)
|
|
144
|
+
|
|
145
|
+
expect(result.timestampMs).toBe(referenceTime)
|
|
146
|
+
expect(result.isRelative).toBe(true)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should parse now() (lowercase)', () => {
|
|
150
|
+
const result = parseTimestamp('now()', referenceTime)
|
|
151
|
+
|
|
152
|
+
expect(result.timestampMs).toBe(referenceTime)
|
|
153
|
+
expect(result.isRelative).toBe(true)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('should parse CURRENT_TIMESTAMP', () => {
|
|
157
|
+
const result = parseTimestamp('CURRENT_TIMESTAMP', referenceTime)
|
|
158
|
+
|
|
159
|
+
expect(result.timestampMs).toBe(referenceTime)
|
|
160
|
+
expect(result.isRelative).toBe(true)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('should parse current_timestamp (lowercase)', () => {
|
|
164
|
+
const result = parseTimestamp('current_timestamp', referenceTime)
|
|
165
|
+
|
|
166
|
+
expect(result.timestampMs).toBe(referenceTime)
|
|
167
|
+
expect(result.isRelative).toBe(true)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
describe('SQL INTERVAL expressions', () => {
|
|
172
|
+
const referenceTime = 1704153600000 // 2024-01-02T00:00:00Z
|
|
173
|
+
|
|
174
|
+
it("should parse NOW() - INTERVAL '1 hour'", () => {
|
|
175
|
+
const result = parseTimestamp("NOW() - INTERVAL '1 hour'", referenceTime)
|
|
176
|
+
|
|
177
|
+
expect(result.timestampMs).toBe(referenceTime - 60 * 60 * 1000)
|
|
178
|
+
expect(result.isRelative).toBe(true)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it("should parse CURRENT_TIMESTAMP - INTERVAL '30 minutes'", () => {
|
|
182
|
+
const result = parseTimestamp("CURRENT_TIMESTAMP - INTERVAL '30 minutes'", referenceTime)
|
|
183
|
+
|
|
184
|
+
expect(result.timestampMs).toBe(referenceTime - 30 * 60 * 1000)
|
|
185
|
+
expect(result.isRelative).toBe(true)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it("should parse now() - interval '2 days'", () => {
|
|
189
|
+
const result = parseTimestamp("now() - interval '2 days'", referenceTime)
|
|
190
|
+
|
|
191
|
+
expect(result.timestampMs).toBe(referenceTime - 2 * 24 * 60 * 60 * 1000)
|
|
192
|
+
expect(result.isRelative).toBe(true)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it("should parse INTERVAL '1 hour' (standalone)", () => {
|
|
196
|
+
const result = parseTimestamp("INTERVAL '1 hour'", referenceTime)
|
|
197
|
+
|
|
198
|
+
expect(result.timestampMs).toBe(referenceTime - 60 * 60 * 1000)
|
|
199
|
+
expect(result.isRelative).toBe(true)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it("should parse interval '1 week' (standalone)", () => {
|
|
203
|
+
const result = parseTimestamp("interval '1 week'", referenceTime)
|
|
204
|
+
|
|
205
|
+
expect(result.timestampMs).toBe(referenceTime - 7 * 24 * 60 * 60 * 1000)
|
|
206
|
+
expect(result.isRelative).toBe(true)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it("should parse interval with various units", () => {
|
|
210
|
+
expect(parseTimestamp("INTERVAL '100 ms'", referenceTime).timestampMs).toBe(
|
|
211
|
+
referenceTime - 100
|
|
212
|
+
)
|
|
213
|
+
expect(parseTimestamp("INTERVAL '45 seconds'", referenceTime).timestampMs).toBe(
|
|
214
|
+
referenceTime - 45 * 1000
|
|
215
|
+
)
|
|
216
|
+
expect(parseTimestamp("INTERVAL '15 min'", referenceTime).timestampMs).toBe(
|
|
217
|
+
referenceTime - 15 * 60 * 1000
|
|
218
|
+
)
|
|
219
|
+
expect(parseTimestamp("INTERVAL '3 months'", referenceTime).timestampMs).toBe(
|
|
220
|
+
referenceTime - 3 * 30 * 24 * 60 * 60 * 1000
|
|
221
|
+
)
|
|
222
|
+
expect(parseTimestamp("INTERVAL '1 year'", referenceTime).timestampMs).toBe(
|
|
223
|
+
referenceTime - 365 * 24 * 60 * 60 * 1000
|
|
224
|
+
)
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('should throw InvalidTimestampError for invalid input', () => {
|
|
229
|
+
expect(() => parseTimestamp('invalid')).toThrow(InvalidTimestampError)
|
|
230
|
+
expect(() => parseTimestamp('yesterday')).toThrow(InvalidTimestampError)
|
|
231
|
+
expect(() => parseTimestamp('')).toThrow(InvalidTimestampError)
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
describe('formatTimestamp', () => {
|
|
236
|
+
it('should format timestamp as ISO string', () => {
|
|
237
|
+
const result = formatTimestamp(1704067200000)
|
|
238
|
+
|
|
239
|
+
expect(result).toBe('2024-01-01T00:00:00.000Z')
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
// ============================================================================
|
|
245
|
+
// SQL AS OF Parser Tests
|
|
246
|
+
// ============================================================================
|
|
247
|
+
|
|
248
|
+
describe('SQL AS OF Parser', () => {
|
|
249
|
+
describe('parseTimeTravelSQL', () => {
|
|
250
|
+
it('should parse SQL with AS OF TIMESTAMP clause', () => {
|
|
251
|
+
const sql = "SELECT * FROM users AS OF TIMESTAMP '2024-01-01T00:00:00Z' WHERE id = 1"
|
|
252
|
+
const result = parseTimeTravelSQL(sql)
|
|
253
|
+
|
|
254
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
255
|
+
expect(result.timestamp?.timestampMs).toBe(1704067200000)
|
|
256
|
+
expect(result.cleanSql).toBe('SELECT * FROM users WHERE id = 1')
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it('should parse SQL with AS OF SYSTEM TIME clause', () => {
|
|
260
|
+
const sql = "SELECT * FROM users AS OF SYSTEM TIME '2024-01-01T00:00:00Z'"
|
|
261
|
+
const result = parseTimeTravelSQL(sql)
|
|
262
|
+
|
|
263
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
264
|
+
expect(result.timestamp?.timestampMs).toBe(1704067200000)
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('should parse SQL with FOR SYSTEM_TIME AS OF clause', () => {
|
|
268
|
+
const sql = "SELECT * FROM users FOR SYSTEM_TIME AS OF '2024-01-01'"
|
|
269
|
+
const result = parseTimeTravelSQL(sql)
|
|
270
|
+
|
|
271
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
272
|
+
expect(result.timestamp).toBeDefined()
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('should handle SQL without AS OF clause', () => {
|
|
276
|
+
const sql = 'SELECT * FROM users WHERE id = 1'
|
|
277
|
+
const result = parseTimeTravelSQL(sql)
|
|
278
|
+
|
|
279
|
+
expect(result.hasTimeTravelClause).toBe(false)
|
|
280
|
+
expect(result.timestamp).toBeUndefined()
|
|
281
|
+
expect(result.cleanSql).toBe(sql)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('should extract table name', () => {
|
|
285
|
+
const sql = "SELECT * FROM events AS OF TIMESTAMP '2024-01-01'"
|
|
286
|
+
const result = parseTimeTravelSQL(sql)
|
|
287
|
+
|
|
288
|
+
expect(result.tableName).toBe('events')
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should handle double-quoted timestamps', () => {
|
|
292
|
+
const sql = 'SELECT * FROM users AS OF TIMESTAMP "2024-01-01T00:00:00Z"'
|
|
293
|
+
const result = parseTimeTravelSQL(sql)
|
|
294
|
+
|
|
295
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
296
|
+
expect(result.timestamp?.timestampMs).toBe(1704067200000)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
it('should parse AS OF TIMESTAMP with relative timestamp', () => {
|
|
300
|
+
const sql = "SELECT * FROM users AS OF TIMESTAMP '1 hour ago'"
|
|
301
|
+
const result = parseTimeTravelSQL(sql)
|
|
302
|
+
|
|
303
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
304
|
+
expect(result.timestamp?.isRelative).toBe(true)
|
|
305
|
+
expect(result.cleanSql).toBe('SELECT * FROM users')
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it("should parse AS OF TIMESTAMP NOW() - INTERVAL '1 hour'", () => {
|
|
309
|
+
const sql = "SELECT * FROM users AS OF TIMESTAMP NOW() - INTERVAL '1 hour' WHERE id = 1"
|
|
310
|
+
const result = parseTimeTravelSQL(sql)
|
|
311
|
+
|
|
312
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
313
|
+
expect(result.timestamp?.isRelative).toBe(true)
|
|
314
|
+
expect(result.cleanSql).toBe('SELECT * FROM users WHERE id = 1')
|
|
315
|
+
expect(result.tableName).toBe('users')
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
it("should parse AS OF TIMESTAMP CURRENT_TIMESTAMP - INTERVAL '30 minutes'", () => {
|
|
319
|
+
const sql = "SELECT * FROM orders AS OF TIMESTAMP CURRENT_TIMESTAMP - INTERVAL '30 minutes'"
|
|
320
|
+
const result = parseTimeTravelSQL(sql)
|
|
321
|
+
|
|
322
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
323
|
+
expect(result.timestamp?.isRelative).toBe(true)
|
|
324
|
+
expect(result.cleanSql).toBe('SELECT * FROM orders')
|
|
325
|
+
expect(result.tableName).toBe('orders')
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('should parse AS OF TIMESTAMP NOW()', () => {
|
|
329
|
+
const sql = 'SELECT * FROM events AS OF TIMESTAMP NOW()'
|
|
330
|
+
const result = parseTimeTravelSQL(sql)
|
|
331
|
+
|
|
332
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
333
|
+
expect(result.timestamp?.isRelative).toBe(true)
|
|
334
|
+
expect(result.cleanSql).toBe('SELECT * FROM events')
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
it('should parse AS OF TIMESTAMP CURRENT_TIMESTAMP', () => {
|
|
338
|
+
const sql = 'SELECT * FROM logs AS OF TIMESTAMP CURRENT_TIMESTAMP'
|
|
339
|
+
const result = parseTimeTravelSQL(sql)
|
|
340
|
+
|
|
341
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
342
|
+
expect(result.timestamp?.isRelative).toBe(true)
|
|
343
|
+
expect(result.cleanSql).toBe('SELECT * FROM logs')
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
it('should preserve complex WHERE clauses', () => {
|
|
347
|
+
const sql = "SELECT id, name FROM users AS OF TIMESTAMP '2024-01-01' WHERE age > 21 AND status = 'active' ORDER BY name"
|
|
348
|
+
const result = parseTimeTravelSQL(sql)
|
|
349
|
+
|
|
350
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
351
|
+
expect(result.cleanSql).toBe("SELECT id, name FROM users WHERE age > 21 AND status = 'active' ORDER BY name")
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
it('should handle quoted table names', () => {
|
|
355
|
+
const sql = 'SELECT * FROM "my_table" AS OF TIMESTAMP \'2024-01-01\''
|
|
356
|
+
const result = parseTimeTravelSQL(sql)
|
|
357
|
+
|
|
358
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
359
|
+
// Note: table name extraction may not work for quoted tables
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
describe('buildTimeTravelSQL', () => {
|
|
364
|
+
it('should add AS OF clause to SQL', () => {
|
|
365
|
+
const sql = 'SELECT * FROM users WHERE id = 1'
|
|
366
|
+
const result = buildTimeTravelSQL(sql, '2024-01-01T00:00:00Z')
|
|
367
|
+
|
|
368
|
+
expect(result).toContain("AS OF TIMESTAMP '2024-01-01T00:00:00.000Z'")
|
|
369
|
+
expect(result).toContain('FROM users')
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
it('should insert after specific table name', () => {
|
|
373
|
+
const sql = 'SELECT * FROM users WHERE id = 1'
|
|
374
|
+
const result = buildTimeTravelSQL(sql, '2024-01-01T00:00:00Z', 'users')
|
|
375
|
+
|
|
376
|
+
expect(result).toBe(
|
|
377
|
+
"SELECT * FROM users AS OF TIMESTAMP '2024-01-01T00:00:00.000Z' WHERE id = 1"
|
|
378
|
+
)
|
|
379
|
+
})
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
// ============================================================================
|
|
384
|
+
// Time Travel Reader Tests
|
|
385
|
+
// ============================================================================
|
|
386
|
+
|
|
387
|
+
describe('IcebergTimeTravelReader', () => {
|
|
388
|
+
// Mock R2 bucket
|
|
389
|
+
const mockBucket = {
|
|
390
|
+
get: vi.fn(),
|
|
391
|
+
put: vi.fn(),
|
|
392
|
+
head: vi.fn(),
|
|
393
|
+
list: vi.fn(),
|
|
394
|
+
delete: vi.fn(),
|
|
395
|
+
} as unknown as R2Bucket
|
|
396
|
+
|
|
397
|
+
let reader: IcebergTimeTravelReader
|
|
398
|
+
|
|
399
|
+
// Sample metadata with snapshots
|
|
400
|
+
const createMetadata = (
|
|
401
|
+
snapshots: Array<{ id: number; timestampMs: number }>
|
|
402
|
+
): IcebergTableMetadata => ({
|
|
403
|
+
'format-version': 2,
|
|
404
|
+
'table-uuid': 'test-uuid',
|
|
405
|
+
location: 'iceberg/test',
|
|
406
|
+
'last-sequence-number': snapshots.length,
|
|
407
|
+
'last-updated-ms': Date.now(),
|
|
408
|
+
'last-column-id': 10,
|
|
409
|
+
'current-schema-id': 0,
|
|
410
|
+
schemas: [{ type: 'struct', 'schema-id': 0, fields: [] }],
|
|
411
|
+
'default-spec-id': 0,
|
|
412
|
+
'partition-specs': [{ 'spec-id': 0, fields: [] }],
|
|
413
|
+
'last-partition-id': 0,
|
|
414
|
+
'default-sort-order-id': 0,
|
|
415
|
+
'sort-orders': [{ 'order-id': 0, fields: [] }],
|
|
416
|
+
'current-snapshot-id': snapshots.length > 0 ? snapshots[snapshots.length - 1]!.id : undefined,
|
|
417
|
+
snapshots: snapshots.map((s, i) => ({
|
|
418
|
+
'snapshot-id': s.id,
|
|
419
|
+
'sequence-number': i + 1,
|
|
420
|
+
'timestamp-ms': s.timestampMs,
|
|
421
|
+
'manifest-list': `iceberg/test/metadata/snap-${s.id}.avro`,
|
|
422
|
+
summary: { operation: 'append' as const },
|
|
423
|
+
})),
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
beforeEach(() => {
|
|
427
|
+
vi.clearAllMocks()
|
|
428
|
+
reader = createTimeTravelReader({ bucket: mockBucket })
|
|
429
|
+
})
|
|
430
|
+
|
|
431
|
+
describe('findSnapshotAtTimestamp', () => {
|
|
432
|
+
it('should find exact matching snapshot', async () => {
|
|
433
|
+
const metadata = createMetadata([
|
|
434
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
435
|
+
{ id: 2, timestampMs: 1704153600000 },
|
|
436
|
+
{ id: 3, timestampMs: 1704240000000 },
|
|
437
|
+
])
|
|
438
|
+
|
|
439
|
+
const result = await reader.findSnapshotAtTimestamp(
|
|
440
|
+
metadata,
|
|
441
|
+
1704153600000
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
expect(result.snapshot['snapshot-id']).toBe(2)
|
|
445
|
+
expect(result.exactMatch).toBe(true)
|
|
446
|
+
expect(result.timeDifferenceMs).toBe(0)
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
it('should find nearest earlier snapshot', async () => {
|
|
450
|
+
const metadata = createMetadata([
|
|
451
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
452
|
+
{ id: 2, timestampMs: 1704153600000 },
|
|
453
|
+
{ id: 3, timestampMs: 1704240000000 },
|
|
454
|
+
])
|
|
455
|
+
|
|
456
|
+
// Query time between snapshot 2 and 3
|
|
457
|
+
const queryTime = 1704200000000
|
|
458
|
+
const result = await reader.findSnapshotAtTimestamp(metadata, queryTime)
|
|
459
|
+
|
|
460
|
+
expect(result.snapshot['snapshot-id']).toBe(2)
|
|
461
|
+
expect(result.exactMatch).toBe(false)
|
|
462
|
+
expect(result.timeDifferenceMs).toBe(queryTime - 1704153600000)
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
it('should throw NoSnapshotFoundError when no snapshots exist', async () => {
|
|
466
|
+
const metadata = createMetadata([])
|
|
467
|
+
|
|
468
|
+
await expect(
|
|
469
|
+
reader.findSnapshotAtTimestamp(metadata, Date.now())
|
|
470
|
+
).rejects.toThrow(NoSnapshotFoundError)
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
it('should throw TimestampOutOfRangeError for future timestamps', async () => {
|
|
474
|
+
const metadata = createMetadata([
|
|
475
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
476
|
+
])
|
|
477
|
+
|
|
478
|
+
const futureTime = Date.now() + 1000000
|
|
479
|
+
|
|
480
|
+
await expect(
|
|
481
|
+
reader.findSnapshotAtTimestamp(metadata, futureTime)
|
|
482
|
+
).rejects.toThrow(TimestampOutOfRangeError)
|
|
483
|
+
})
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
describe('findSnapshotsInRange', () => {
|
|
487
|
+
it('should find all snapshots in time range', async () => {
|
|
488
|
+
const metadata = createMetadata([
|
|
489
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
490
|
+
{ id: 2, timestampMs: 1704153600000 },
|
|
491
|
+
{ id: 3, timestampMs: 1704240000000 },
|
|
492
|
+
{ id: 4, timestampMs: 1704326400000 },
|
|
493
|
+
])
|
|
494
|
+
|
|
495
|
+
const snapshots = await reader.findSnapshotsInRange(
|
|
496
|
+
metadata,
|
|
497
|
+
1704100000000,
|
|
498
|
+
1704250000000
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
expect(snapshots).toHaveLength(2)
|
|
502
|
+
expect(snapshots.map((s) => s['snapshot-id'])).toEqual([2, 3])
|
|
503
|
+
})
|
|
504
|
+
})
|
|
505
|
+
|
|
506
|
+
describe('getDataFilesForSnapshot', () => {
|
|
507
|
+
it('should load data files from manifest list', async () => {
|
|
508
|
+
const metadata = createMetadata([
|
|
509
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
510
|
+
])
|
|
511
|
+
|
|
512
|
+
const mockManifestList = {
|
|
513
|
+
text: vi.fn().mockResolvedValue(
|
|
514
|
+
JSON.stringify({
|
|
515
|
+
manifests: [
|
|
516
|
+
{
|
|
517
|
+
'manifest-path': 'iceberg/test/metadata/manifest-1.avro',
|
|
518
|
+
'manifest-length': 1000,
|
|
519
|
+
'partition-spec-id': 0,
|
|
520
|
+
content: 0,
|
|
521
|
+
'sequence-number': 1,
|
|
522
|
+
'min-sequence-number': 1,
|
|
523
|
+
'added-snapshot-id': 1,
|
|
524
|
+
'added-files-count': 1,
|
|
525
|
+
'existing-files-count': 0,
|
|
526
|
+
'deleted-files-count': 0,
|
|
527
|
+
'added-rows-count': 100,
|
|
528
|
+
'existing-rows-count': 0,
|
|
529
|
+
'deleted-rows-count': 0,
|
|
530
|
+
},
|
|
531
|
+
],
|
|
532
|
+
})
|
|
533
|
+
),
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const mockManifest = {
|
|
537
|
+
text: vi.fn().mockResolvedValue(
|
|
538
|
+
JSON.stringify({
|
|
539
|
+
entries: [
|
|
540
|
+
{
|
|
541
|
+
status: 1, // ADDED
|
|
542
|
+
'data-file': {
|
|
543
|
+
content: 'data',
|
|
544
|
+
'file-path': 'iceberg/test/data/file1.parquet',
|
|
545
|
+
'file-format': 'parquet',
|
|
546
|
+
partition: {},
|
|
547
|
+
'record-count': 100,
|
|
548
|
+
'file-size-in-bytes': 5000,
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
})
|
|
553
|
+
),
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>)
|
|
557
|
+
.mockResolvedValueOnce(mockManifestList)
|
|
558
|
+
.mockResolvedValueOnce(mockManifest)
|
|
559
|
+
|
|
560
|
+
const snapshot = metadata.snapshots![0]!
|
|
561
|
+
const result = await reader.getDataFilesForSnapshot(metadata, snapshot)
|
|
562
|
+
|
|
563
|
+
expect(result.dataFiles).toHaveLength(1)
|
|
564
|
+
expect(result.dataFiles[0]!['file-path']).toBe('iceberg/test/data/file1.parquet')
|
|
565
|
+
expect(result.metadata.totalRecords).toBe(100)
|
|
566
|
+
})
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
describe('resolveDataFiles', () => {
|
|
570
|
+
it('should resolve data files for point-in-time query', async () => {
|
|
571
|
+
const metadata = createMetadata([
|
|
572
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
573
|
+
])
|
|
574
|
+
|
|
575
|
+
const mockManifestList = {
|
|
576
|
+
text: vi.fn().mockResolvedValue(JSON.stringify({ manifests: [] })),
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
580
|
+
mockManifestList
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
const options: TimeTravelQueryOptions = {
|
|
584
|
+
asOf: 1704067200000,
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const result = await reader.resolveDataFiles(metadata, options)
|
|
588
|
+
|
|
589
|
+
expect(result.metadata.mode).toBe('point-in-time')
|
|
590
|
+
expect(result.metadata.snapshotId).toBe(1)
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
it('should use latest mode when no timestamp provided', async () => {
|
|
594
|
+
const metadata = createMetadata([
|
|
595
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
596
|
+
])
|
|
597
|
+
|
|
598
|
+
const mockManifestList = {
|
|
599
|
+
text: vi.fn().mockResolvedValue(JSON.stringify({ manifests: [] })),
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
603
|
+
mockManifestList
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
const result = await reader.resolveDataFiles(metadata, {})
|
|
607
|
+
|
|
608
|
+
expect(result.metadata.mode).toBe('latest')
|
|
609
|
+
})
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
describe('getAvailableTimeRange', () => {
|
|
613
|
+
it('should return oldest and newest timestamps', () => {
|
|
614
|
+
const metadata = createMetadata([
|
|
615
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
616
|
+
{ id: 2, timestampMs: 1704153600000 },
|
|
617
|
+
{ id: 3, timestampMs: 1704240000000 },
|
|
618
|
+
])
|
|
619
|
+
|
|
620
|
+
const range = reader.getAvailableTimeRange(metadata)
|
|
621
|
+
|
|
622
|
+
expect(range.oldest).toBe(1704067200000)
|
|
623
|
+
expect(range.newest).toBe(1704240000000)
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
it('should return null for empty snapshots', () => {
|
|
627
|
+
const metadata = createMetadata([])
|
|
628
|
+
|
|
629
|
+
const range = reader.getAvailableTimeRange(metadata)
|
|
630
|
+
|
|
631
|
+
expect(range.oldest).toBeNull()
|
|
632
|
+
expect(range.newest).toBeNull()
|
|
633
|
+
})
|
|
634
|
+
})
|
|
635
|
+
|
|
636
|
+
describe('listSnapshots', () => {
|
|
637
|
+
it('should list snapshots sorted by timestamp descending', () => {
|
|
638
|
+
const metadata = createMetadata([
|
|
639
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
640
|
+
{ id: 2, timestampMs: 1704153600000 },
|
|
641
|
+
{ id: 3, timestampMs: 1704240000000 },
|
|
642
|
+
])
|
|
643
|
+
|
|
644
|
+
const snapshots = reader.listSnapshots(metadata)
|
|
645
|
+
|
|
646
|
+
expect(snapshots).toHaveLength(3)
|
|
647
|
+
expect(snapshots[0]!.snapshotId).toBe(3)
|
|
648
|
+
expect(snapshots[2]!.snapshotId).toBe(1)
|
|
649
|
+
})
|
|
650
|
+
})
|
|
651
|
+
|
|
652
|
+
describe('caching', () => {
|
|
653
|
+
it('should cache manifest list data', async () => {
|
|
654
|
+
const metadata = createMetadata([
|
|
655
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
656
|
+
])
|
|
657
|
+
|
|
658
|
+
const mockManifestList = {
|
|
659
|
+
text: vi.fn().mockResolvedValue(JSON.stringify({ manifests: [] })),
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
663
|
+
mockManifestList
|
|
664
|
+
)
|
|
665
|
+
|
|
666
|
+
const snapshot = metadata.snapshots![0]!
|
|
667
|
+
|
|
668
|
+
// First call
|
|
669
|
+
await reader.getDataFilesForSnapshot(metadata, snapshot)
|
|
670
|
+
// Second call - should use cache
|
|
671
|
+
await reader.getDataFilesForSnapshot(metadata, snapshot)
|
|
672
|
+
|
|
673
|
+
// Should only call bucket.get once for manifest list
|
|
674
|
+
expect(mockBucket.get).toHaveBeenCalledTimes(1)
|
|
675
|
+
|
|
676
|
+
const stats = reader.getCacheStats()
|
|
677
|
+
expect(stats.size).toBe(1)
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('should clear cache', async () => {
|
|
681
|
+
const metadata = createMetadata([
|
|
682
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
683
|
+
])
|
|
684
|
+
|
|
685
|
+
const mockManifestList = {
|
|
686
|
+
text: vi.fn().mockResolvedValue(JSON.stringify({ manifests: [] })),
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
690
|
+
mockManifestList
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
const snapshot = metadata.snapshots![0]!
|
|
694
|
+
await reader.getDataFilesForSnapshot(metadata, snapshot)
|
|
695
|
+
|
|
696
|
+
reader.clearCache()
|
|
697
|
+
|
|
698
|
+
const stats = reader.getCacheStats()
|
|
699
|
+
expect(stats.size).toBe(0)
|
|
700
|
+
})
|
|
701
|
+
})
|
|
702
|
+
})
|
|
703
|
+
|
|
704
|
+
// ============================================================================
|
|
705
|
+
// Integration-like Tests
|
|
706
|
+
// ============================================================================
|
|
707
|
+
|
|
708
|
+
describe('Time Travel Integration', () => {
|
|
709
|
+
it('should support complete time travel query workflow', async () => {
|
|
710
|
+
// This tests the full flow from SQL parsing to snapshot resolution
|
|
711
|
+
|
|
712
|
+
// 1. Parse SQL with AS OF clause
|
|
713
|
+
const sql = "SELECT * FROM events AS OF TIMESTAMP '2024-01-01T12:00:00Z' WHERE type = 'click'"
|
|
714
|
+
const parsed = parseTimeTravelSQL(sql)
|
|
715
|
+
|
|
716
|
+
expect(parsed.hasTimeTravelClause).toBe(true)
|
|
717
|
+
expect(parsed.cleanSql).toBe("SELECT * FROM events WHERE type = 'click'")
|
|
718
|
+
expect(parsed.tableName).toBe('events')
|
|
719
|
+
|
|
720
|
+
// 2. Parse the timestamp
|
|
721
|
+
const timestamp = parsed.timestamp!
|
|
722
|
+
expect(timestamp.timestampMs).toBe(1704110400000) // 2024-01-01T12:00:00Z
|
|
723
|
+
|
|
724
|
+
// 3. Format for display
|
|
725
|
+
const formatted = formatTimestamp(timestamp.timestampMs)
|
|
726
|
+
expect(formatted).toBe('2024-01-01T12:00:00.000Z')
|
|
727
|
+
})
|
|
728
|
+
|
|
729
|
+
it('should support relative timestamp workflow', async () => {
|
|
730
|
+
const referenceTime = 1704153600000 // 2024-01-02T00:00:00Z
|
|
731
|
+
|
|
732
|
+
// User requests "1 hour ago"
|
|
733
|
+
const timestamp = parseTimestamp('1 hour ago', referenceTime)
|
|
734
|
+
|
|
735
|
+
expect(timestamp.isRelative).toBe(true)
|
|
736
|
+
expect(timestamp.timestampMs).toBe(1704150000000) // 1 hour before reference
|
|
737
|
+
|
|
738
|
+
// Build SQL with resolved timestamp
|
|
739
|
+
const sql = 'SELECT * FROM users'
|
|
740
|
+
const timeTravelSql = buildTimeTravelSQL(sql, timestamp.timestampMs)
|
|
741
|
+
|
|
742
|
+
expect(timeTravelSql).toContain("AS OF TIMESTAMP '2024-01-01T23:00:00.000Z'")
|
|
743
|
+
})
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
// ============================================================================
|
|
747
|
+
// VERSIONS BETWEEN Tests
|
|
748
|
+
// ============================================================================
|
|
749
|
+
|
|
750
|
+
describe('VERSIONS BETWEEN Query Support', () => {
|
|
751
|
+
describe('parseTimeTravelSQL - VERSIONS BETWEEN', () => {
|
|
752
|
+
it('should parse basic VERSIONS BETWEEN syntax', () => {
|
|
753
|
+
const sql = "SELECT * FROM users VERSIONS BETWEEN '2024-01-01' AND '2024-01-15'"
|
|
754
|
+
const result = parseTimeTravelSQL(sql)
|
|
755
|
+
|
|
756
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
757
|
+
expect(result.mode).toBe('versions-between')
|
|
758
|
+
expect(result.startTimestamp?.timestampMs).toBe(1704067200000) // 2024-01-01
|
|
759
|
+
expect(result.endTimestamp?.timestampMs).toBe(1705276800000) // 2024-01-15
|
|
760
|
+
expect(result.cleanSql).toBe('SELECT * FROM users')
|
|
761
|
+
expect(result.tableName).toBe('users')
|
|
762
|
+
})
|
|
763
|
+
|
|
764
|
+
it('should parse VERSIONS BETWEEN with TIMESTAMP keyword', () => {
|
|
765
|
+
const sql = "SELECT * FROM orders VERSIONS BETWEEN TIMESTAMP '2024-01-01' AND TIMESTAMP '2024-01-15'"
|
|
766
|
+
const result = parseTimeTravelSQL(sql)
|
|
767
|
+
|
|
768
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
769
|
+
expect(result.mode).toBe('versions-between')
|
|
770
|
+
expect(result.startTimestamp?.timestampMs).toBe(1704067200000)
|
|
771
|
+
expect(result.endTimestamp?.timestampMs).toBe(1705276800000)
|
|
772
|
+
expect(result.cleanSql).toBe('SELECT * FROM orders')
|
|
773
|
+
})
|
|
774
|
+
|
|
775
|
+
it('should parse VERSIONS BETWEEN with CURRENT_TIMESTAMP', () => {
|
|
776
|
+
const sql = "SELECT * FROM orders VERSIONS BETWEEN TIMESTAMP '2024-01-01' AND CURRENT_TIMESTAMP"
|
|
777
|
+
const result = parseTimeTravelSQL(sql)
|
|
778
|
+
|
|
779
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
780
|
+
expect(result.mode).toBe('versions-between')
|
|
781
|
+
expect(result.startTimestamp?.timestampMs).toBe(1704067200000)
|
|
782
|
+
expect(result.endTimestamp?.isRelative).toBe(true)
|
|
783
|
+
expect(result.cleanSql).toBe('SELECT * FROM orders')
|
|
784
|
+
})
|
|
785
|
+
|
|
786
|
+
it('should parse VERSIONS BETWEEN with NOW()', () => {
|
|
787
|
+
const sql = "SELECT * FROM events VERSIONS BETWEEN '2024-01-01' AND NOW()"
|
|
788
|
+
const result = parseTimeTravelSQL(sql)
|
|
789
|
+
|
|
790
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
791
|
+
expect(result.mode).toBe('versions-between')
|
|
792
|
+
expect(result.startTimestamp?.timestampMs).toBe(1704067200000)
|
|
793
|
+
expect(result.endTimestamp?.isRelative).toBe(true)
|
|
794
|
+
expect(result.tableName).toBe('events')
|
|
795
|
+
})
|
|
796
|
+
|
|
797
|
+
it('should preserve WHERE clause in VERSIONS BETWEEN', () => {
|
|
798
|
+
const sql = "SELECT * FROM users VERSIONS BETWEEN '2024-01-01' AND '2024-01-15' WHERE customer_id = 123"
|
|
799
|
+
const result = parseTimeTravelSQL(sql)
|
|
800
|
+
|
|
801
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
802
|
+
expect(result.mode).toBe('versions-between')
|
|
803
|
+
expect(result.cleanSql).toBe('SELECT * FROM users WHERE customer_id = 123')
|
|
804
|
+
})
|
|
805
|
+
|
|
806
|
+
it('should handle full ISO timestamps in VERSIONS BETWEEN', () => {
|
|
807
|
+
const sql = "SELECT * FROM events VERSIONS BETWEEN TIMESTAMP '2024-01-01T00:00:00Z' AND TIMESTAMP '2024-01-15T23:59:59Z'"
|
|
808
|
+
const result = parseTimeTravelSQL(sql)
|
|
809
|
+
|
|
810
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
811
|
+
expect(result.mode).toBe('versions-between')
|
|
812
|
+
expect(result.startTimestamp?.timestampMs).toBe(1704067200000)
|
|
813
|
+
expect(result.endTimestamp?.timestampMs).toBe(1705363199000)
|
|
814
|
+
})
|
|
815
|
+
|
|
816
|
+
it('should handle complex SELECT with VERSIONS BETWEEN', () => {
|
|
817
|
+
const sql = "SELECT user_id, name, _operation, _valid_from, _valid_to FROM users VERSIONS BETWEEN '2024-01-01' AND '2024-01-15' WHERE active = true ORDER BY _valid_from"
|
|
818
|
+
const result = parseTimeTravelSQL(sql)
|
|
819
|
+
|
|
820
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
821
|
+
expect(result.mode).toBe('versions-between')
|
|
822
|
+
expect(result.cleanSql).toContain('SELECT user_id, name, _operation, _valid_from, _valid_to FROM users')
|
|
823
|
+
expect(result.cleanSql).toContain('WHERE active = true ORDER BY _valid_from')
|
|
824
|
+
})
|
|
825
|
+
|
|
826
|
+
it('should not match partial VERSIONS BETWEEN syntax', () => {
|
|
827
|
+
const sql = 'SELECT * FROM users WHERE version BETWEEN 1 AND 10'
|
|
828
|
+
const result = parseTimeTravelSQL(sql)
|
|
829
|
+
|
|
830
|
+
expect(result.hasTimeTravelClause).toBe(false)
|
|
831
|
+
expect(result.mode).toBeUndefined()
|
|
832
|
+
})
|
|
833
|
+
|
|
834
|
+
it('should prioritize VERSIONS BETWEEN over AS OF', () => {
|
|
835
|
+
const sql = "SELECT * FROM users VERSIONS BETWEEN '2024-01-01' AND '2024-01-15' AS OF TIMESTAMP '2024-01-10'"
|
|
836
|
+
const result = parseTimeTravelSQL(sql)
|
|
837
|
+
|
|
838
|
+
expect(result.hasTimeTravelClause).toBe(true)
|
|
839
|
+
expect(result.mode).toBe('versions-between')
|
|
840
|
+
expect(result.startTimestamp).toBeDefined()
|
|
841
|
+
expect(result.endTimestamp).toBeDefined()
|
|
842
|
+
})
|
|
843
|
+
})
|
|
844
|
+
|
|
845
|
+
describe('IcebergTimeTravelReader - VERSIONS BETWEEN', () => {
|
|
846
|
+
const mockBucket = {
|
|
847
|
+
get: vi.fn(),
|
|
848
|
+
put: vi.fn(),
|
|
849
|
+
head: vi.fn(),
|
|
850
|
+
list: vi.fn(),
|
|
851
|
+
delete: vi.fn(),
|
|
852
|
+
} as unknown as R2Bucket
|
|
853
|
+
|
|
854
|
+
let reader: IcebergTimeTravelReader
|
|
855
|
+
|
|
856
|
+
const createMetadata = (
|
|
857
|
+
snapshots: Array<{ id: number; timestampMs: number }>
|
|
858
|
+
): IcebergTableMetadata => ({
|
|
859
|
+
'format-version': 2,
|
|
860
|
+
'table-uuid': 'test-uuid',
|
|
861
|
+
location: 'iceberg/test',
|
|
862
|
+
'last-sequence-number': snapshots.length,
|
|
863
|
+
'last-updated-ms': Date.now(),
|
|
864
|
+
'last-column-id': 10,
|
|
865
|
+
'current-schema-id': 0,
|
|
866
|
+
schemas: [{ type: 'struct', 'schema-id': 0, fields: [] }],
|
|
867
|
+
'default-spec-id': 0,
|
|
868
|
+
'partition-specs': [{ 'spec-id': 0, fields: [] }],
|
|
869
|
+
'last-partition-id': 0,
|
|
870
|
+
'default-sort-order-id': 0,
|
|
871
|
+
'sort-orders': [{ 'order-id': 0, fields: [] }],
|
|
872
|
+
'current-snapshot-id': snapshots.length > 0 ? snapshots[snapshots.length - 1]!.id : undefined,
|
|
873
|
+
snapshots: snapshots.map((s, i) => ({
|
|
874
|
+
'snapshot-id': s.id,
|
|
875
|
+
'sequence-number': i + 1,
|
|
876
|
+
'timestamp-ms': s.timestampMs,
|
|
877
|
+
'manifest-list': `iceberg/test/metadata/snap-${s.id}.avro`,
|
|
878
|
+
summary: { operation: 'append' as const },
|
|
879
|
+
})),
|
|
880
|
+
})
|
|
881
|
+
|
|
882
|
+
beforeEach(() => {
|
|
883
|
+
vi.clearAllMocks()
|
|
884
|
+
reader = createTimeTravelReader({ bucket: mockBucket })
|
|
885
|
+
})
|
|
886
|
+
|
|
887
|
+
it('should resolve data files for VERSIONS BETWEEN query', async () => {
|
|
888
|
+
const metadata = createMetadata([
|
|
889
|
+
{ id: 1, timestampMs: 1704067200000 }, // 2024-01-01
|
|
890
|
+
{ id: 2, timestampMs: 1704326400000 }, // 2024-01-04
|
|
891
|
+
{ id: 3, timestampMs: 1704585600000 }, // 2024-01-07
|
|
892
|
+
{ id: 4, timestampMs: 1704844800000 }, // 2024-01-10
|
|
893
|
+
])
|
|
894
|
+
|
|
895
|
+
const mockManifestListJson = JSON.stringify({
|
|
896
|
+
manifests: [
|
|
897
|
+
{
|
|
898
|
+
'manifest-path': 'iceberg/test/metadata/manifest-1.avro',
|
|
899
|
+
'manifest-length': 1000,
|
|
900
|
+
'partition-spec-id': 0,
|
|
901
|
+
content: 0,
|
|
902
|
+
'sequence-number': 1,
|
|
903
|
+
'min-sequence-number': 1,
|
|
904
|
+
'added-snapshot-id': 1,
|
|
905
|
+
'added-files-count': 1,
|
|
906
|
+
'existing-files-count': 0,
|
|
907
|
+
'deleted-files-count': 0,
|
|
908
|
+
'added-rows-count': 50,
|
|
909
|
+
'existing-rows-count': 0,
|
|
910
|
+
'deleted-rows-count': 0,
|
|
911
|
+
},
|
|
912
|
+
],
|
|
913
|
+
})
|
|
914
|
+
|
|
915
|
+
const mockManifestJson = JSON.stringify({
|
|
916
|
+
entries: [
|
|
917
|
+
{
|
|
918
|
+
status: 1, // ADDED
|
|
919
|
+
'data-file': {
|
|
920
|
+
content: 'data',
|
|
921
|
+
'file-path': 'iceberg/test/data/file1.parquet',
|
|
922
|
+
'file-format': 'parquet',
|
|
923
|
+
partition: {},
|
|
924
|
+
'record-count': 50,
|
|
925
|
+
'file-size-in-bytes': 5000,
|
|
926
|
+
},
|
|
927
|
+
},
|
|
928
|
+
],
|
|
929
|
+
})
|
|
930
|
+
|
|
931
|
+
// Mock calls for 3 snapshots (2, 3, 4) - manifest list + manifest for each
|
|
932
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>)
|
|
933
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestListJson) })
|
|
934
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestJson) })
|
|
935
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestListJson) })
|
|
936
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestJson) })
|
|
937
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestListJson) })
|
|
938
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestJson) })
|
|
939
|
+
|
|
940
|
+
const options: TimeTravelQueryOptions = {
|
|
941
|
+
fromTimestamp: 1704326400000, // 2024-01-04
|
|
942
|
+
toTimestamp: 1704844800000, // 2024-01-10
|
|
943
|
+
mode: 'versions-between',
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const result = await reader.resolveDataFiles(metadata, options)
|
|
947
|
+
|
|
948
|
+
expect(result.metadata.mode).toBe('versions-between')
|
|
949
|
+
expect(result.metadata.snapshotCount).toBe(3) // snapshots 2, 3, and 4
|
|
950
|
+
expect(result.metadata.startTimestampMs).toBe(1704326400000)
|
|
951
|
+
expect(result.metadata.endTimestampMs).toBe(1704844800000)
|
|
952
|
+
expect(result.dataFiles.length).toBeGreaterThan(0)
|
|
953
|
+
})
|
|
954
|
+
|
|
955
|
+
it('should collect all unique data files across snapshots', async () => {
|
|
956
|
+
// Create a fresh reader with caching disabled for this test
|
|
957
|
+
const freshReader = createTimeTravelReader({
|
|
958
|
+
bucket: mockBucket,
|
|
959
|
+
enableManifestCache: false,
|
|
960
|
+
})
|
|
961
|
+
|
|
962
|
+
const metadata = createMetadata([
|
|
963
|
+
{ id: 5, timestampMs: 1705067200000 }, // Different IDs to avoid cache conflicts
|
|
964
|
+
{ id: 6, timestampMs: 1705153600000 },
|
|
965
|
+
])
|
|
966
|
+
|
|
967
|
+
const mockManifestListJson1 = JSON.stringify({
|
|
968
|
+
manifests: [
|
|
969
|
+
{
|
|
970
|
+
'manifest-path': 'iceberg/test/metadata/manifest-5.avro',
|
|
971
|
+
'manifest-length': 1000,
|
|
972
|
+
'partition-spec-id': 0,
|
|
973
|
+
content: 0,
|
|
974
|
+
'sequence-number': 1,
|
|
975
|
+
'min-sequence-number': 1,
|
|
976
|
+
'added-snapshot-id': 5,
|
|
977
|
+
'added-files-count': 1,
|
|
978
|
+
'existing-files-count': 0,
|
|
979
|
+
'deleted-files-count': 0,
|
|
980
|
+
'added-rows-count': 100,
|
|
981
|
+
'existing-rows-count': 0,
|
|
982
|
+
'deleted-rows-count': 0,
|
|
983
|
+
},
|
|
984
|
+
],
|
|
985
|
+
})
|
|
986
|
+
|
|
987
|
+
const mockManifestJson1 = JSON.stringify({
|
|
988
|
+
entries: [
|
|
989
|
+
{
|
|
990
|
+
status: 1,
|
|
991
|
+
'data-file': {
|
|
992
|
+
content: 'data',
|
|
993
|
+
'file-path': 'iceberg/test/data/file-a.parquet',
|
|
994
|
+
'file-format': 'parquet',
|
|
995
|
+
partition: {},
|
|
996
|
+
'record-count': 100,
|
|
997
|
+
'file-size-in-bytes': 10000,
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
],
|
|
1001
|
+
})
|
|
1002
|
+
|
|
1003
|
+
const mockManifestListJson2 = JSON.stringify({
|
|
1004
|
+
manifests: [
|
|
1005
|
+
{
|
|
1006
|
+
'manifest-path': 'iceberg/test/metadata/manifest-6.avro',
|
|
1007
|
+
'manifest-length': 1000,
|
|
1008
|
+
'partition-spec-id': 0,
|
|
1009
|
+
content: 0,
|
|
1010
|
+
'sequence-number': 2,
|
|
1011
|
+
'min-sequence-number': 2,
|
|
1012
|
+
'added-snapshot-id': 6,
|
|
1013
|
+
'added-files-count': 1,
|
|
1014
|
+
'existing-files-count': 0,
|
|
1015
|
+
'deleted-files-count': 0,
|
|
1016
|
+
'added-rows-count': 50,
|
|
1017
|
+
'existing-rows-count': 0,
|
|
1018
|
+
'deleted-rows-count': 0,
|
|
1019
|
+
},
|
|
1020
|
+
],
|
|
1021
|
+
})
|
|
1022
|
+
|
|
1023
|
+
const mockManifestJson2 = JSON.stringify({
|
|
1024
|
+
entries: [
|
|
1025
|
+
{
|
|
1026
|
+
status: 1,
|
|
1027
|
+
'data-file': {
|
|
1028
|
+
content: 'data',
|
|
1029
|
+
'file-path': 'iceberg/test/data/file-b.parquet',
|
|
1030
|
+
'file-format': 'parquet',
|
|
1031
|
+
partition: {},
|
|
1032
|
+
'record-count': 50,
|
|
1033
|
+
'file-size-in-bytes': 5000,
|
|
1034
|
+
},
|
|
1035
|
+
},
|
|
1036
|
+
],
|
|
1037
|
+
})
|
|
1038
|
+
|
|
1039
|
+
// Mock multiple calls - manifest list for each snapshot, then manifest for each
|
|
1040
|
+
;(mockBucket.get as ReturnType<typeof vi.fn>)
|
|
1041
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestListJson1) })
|
|
1042
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestJson1) })
|
|
1043
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestListJson2) })
|
|
1044
|
+
.mockResolvedValueOnce({ text: vi.fn().mockResolvedValue(mockManifestJson2) })
|
|
1045
|
+
|
|
1046
|
+
const options: TimeTravelQueryOptions = {
|
|
1047
|
+
fromTimestamp: 1705067200000,
|
|
1048
|
+
toTimestamp: 1705153600000,
|
|
1049
|
+
mode: 'versions-between',
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
const result = await freshReader.resolveDataFiles(metadata, options)
|
|
1053
|
+
|
|
1054
|
+
// Should have files from both snapshots
|
|
1055
|
+
expect(result.dataFiles.length).toBe(2)
|
|
1056
|
+
expect(result.metadata.snapshotCount).toBe(2)
|
|
1057
|
+
const filePaths = result.dataFiles.map(f => f['file-path'])
|
|
1058
|
+
// In VERSIONS BETWEEN, we collect data files from all snapshots
|
|
1059
|
+
// The deduplication happens based on file path, so we should have 2 unique files
|
|
1060
|
+
expect(filePaths.length).toBe(2)
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
it('should throw error for VERSIONS BETWEEN without timestamps', async () => {
|
|
1064
|
+
const metadata = createMetadata([
|
|
1065
|
+
{ id: 1, timestampMs: 1704067200000 },
|
|
1066
|
+
])
|
|
1067
|
+
|
|
1068
|
+
const options: TimeTravelQueryOptions = {
|
|
1069
|
+
mode: 'versions-between',
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
await expect(
|
|
1073
|
+
reader.resolveDataFiles(metadata, options)
|
|
1074
|
+
).rejects.toThrow('fromTimestamp and toTimestamp are required for versions-between queries')
|
|
1075
|
+
})
|
|
1076
|
+
|
|
1077
|
+
it('should throw NoSnapshotFoundError when no snapshots in range', async () => {
|
|
1078
|
+
const metadata = createMetadata([
|
|
1079
|
+
{ id: 1, timestampMs: 1704067200000 }, // 2024-01-01
|
|
1080
|
+
])
|
|
1081
|
+
|
|
1082
|
+
const options: TimeTravelQueryOptions = {
|
|
1083
|
+
fromTimestamp: 1705276800000, // 2024-01-15 (after all snapshots)
|
|
1084
|
+
toTimestamp: 1705363200000, // 2024-01-16
|
|
1085
|
+
mode: 'versions-between',
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
await expect(
|
|
1089
|
+
reader.resolveDataFiles(metadata, options)
|
|
1090
|
+
).rejects.toThrow(NoSnapshotFoundError)
|
|
1091
|
+
})
|
|
1092
|
+
})
|
|
1093
|
+
|
|
1094
|
+
describe('Integration - VERSIONS BETWEEN Workflow', () => {
|
|
1095
|
+
it('should support complete VERSIONS BETWEEN query workflow', () => {
|
|
1096
|
+
// 1. Parse SQL with VERSIONS BETWEEN clause
|
|
1097
|
+
const sql = "SELECT user_id, name, _operation, _valid_from FROM users VERSIONS BETWEEN TIMESTAMP '2024-01-01' AND TIMESTAMP '2024-01-15' WHERE department = 'engineering'"
|
|
1098
|
+
const parsed = parseTimeTravelSQL(sql)
|
|
1099
|
+
|
|
1100
|
+
expect(parsed.hasTimeTravelClause).toBe(true)
|
|
1101
|
+
expect(parsed.mode).toBe('versions-between')
|
|
1102
|
+
expect(parsed.cleanSql).toBe("SELECT user_id, name, _operation, _valid_from FROM users WHERE department = 'engineering'")
|
|
1103
|
+
expect(parsed.tableName).toBe('users')
|
|
1104
|
+
|
|
1105
|
+
// 2. Parse the timestamps
|
|
1106
|
+
const startTimestamp = parsed.startTimestamp!
|
|
1107
|
+
const endTimestamp = parsed.endTimestamp!
|
|
1108
|
+
|
|
1109
|
+
expect(startTimestamp.timestampMs).toBe(1704067200000) // 2024-01-01
|
|
1110
|
+
expect(endTimestamp.timestampMs).toBe(1705276800000) // 2024-01-15
|
|
1111
|
+
|
|
1112
|
+
// 3. Format for display
|
|
1113
|
+
const formattedStart = formatTimestamp(startTimestamp.timestampMs)
|
|
1114
|
+
const formattedEnd = formatTimestamp(endTimestamp.timestampMs)
|
|
1115
|
+
|
|
1116
|
+
expect(formattedStart).toBe('2024-01-01T00:00:00.000Z')
|
|
1117
|
+
expect(formattedEnd).toBe('2024-01-15T00:00:00.000Z')
|
|
1118
|
+
})
|
|
1119
|
+
|
|
1120
|
+
it('should support VERSIONS BETWEEN with NOW()', () => {
|
|
1121
|
+
const referenceTime = 1704153600000 // 2024-01-02
|
|
1122
|
+
|
|
1123
|
+
const sql = "SELECT * FROM orders VERSIONS BETWEEN '2024-01-01' AND NOW()"
|
|
1124
|
+
const parsed = parseTimeTravelSQL(sql)
|
|
1125
|
+
|
|
1126
|
+
expect(parsed.hasTimeTravelClause).toBe(true)
|
|
1127
|
+
expect(parsed.mode).toBe('versions-between')
|
|
1128
|
+
expect(parsed.startTimestamp?.timestampMs).toBe(1704067200000)
|
|
1129
|
+
|
|
1130
|
+
// endTimestamp should be NOW(), which is relative
|
|
1131
|
+
const endTimestamp = parseTimestamp(parsed.endTimestamp!.original, referenceTime)
|
|
1132
|
+
expect(endTimestamp.isRelative).toBe(true)
|
|
1133
|
+
expect(endTimestamp.timestampMs).toBe(referenceTime)
|
|
1134
|
+
})
|
|
1135
|
+
})
|
|
1136
|
+
|
|
1137
|
+
describe('System Columns Types', () => {
|
|
1138
|
+
it('should support RowVersion type structure', () => {
|
|
1139
|
+
const version: RowVersion<{ user_id: number; name: string }> = {
|
|
1140
|
+
data: {
|
|
1141
|
+
user_id: 123,
|
|
1142
|
+
name: 'John Doe',
|
|
1143
|
+
},
|
|
1144
|
+
system: {
|
|
1145
|
+
_operation: 'INSERT',
|
|
1146
|
+
_valid_from: 1704067200000,
|
|
1147
|
+
_valid_to: null,
|
|
1148
|
+
_transaction_id: 1001,
|
|
1149
|
+
_snapshot_id: 1,
|
|
1150
|
+
},
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
expect(version.data.user_id).toBe(123)
|
|
1154
|
+
expect(version.system._operation).toBe('INSERT')
|
|
1155
|
+
expect(version.system._valid_from).toBe(1704067200000)
|
|
1156
|
+
expect(version.system._valid_to).toBeNull()
|
|
1157
|
+
})
|
|
1158
|
+
|
|
1159
|
+
it('should support all operation types', () => {
|
|
1160
|
+
const operations: RowOperation[] = ['INSERT', 'UPDATE', 'DELETE']
|
|
1161
|
+
|
|
1162
|
+
operations.forEach(op => {
|
|
1163
|
+
const systemColumns: VersionSystemColumns = {
|
|
1164
|
+
_operation: op,
|
|
1165
|
+
_valid_from: Date.now(),
|
|
1166
|
+
_valid_to: null,
|
|
1167
|
+
_transaction_id: 1,
|
|
1168
|
+
_snapshot_id: 1,
|
|
1169
|
+
}
|
|
1170
|
+
expect(systemColumns._operation).toBe(op)
|
|
1171
|
+
})
|
|
1172
|
+
})
|
|
1173
|
+
|
|
1174
|
+
it('should support VersionsBetweenResult type structure', () => {
|
|
1175
|
+
const result: VersionsBetweenResult<{ id: number; value: string }> = {
|
|
1176
|
+
versions: [
|
|
1177
|
+
{
|
|
1178
|
+
data: { id: 1, value: 'v1' },
|
|
1179
|
+
system: {
|
|
1180
|
+
_operation: 'INSERT',
|
|
1181
|
+
_valid_from: 1704067200000,
|
|
1182
|
+
_valid_to: 1704153600000,
|
|
1183
|
+
_transaction_id: 100,
|
|
1184
|
+
_snapshot_id: 1,
|
|
1185
|
+
},
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
data: { id: 1, value: 'v2' },
|
|
1189
|
+
system: {
|
|
1190
|
+
_operation: 'UPDATE',
|
|
1191
|
+
_valid_from: 1704153600000,
|
|
1192
|
+
_valid_to: null,
|
|
1193
|
+
_transaction_id: 101,
|
|
1194
|
+
_snapshot_id: 2,
|
|
1195
|
+
},
|
|
1196
|
+
},
|
|
1197
|
+
],
|
|
1198
|
+
metadata: {
|
|
1199
|
+
snapshotId: 2,
|
|
1200
|
+
snapshotTimestampMs: 1704153600000,
|
|
1201
|
+
requestedTimestampMs: 1704067200000,
|
|
1202
|
+
mode: 'versions-between',
|
|
1203
|
+
dataFilesScanned: 2,
|
|
1204
|
+
totalRecords: 2,
|
|
1205
|
+
snapshotCount: 2,
|
|
1206
|
+
startTimestampMs: 1704067200000,
|
|
1207
|
+
endTimestampMs: 1704153600000,
|
|
1208
|
+
},
|
|
1209
|
+
hasMore: false,
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
expect(result.versions.length).toBe(2)
|
|
1213
|
+
expect(result.versions[0]!.system._operation).toBe('INSERT')
|
|
1214
|
+
expect(result.versions[1]!.system._operation).toBe('UPDATE')
|
|
1215
|
+
expect(result.hasMore).toBe(false)
|
|
1216
|
+
})
|
|
1217
|
+
})
|
|
1218
|
+
})
|