@gscdump/lakehouse 0.36.3 → 0.36.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/catalog.mjs +30 -2
- package/package.json +1 -1
package/dist/_chunks/catalog.mjs
CHANGED
|
@@ -106,13 +106,13 @@ async function connectIcebergCatalog(config, opts = {}) {
|
|
|
106
106
|
await cachePut(opts.cache, catalogConfigKey(config), toCache, CATALOG_CONFIG_TTL_MS, now);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const resolver = cachingResolver(s3SignedResolver({
|
|
109
|
+
const resolver = withVerifiedWriterByteLengths(cachingResolver(s3SignedResolver({
|
|
110
110
|
accessKeyId: config.s3.accessKeyId,
|
|
111
111
|
secretAccessKey: config.s3.secretAccessKey,
|
|
112
112
|
region: config.s3.region ?? "auto",
|
|
113
113
|
endpoint: config.s3.endpoint,
|
|
114
114
|
pathStyle: true
|
|
115
|
-
}));
|
|
115
|
+
})));
|
|
116
116
|
return {
|
|
117
117
|
catalog,
|
|
118
118
|
resolver,
|
|
@@ -120,6 +120,34 @@ async function connectIcebergCatalog(config, opts = {}) {
|
|
|
120
120
|
cacheScope: catalogCacheScope(config)
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
function withVerifiedWriterByteLengths(resolver) {
|
|
124
|
+
if (!resolver.writer) return resolver;
|
|
125
|
+
const baseWriter = resolver.writer;
|
|
126
|
+
return {
|
|
127
|
+
...resolver,
|
|
128
|
+
writer(path, options) {
|
|
129
|
+
const writer = baseWriter(path, options);
|
|
130
|
+
const finish = writer.finish.bind(writer);
|
|
131
|
+
writer.finish = async function() {
|
|
132
|
+
await finish();
|
|
133
|
+
const actual = bufferedByteLength(writer);
|
|
134
|
+
if (actual == null || writer.offset === actual) return;
|
|
135
|
+
console.warn(`[lakehouse] corrected Iceberg writer byte length for ${path}: offset=${writer.offset} actual=${actual}`);
|
|
136
|
+
writer.offset = actual;
|
|
137
|
+
};
|
|
138
|
+
return writer;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function bufferedByteLength(writer) {
|
|
143
|
+
if (typeof writer.flush === "function") return null;
|
|
144
|
+
try {
|
|
145
|
+
const bytes = writer.getBytes();
|
|
146
|
+
return Number.isFinite(bytes.byteLength) ? bytes.byteLength : null;
|
|
147
|
+
} catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
123
151
|
function catalogCacheScope(config) {
|
|
124
152
|
return `${config.catalogUri}\0${config.warehouse}`;
|
|
125
153
|
}
|
package/package.json
CHANGED