From 47945777dda09101105c14a75be65a01224db2b8 Mon Sep 17 00:00:00 2001 From: Annie Zhang Date: Mon, 17 Apr 2023 12:07:50 -0400 Subject: [PATCH 1/2] Remove .columns --- src/table.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/table.js b/src/table.js index 9cbeced..f83a088 100644 --- a/src/table.js +++ b/src/table.js @@ -633,7 +633,6 @@ export function getSchema(source) { // function to do table operations on in-memory data? export function __table(source, operations) { const input = source; - let {columns} = source; let {schema, inferred} = getSchema(source); // Combine column types from schema with user-selected types in operations const types = new Map(schema.map(({name, type}) => [name, type])); @@ -756,9 +755,6 @@ export function __table(source, operations) { const schemaByName = new Map(schema.map((s) => [s.name, s])); schema = operations.select.columns.map((c) => schemaByName.get(c)); } - if (columns) { - columns = operations.select.columns; - } source = source.map((d) => Object.fromEntries(operations.select.columns.map((c) => [c, d[c]])) ); @@ -771,12 +767,6 @@ export function __table(source, operations) { return ({...s, ...(override ? {name: override.name} : null)}); }); } - if (columns) { - columns = columns.map((c) => { - const override = overridesByName.get(c); - return override?.name ?? c; - }); - } source = source.map((d) => Object.fromEntries(Object.keys(d).map((k) => { const override = overridesByName.get(k); @@ -786,7 +776,6 @@ export function __table(source, operations) { } if (source !== input) { if (schema) source.schema = schema; - if (columns) source.columns = columns; } return source; } From c73869374bd9642e1f81be14cdd14d98c8ff74a2 Mon Sep 17 00:00:00 2001 From: Annie Zhang Date: Mon, 17 Apr 2023 12:10:07 -0400 Subject: [PATCH 2/2] update tests --- test/table-test.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/table-test.js b/test/table-test.js index 4727b12..0a79525 100644 --- a/test/table-test.js +++ b/test/table-test.js @@ -801,11 +801,6 @@ describe("__table", () => { ]; assert.deepStrictEqual(__table(source, operations), expected); source.columns = ["a", "b", "c"]; - assert.deepStrictEqual(__table(source, operations).columns, [ - "nameA", - "b", - "c" - ]); assert.deepStrictEqual(__table(source, operations).schema, [ {name: "nameA", type: "integer", inferred: "integer"}, {name: "b", type: "integer", inferred: "integer"}, @@ -830,11 +825,6 @@ describe("__table", () => { ]; assert.deepStrictEqual(__table(source, operations), expected); source.columns = ["a", "b", "c"]; - assert.deepStrictEqual(__table(source, operations).columns, [ - "a", - "b", - "c" - ]); assert.deepStrictEqual(__table(source, operations).schema, [ {name: "a", type: "string", inferred: "integer"}, {name: "b", type: "integer", inferred: "integer"},