-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Update annotation model to have JSON Metadata field #5745
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5745 +/- ##
==========================================
- Coverage 63.45% 63.41% -0.04%
==========================================
Files 362 366 +4
Lines 22978 25574 +2596
Branches 2554 2844 +290
==========================================
+ Hits 14580 16219 +1639
- Misses 8383 9340 +957
Partials 15 15
Continue to review full report at Codecov.
|
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.
For renaming the column in the db it'll come handy to have the downgrade
method defined in your migration. First define the downgrade
method with the old table name, then run superset db downgrade
, then rename the table, ...
|
||
|
||
def upgrade(): | ||
op.add_column('annotation', sa.Column('annotation_metadata', sa.Text(), nullable=True)) |
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.
Migration should have a downgrade too. You can grep and find many other migrations that add_column on upgrade and remove_column on downgarde
superset/models/annotations.py
Outdated
@@ -42,6 +42,7 @@ class Annotation(Model, AuditMixinNullable): | |||
layer = relationship( | |||
AnnotationLayer, | |||
backref='annotation') | |||
annotation_metadata = Column(Text) |
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.
Knowing that this is the Annotation
model, the pattern we've been following is to not repeat the entity name in the column names, as in just id
and not annotation_id
(since we know all columns in the table has to be annotation-related). There's different school of thought here and different school of data modeling will suggest different column naming schemes, but let's be consistent with other models in Superset.
Also could be nice to have json
in the column name to let people know this column contains json text. So maybe something like extra_json
or json_metadata
.
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.
For renaming the column in the db it'll come handy to have the downgrade
method defined in your migration. First define the downgrade
method with the old table name, then run superset db downgrade
, then rename the table, ...
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.
For renaming the column in the db it'll come handy to have the downgrade
method defined in your migration. First define the downgrade
method with the old table name, then run superset db downgrade
, then rename the table, ...
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.
For renaming the column in the db it'll come handy to have the downgrade
method defined in your migration. First define the downgrade
method with the old table name, then run superset db downgrade
, then rename the table, ...
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.
For renaming the column in the db it'll come handy to have the downgrade
method defined in your migration. First define the downgrade
method with the old table name, then run superset db downgrade
, then rename the table, ...
Sorry github was down for a moment and I refreshed the page a few times, review got posted many times |
superset/views/annotations.py
Outdated
@@ -22,9 +22,12 @@ class AnnotationModelView(SupersetModelView, DeleteMixin): # noqa | |||
add_title = _('Add Annotation') | |||
edit_title = _('Edit Annotation') | |||
|
|||
list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm'] | |||
list_columns = ['layer', 'short_descr', 'start_dttm', 'end_dttm', | |||
'annotation_metadata'] |
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 think annotation_metadata
should be json_metadata
, though actually we don't want the json in the list view as it may bloat the table, I think I'd just leave it out.
LGTM |
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns (cherry picked from commit 5e3f833)
* add column to annotation model * update migration file * change to Text * remove old migration file * add migration file * remove JSON * add new column to view * add comma back * linting * lint some more * missing comma * rename columns * add degrade and new migration file * update version * fixe changed name * remove json from list columns
Adding an additional field to Annotation Model, to allow users to store additional information about this record.
@mistercrunch @betodealmeida