Skip to content

Commit 469498a

Browse files
committed
fix linting errors
1 parent fd63810 commit 469498a

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

lib/codec/plain.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function decodeValues_INT96(cursor: Cursor, count: number, opts?: Options) {
154154
for (let i = 0; i < count; ++i) {
155155
const nanosSinceMidnight = INT53.readInt64LE(cursor.buffer, cursor.offset);
156156
const julianDay = cursor.buffer.readUInt32LE(cursor.offset + 8);
157-
157+
158158
if (treatAsTimestamp) {
159159
// Convert Julian day and nanoseconds to a timestamp
160160
values.push(convertInt96ToTimestamp(julianDay, nanosSinceMidnight));
@@ -166,7 +166,7 @@ function decodeValues_INT96(cursor: Cursor, count: number, opts?: Options) {
166166
values.push(nanosSinceMidnight); // positive value
167167
}
168168
}
169-
169+
170170
cursor.offset += 12;
171171
}
172172

@@ -178,21 +178,21 @@ function decodeValues_INT96(cursor: Cursor, count: number, opts?: Options) {
178178
* In the Parquet format, INT96 timestamps are stored as:
179179
* - The first 8 bytes (low) represent nanoseconds within the day
180180
* - The last 4 bytes (high) represent the Julian day
181-
*
181+
*
182182
* @param julianDay Julian day number
183183
* @param nanosSinceMidnight Nanoseconds since midnight
184184
* @returns JavaScript Date object (UTC)
185185
*/
186186
function convertInt96ToTimestamp(julianDay: number, nanosSinceMidnight: number | bigint): Date {
187187
// Julian day 2440588 corresponds to 1970-01-01 (Unix epoch)
188188
const daysSinceEpoch = julianDay - 2440588;
189-
189+
190190
// Convert days to milliseconds (86,400,000 ms per day)
191191
const millisSinceEpoch = daysSinceEpoch * 86400000;
192-
192+
193193
// Convert nanoseconds to milliseconds
194194
const nanosInMillis = Number(BigInt(nanosSinceMidnight) / 1000000n);
195-
195+
196196
// Create a UTC Date
197197
return new Date(millisSinceEpoch + nanosInMillis);
198198
}

lib/reader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class ParquetReader {
199199
if (!PARQUET_VERSIONS.includes(metadata.version)) {
200200
throw 'invalid parquet version';
201201
}
202-
202+
203203
// Default to false for backward compatibility
204204
this.treatInt96AsTimestamp = opts.treatInt96AsTimestamp === true;
205205

@@ -761,7 +761,7 @@ export class ParquetEnvelopeReader {
761761
compression: compression,
762762
column: field,
763763
num_values: metadata.num_values,
764-
treatInt96AsTimestamp: this.treatInt96AsTimestamp
764+
treatInt96AsTimestamp: this.treatInt96AsTimestamp,
765765
});
766766

767767
// If this exists and is greater than zero then we need to have an offset

test/int96_timestamp.test.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ const chai = require('chai');
33
const assert = chai.assert;
44
const { ParquetReader } = require('../lib/reader');
55

6-
describe('INT96 timestamp handling', function() {
6+
describe('INT96 timestamp handling', function () {
77
this.timeout(30000); // Increase timeout for URL fetching
8-
9-
const testUrl = 'https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.0/eth/traces/date%3D2016-05-22/part-00000-54f4b70c-db10-479c-a117-e3cc760a7e26-c000.snappy.parquet';
10-
11-
it('should handle INT96 values as numbers by default', async function() {
8+
9+
const testUrl =
10+
'https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.0/eth/traces/date%3D2016-05-22/part-00000-54f4b70c-db10-479c-a117-e3cc760a7e26-c000.snappy.parquet';
11+
12+
it('should handle INT96 values as numbers by default', async function () {
1213
const reader = await ParquetReader.openUrl(testUrl);
1314
const cursor = reader.getCursor();
14-
15+
1516
// Read the first row
1617
const row = await cursor.next();
17-
18+
1819
// Find INT96 columns (if any)
1920
const schema = reader.getSchema();
2021
const fields = schema.fields;
21-
22+
2223
// Check if there are any INT96 columns and verify they're numbers
2324
let foundInt96 = false;
2425
for (const fieldName in fields) {
@@ -28,26 +29,26 @@ describe('INT96 timestamp handling', function() {
2829
assert.isNumber(row[fieldName], `Expected ${fieldName} to be a number`);
2930
}
3031
}
31-
32+
3233
// If no INT96 columns were found, log a message
3334
if (!foundInt96) {
3435
console.log('No INT96 columns found in the test file');
3536
}
36-
37+
3738
await reader.close();
3839
});
39-
40-
it('should convert INT96 values to timestamps when option is enabled', async function() {
40+
41+
it('should convert INT96 values to timestamps when option is enabled', async function () {
4142
const reader = await ParquetReader.openUrl(testUrl, { treatInt96AsTimestamp: true });
4243
const cursor = reader.getCursor();
43-
44+
4445
// Read the first row
4546
const row = await cursor.next();
46-
47+
4748
// Find INT96 columns (if any)
4849
const schema = reader.getSchema();
4950
const fields = schema.fields;
50-
51+
5152
// Check if there are any INT96 columns and verify they're Date objects
5253
let foundInt96 = false;
5354
for (const fieldName in fields) {
@@ -58,12 +59,12 @@ describe('INT96 timestamp handling', function() {
5859
console.log(`${fieldName} timestamp:`, row[fieldName]);
5960
}
6061
}
61-
62+
6263
// If no INT96 columns were found, log a message
6364
if (!foundInt96) {
6465
console.log('No INT96 columns found in the test file');
6566
}
66-
67+
6768
await reader.close();
6869
});
6970
});

0 commit comments

Comments
 (0)