-
Notifications
You must be signed in to change notification settings - Fork 18k
AIP-39: DagRun.data_interval_start and data_interval_end
#16352
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
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3525785
Implement DagRun.data_interval
uranusjr cac4f67
Add template context for AIP-39 variables
uranusjr b3ceaeb
Inject lazy-object-proxy into virtual environment
uranusjr a02b834
Propogate data interval from context to subdag
uranusjr aa41435
Set data interval for DagRun triggered from API
uranusjr d958883
Update doc on template variable for AIP-39
uranusjr 70a51c1
Correctly handle None when expanding a DAG ZIP
uranusjr bc32444
Bag the DAG for Connexion tests
uranusjr 6675773
Use DAG.create_dagrun() to create a DagRun
uranusjr cda6974
Remove the DagRunInfo compatibility shim
uranusjr 6cb8388
Fix Black blunder
uranusjr c1cd66f
We still need next_dagrun
uranusjr 173c262
Rename DagModel.data_interval to next_data_interval
uranusjr 873da99
Unify DAG run creation logic in HTML view and API
uranusjr 2c832f0
Remove usage of deprecated get_run_dates()
uranusjr 1b8593b
NamedTuple can't have cached_property
uranusjr f47591a
Allow DAGRun to not specify 'conf'
uranusjr 1a82474
Correctly handle datetime types in tests
uranusjr 055e90b
Test the CLI triggers DagRun with correct settings
uranusjr d4c5715
Remove unneeded owner field in test DAG
uranusjr 9a335c1
Test deprecated template fields
uranusjr 01fa13d
Pass local session on to child calls
uranusjr 598b746
Show wrong values in error messages for debuggability
uranusjr 62c75b6
Typos
uranusjr 23a5018
Clean up docstring on 'align'
uranusjr b959d96
Improve datetime field handling in migration
uranusjr 2fb68e4
Fix template context type tests
uranusjr 858ffd7
Create an actual DagRun to populate data interval
uranusjr cba9cce
Test to ensure /trigger populated data interval
uranusjr 0192e56
Include dagrun in the data interval property name
uranusjr 326e057
Test data intervals around in the scheduler job
uranusjr 03fa988
Rename schedule_date to logical_date
uranusjr c1c8652
Revert www/views.py change
uranusjr 1084344
Make a DagRun always have a data interval
uranusjr d65d36f
Make data interval 'exact' instead of None
uranusjr ed436e2
Back template variables against data interval
uranusjr 23d19f4
More consistently use :return:
uranusjr c130fc1
Add data interval to tests
uranusjr cedffe9
Point people to the template filters
uranusjr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...ow/migrations/versions/142555e44c17_add_data_interval_start_end_to_dagmodel_and_dagrun.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| """Add data_interval_[start|end] to DagModel and DagRun. | ||
|
|
||
| Revision ID: 142555e44c17 | ||
| Revises: e9304a3141f0 | ||
| Create Date: 2021-06-09 08:28:02.089817 | ||
|
|
||
| """ | ||
|
|
||
| from alembic import op | ||
| from sqlalchemy import TIMESTAMP, Column | ||
| from sqlalchemy.dialects import mssql, mysql | ||
|
|
||
| # Revision identifiers, used by Alembic. | ||
| revision = "142555e44c17" | ||
| down_revision = "54bebd308c5f" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def _use_date_time2(conn): | ||
| result = conn.execute( | ||
| """SELECT CASE WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) | ||
| like '8%' THEN '2000' WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) | ||
| like '9%' THEN '2005' ELSE '2005Plus' END AS MajorVersion""" | ||
| ).fetchone() | ||
| mssql_version = result[0] | ||
| return mssql_version not in ("2000", "2005") | ||
|
|
||
|
|
||
| def _get_timestamp(conn): | ||
| dialect_name = conn.dialect.name | ||
| if dialect_name == "mysql": | ||
| return mysql.TIMESTAMP(fsp=6, timezone=True) | ||
| if dialect_name != "mssql": | ||
| return TIMESTAMP(timezone=True) | ||
| if _use_date_time2(conn): | ||
| return mssql.DATETIME2(precision=6) | ||
| return mssql.DATETIME | ||
|
|
||
|
|
||
| def upgrade(): | ||
| """Apply data_interval fields to DagModel and DagRun.""" | ||
| column_type = _get_timestamp(op.get_bind()) | ||
| with op.batch_alter_table("dag_run") as batch_op: | ||
| batch_op.add_column(Column("data_interval_start", column_type)) | ||
| batch_op.add_column(Column("data_interval_end", column_type)) | ||
| with op.batch_alter_table("dag") as batch_op: | ||
| batch_op.add_column(Column("next_dagrun_data_interval_start", column_type)) | ||
| batch_op.add_column(Column("next_dagrun_data_interval_end", column_type)) | ||
|
|
||
|
|
||
| def downgrade(): | ||
| """Unapply data_interval fields to DagModel and DagRun.""" | ||
| with op.batch_alter_table("dag_run") as batch_op: | ||
| batch_op.drop_column("data_interval_start") | ||
| batch_op.drop_column("data_interval_end") | ||
| with op.batch_alter_table("dag") as batch_op: | ||
| batch_op.drop_column("next_dagrun_data_interval_start") | ||
| batch_op.drop_column("next_dagrun_data_interval_end") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.