-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(datasource): remove deleted columns and update column type on metadata refresh #10619
feat(datasource): remove deleted columns and update column type on metadata refresh #10619
Conversation
const columns = [ | ||
{ | ||
name: 'ds', | ||
type: 'DATETIME', | ||
nullable: true, | ||
default: '', | ||
primary_key: false, | ||
}, | ||
{ | ||
name: 'gender', | ||
type: 'VARCHAR(32)', | ||
nullable: true, | ||
default: '', | ||
primary_key: false, | ||
}, | ||
{ | ||
name: 'new_column', | ||
type: 'VARCHAR(10)', | ||
nullable: true, | ||
default: '', | ||
primary_key: false, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the correct schema coming back from the API (compare with extraColumn
above).
{ | ||
type: 'DATETIME', | ||
description: null, | ||
filterable: false, | ||
verbose_name: null, | ||
is_dttm: true, | ||
expression: '', | ||
groupby: false, | ||
column_name: 'ds', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This column is unchanged.
{ | ||
type: 'VARCHAR(32)', | ||
description: null, | ||
filterable: true, | ||
verbose_name: null, | ||
is_dttm: false, | ||
expression: '', | ||
groupby: true, | ||
column_name: 'gender', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is updated from VARCHAR(16)
to VARCHAR(32)
expect.objectContaining({ | ||
column_name: 'new_column', | ||
type: 'VARCHAR(10)', | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new column.
expect(inst.state.databaseColumns).not.toEqual( | ||
expect.arrayContaining([expect.objectContaining({ name: 'name' })]), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the removed columns in the original metadata.
let { databaseColumns } = this.state; | ||
let hasChanged; | ||
const currentColNames = databaseColumns.map(col => col.column_name); | ||
updateColumns(cols) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method was renamed to reflect that metadata is updated, not only merged.
dbcols = ( | ||
db.session.query(TableColumn) | ||
.filter(TableColumn.table == self) | ||
.filter(or_(TableColumn.column_name == col.name for col in table_.columns)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the intent here was, but I don't see any scenario where we want to bring in columns from another table with the same column names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good improvement/fix - I'd like to tag @lilykuang as well who's touched this code recently for a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 thank you for the improvement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* master: (43 commits) feat: Getting fancier with Storybook (apache#10647) fix: dedup groupby in viz.py while preserving order (apache#10633) feat: bump superset-ui for certified tag (apache#10650) feat: setup react page with submenu for datasources listview (apache#10642) feat: add certification to metrics (apache#10630) feat(viz-plugins): add date formatting to pivot-table (apache#10637) fix: controls scroll issue (apache#10644) feat: Allow tests files in /src (plus Label component tests) (apache#10634) fix: remove duplicated params and cache_timeout from list_columns; add viz_type to list_columns (apache#10643) chore: splitting button stories into separate stories (apache#10631) refactor: remove slice level label_colors from dashboard init load (apache#10603) feat: card view bulk select (apache#10607) style: Label styling/storybook touchups (apache#10627) fix: removing unsupported modal sizes (apache#10625) feat(datasource): remove deleted columns and update column type on metadata refresh (apache#10619) improve documentation for country maps (apache#10621) chore: npm audit fix as of 2020-08-15 (apache#10613) feat: dataset REST API for distinct values (apache#10595) chore: bump react-redux to 5.1.2, whittling console noise (apache#10602) fixing console error about bad html attribute (apache#10604) ... # Conflicts: # superset-frontend/src/explore/components/ExploreViewContainer.jsx # superset-frontend/src/views/App.tsx # superset/config.py
…tadata refresh (apache#10619) * fix: remove missing columns on metadata refresh * add tests * lint and simplify * lint * reduce locals * fix label style
…tadata refresh (apache#10619) * fix: remove missing columns on metadata refresh * add tests * lint and simplify * lint * reduce locals * fix label style
SUMMARY
Currently refreshing table metadata doesn't remove columns that aren't available on the table any longer. In addition, the React Table view doesn't update column types if they've changed. This PR:
AFTER
BEFORE
The type pills on the column tab were using an incorrect style, causing white foreground on white background.

TEST PLAN
Local testing + new tests
ADDITIONAL INFORMATION