Skip to content

Commit

Permalink
update existing test to include logicalType
Browse files Browse the repository at this point in the history
  • Loading branch information
saraswatpuneet committed Sep 12, 2024
1 parent 0a5040f commit 119bc70
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions test/decodeSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = chai.assert;
const parquet = require('../parquet');

describe('ParquetSchema', function () {
it('should handle complex nesting', function () {
it('should handle complex nesting with logicalType as undefined', function () {
var metadata = {
version: 1,
schema: [
Expand Down Expand Up @@ -120,6 +120,7 @@ describe('ParquetSchema', function () {
dLevelMax: 0,
isNested: true,
fieldCount: 2,
logicalType: undefined,
fields: {
b: {
name: 'b',
Expand All @@ -130,6 +131,7 @@ describe('ParquetSchema', function () {
dLevelMax: 0,
isNested: true,
fieldCount: 2,
logicalType: undefined,
fields: {
c: {
name: 'c',
Expand All @@ -140,6 +142,7 @@ describe('ParquetSchema', function () {
dLevelMax: 0,
isNested: true,
fieldCount: 1,
logicalType: undefined,
fields: {
d: {
name: 'd',
Expand All @@ -150,6 +153,7 @@ describe('ParquetSchema', function () {
statistics: undefined,
typeLength: undefined,
encoding: 'PLAIN',
logicalType: undefined,
compression: 'UNCOMPRESSED',
rLevelMax: 0,
dLevelMax: 0,
Expand All @@ -167,6 +171,7 @@ describe('ParquetSchema', function () {
dLevelMax: 0,
isNested: true,
fieldCount: 2,
logicalType: undefined,
fields: {
f: {
name: 'f',
Expand All @@ -177,6 +182,7 @@ describe('ParquetSchema', function () {
statistics: undefined,
typeLength: undefined,
encoding: 'PLAIN',
logicalType: undefined,
compression: 'UNCOMPRESSED',
rLevelMax: 0,
dLevelMax: 0,
Expand All @@ -192,6 +198,7 @@ describe('ParquetSchema', function () {
statistics: undefined,
typeLength: undefined,
encoding: 'PLAIN',
logicalType: undefined,
compression: 'UNCOMPRESSED',
rLevelMax: 0,
dLevelMax: 0,
Expand All @@ -211,6 +218,7 @@ describe('ParquetSchema', function () {
statistics: undefined,
typeLength: undefined,
encoding: 'PLAIN',
logicalType: undefined,
compression: 'UNCOMPRESSED',
rLevelMax: 0,
dLevelMax: 0,
Expand All @@ -222,21 +230,6 @@ describe('ParquetSchema', function () {
};

const reader = new parquet.ParquetReader(metadata, {});
const removeUndefinedFields = (obj) => {
Object.keys(obj).forEach((key) => {
if (obj[key] === undefined || obj[key] === null || (Array.isArray(obj[key]) && obj[key].length === 0)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete obj[key];
} else if (typeof obj[key] === 'object') {
removeUndefinedFields(obj[key]);
}
});
return obj;
};

const sanitizedExpected = removeUndefinedFields(expected);
const sanitizedActual = removeUndefinedFields(reader.schema.fields);

assert.deepEqual(sanitizedActual, sanitizedExpected);
assert.deepEqual(reader.schema.fields, expected);
});
});

0 comments on commit 119bc70

Please sign in to comment.