Skip to content

Commit 9f01d7a

Browse files
author
Annie Zhang
authored
Remove .columns (#365)
* Remove .columns * update tests
1 parent 399b801 commit 9f01d7a

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

src/table.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,6 @@ export function getSchema(source) {
633633
// function to do table operations on in-memory data?
634634
export function __table(source, operations) {
635635
const input = source;
636-
let {columns} = source;
637636
let {schema, inferred} = getSchema(source);
638637
// Combine column types from schema with user-selected types in operations
639638
const types = new Map(schema.map(({name, type}) => [name, type]));
@@ -756,9 +755,6 @@ export function __table(source, operations) {
756755
const schemaByName = new Map(schema.map((s) => [s.name, s]));
757756
schema = operations.select.columns.map((c) => schemaByName.get(c));
758757
}
759-
if (columns) {
760-
columns = operations.select.columns;
761-
}
762758
source = source.map((d) =>
763759
Object.fromEntries(operations.select.columns.map((c) => [c, d[c]]))
764760
);
@@ -771,12 +767,6 @@ export function __table(source, operations) {
771767
return ({...s, ...(override ? {name: override.name} : null)});
772768
});
773769
}
774-
if (columns) {
775-
columns = columns.map((c) => {
776-
const override = overridesByName.get(c);
777-
return override?.name ?? c;
778-
});
779-
}
780770
source = source.map((d) =>
781771
Object.fromEntries(Object.keys(d).map((k) => {
782772
const override = overridesByName.get(k);
@@ -786,7 +776,6 @@ export function __table(source, operations) {
786776
}
787777
if (source !== input) {
788778
if (schema) source.schema = schema;
789-
if (columns) source.columns = columns;
790779
}
791780
return source;
792781
}

test/table-test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,6 @@ describe("__table", () => {
801801
];
802802
assert.deepStrictEqual(__table(source, operations), expected);
803803
source.columns = ["a", "b", "c"];
804-
assert.deepStrictEqual(__table(source, operations).columns, [
805-
"nameA",
806-
"b",
807-
"c"
808-
]);
809804
assert.deepStrictEqual(__table(source, operations).schema, [
810805
{name: "nameA", type: "integer", inferred: "integer"},
811806
{name: "b", type: "integer", inferred: "integer"},
@@ -830,11 +825,6 @@ describe("__table", () => {
830825
];
831826
assert.deepStrictEqual(__table(source, operations), expected);
832827
source.columns = ["a", "b", "c"];
833-
assert.deepStrictEqual(__table(source, operations).columns, [
834-
"a",
835-
"b",
836-
"c"
837-
]);
838828
assert.deepStrictEqual(__table(source, operations).schema, [
839829
{name: "a", type: "string", inferred: "integer"},
840830
{name: "b", type: "integer", inferred: "integer"},

0 commit comments

Comments
 (0)