Skip to content

Commit

Permalink
Don't truncate BigInts
Browse files Browse the repository at this point in the history
BigInts are currently converted to JS Numbers, which can't fit values
over 2**53.

Fixes databricks#259
  • Loading branch information
gabegorelick committed Oct 28, 2024
1 parent 56bd0d9 commit f9db338
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/result/ArrowResultConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class ArrowResultConverter implements IResultsProvider<Array<any>
}

// Return other values as is
return typeof value === 'bigint' ? Number(value) : value;
return value;
}

private convertThriftTypes(record: Record<string, any>): any {
Expand Down
7 changes: 3 additions & 4 deletions lib/result/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ function convertJSON(value: any, defaultValue: any): any {
}

function convertBigInt(value: any): any {
if (typeof value === 'bigint') {
return Number(value);
}
if (value instanceof Int64) {
return value.toNumber();
return BigInt(value.toString());
}

// Do not convert a BigInt away from the BigInt type
return value;
}

Expand Down

0 comments on commit f9db338

Please sign in to comment.