diff --git a/CHANGELOG.md b/CHANGELOG.md index b02438d..a148a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v0.7.6-alpha + +- Added an error to handle empty relation size of 0 bytes when reading arrow files + ## v0.7.5-alpha - Updated some dependencies. diff --git a/package.json b/package.json index aba4bb1..6c2cf80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@relationalai/rai-sdk-javascript", "description": "RelationalAI SDK for JavaScript", - "version": "0.7.5-alpha", + "version": "0.7.6-alpha", "author": { "name": "RelationalAI", "url": "https://relational.ai" diff --git a/src/api/transaction/transactionUtils.ts b/src/api/transaction/transactionUtils.ts index 565745b..3685c88 100644 --- a/src/api/transaction/transactionUtils.ts +++ b/src/api/transaction/transactionUtils.ts @@ -16,7 +16,7 @@ import { tableFromIPC } from 'apache-arrow'; -import { MaxRelationSizeError } from '../../errors'; +import { EmptyRelationSizeError, MaxRelationSizeError } from '../../errors'; import { MetadataInfo } from '../../proto/generated/message'; import { RelationId } from '../../proto/generated/schema'; import { @@ -92,6 +92,13 @@ export async function readArrowFiles(files: TransactionAsyncFile[]) { ); } + // The part that exceeds 2GB is returned as a blob of 0 bytes, + // all the remaining parts are empty as well in Windows’s Chrome, + // therefore, throwing the error here to avoid failures downstream + if (file.file.size === 0) { + throw new EmptyRelationSizeError(file.name); + } + const table = await tableFromIPC(file.file.stream()); results.push({ diff --git a/src/errors.ts b/src/errors.ts index 318e21d..7ae78b5 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -82,6 +82,16 @@ export class MaxRelationSizeError extends Error { } } +export class EmptyRelationSizeError extends Error { + constructor(public relationId: string) { + const message = `Empty relation size of 0 bytes. Relation: ${relationId}`; + + super(message); + + this.name = 'EmptyRelationSizeError'; + } +} + export class AbortError extends Error { constructor(message?: string) { super(message); @@ -99,4 +109,5 @@ export type SdkError = | ApiError | TransactionError | MaxRelationSizeError + | EmptyRelationSizeError | Error;