Skip to content

Commit fe9df56

Browse files
committed
Don't truncate BigInts
BigInts are currently converted to JS Numbers, which can't fit values over 2**53. Fixes databricks#259
1 parent 56bd0d9 commit fe9df56

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/result/ArrowResultConverter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default class ArrowResultConverter implements IResultsProvider<Array<any>
205205
}
206206

207207
// Return other values as is
208-
return typeof value === 'bigint' ? Number(value) : value;
208+
return value;
209209
}
210210

211211
private convertThriftTypes(record: Record<string, any>): any {

lib/result/utils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Int64 from 'node-int64';
21
import {
32
Schema,
43
Field,
@@ -49,12 +48,7 @@ function convertJSON(value: any, defaultValue: any): any {
4948
}
5049

5150
function convertBigInt(value: any): any {
52-
if (typeof value === 'bigint') {
53-
return Number(value);
54-
}
55-
if (value instanceof Int64) {
56-
return value.toNumber();
57-
}
51+
// Do not convert a BigInt away from the BigInt type
5852
return value;
5953
}
6054

0 commit comments

Comments
 (0)