Skip to content

Remove .columns #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down Expand Up @@ -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]]))
);
Expand All @@ -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);
Expand All @@ -786,7 +776,6 @@ export function __table(source, operations) {
}
if (source !== input) {
if (schema) source.schema = schema;
if (columns) source.columns = columns;
}
return source;
}
Expand Down
10 changes: 0 additions & 10 deletions test/table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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"},
Expand Down