-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
fix: time filter db migration optimization #13015
Conversation
6f749e9
to
a29817e
Compare
@@ -14,7 +14,7 @@ | |||
# KIND, either express or implied. See the License for the | |||
# specific language governing permissions and limitations | |||
# under the License. | |||
from flask_babel import lazy_gettext as _ | |||
from flask_babel import _ |
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.
Bycatch, lazy text cannot be properly formatted by Marshmallow.
class DatabaseNotFoundValidationError(ValidationError): | ||
""" | ||
Marshmallow validation error for database does not exist | ||
""" | ||
|
||
def __init__(self) -> None: | ||
super().__init__(_("Database does not exist"), field_names=["database"]) | ||
super().__init__(_("Database does not exist"), field_name="database") |
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.
Bycatch: should use field_name
instead of field_names
.
Codecov Report
@@ Coverage Diff @@
## master #13015 +/- ##
===========================================
+ Coverage 52.64% 66.97% +14.32%
===========================================
Files 480 489 +9
Lines 17300 28766 +11466
Branches 4481 0 -4481
===========================================
+ Hits 9108 19266 +10158
- Misses 8192 9500 +1308
Flags with carried forward coverage won't be shown. Click here to find out more. 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.
LGTM, thanks for fixing it!
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.
One nit, add a test case :
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 will merge when the CI completed
* master: fix: UI toast typo (apache#13026) feat(db engines): add support for Opendistro Elasticsearch (AWS ES) (apache#12602) fix(build): black failing on master, add to required checks (apache#13039) fix: time filter db migration optimization (apache#13015) fix: untranslated text content of Dashboard page (apache#13024) fix(ci): remove signature requirements for commits to master (apache#13034) fix: add alerts and report to default config (apache#12999) docs(changelog): add entries for 1.0.1 (apache#12981) ci: skip cypress if no code changes (apache#12982) chore: add cypress required checks for branch protection (apache#12970) Refresh dashboard list after bulk delete (apache#12945) Updates storybook to version 6.1.17 (apache#13014) feat: Save datapanel state in local storage (apache#12996) fix: added text and changed margins (apache#12923) chore: Swap Slack Url 2 more places (apache#13004)
SUMMARY
Optimizes free-text time range filter db migration added by #12505
100 years : 30 years ago
. Previously it will incorrectly change it to100 years ago : 30 years later
when it should be100 years ago : 30 years ago
.These are edge cases nonetheless.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
When opening a chart with "100 years" (i.e. periods without "ago" or "before/after"), it shows "Fatal error":
After
The error is more actionable:
(Still need some optimization here in order to render the backend validation error more properly but let's do it in another PR for other fields as well. Ideally the backend validation errors should come back to each control based on field name.)
TEST PLAN
#12552 is for fixing legacy charts. You will not be able to add bad data anymore because of the backend validation. You'd need to either find a legacy bad chart, or manually add one. A quick way to do it is this:
For example I use
psql
:Note we set the time range to be
"100 years : 30 years ago"
/superset/slice/{slice_id}
Before migration, you should see the "Unexpected error" when you open the chart.
After migration, you should see the chart render correctly.
Note: if you have already upgraded superset db, you need to downgrade it first:
When in current master, after migration, you will also see the filter being updated to "100 years ago : 30 years later":
With this PR, after migration, you should see the filter being updated to "100 years ago : 30 years ago":
ADDITIONAL INFORMATION