Skip to content

Switch map_index back to use server_default#20902

Merged
uranusjr merged 1 commit into
apache:mainfrom
astronomer:map-index-server-default
Jan 18, 2022
Merged

Switch map_index back to use server_default#20902
uranusjr merged 1 commit into
apache:mainfrom
astronomer:map-index-server-default

Conversation

@uranusjr

@uranusjr uranusjr commented Jan 17, 2022

Copy link
Copy Markdown
Member

Close #20876.

This ends up being simply reverting fff3a1e, but I forgot exactly why I made the switch in the first place. I guess the test suite will tell us if it works…

This emits 'DEFAULT -1' in the column definition and helps migration.
@uranusjr uranusjr requested a review from ashb January 17, 2022 10:51
@ashb

This comment has been minimized.

dag_id = Column(String(ID_LEN, **COLLATION_ARGS), primary_key=True, nullable=False)
run_id = Column(String(ID_LEN, **COLLATION_ARGS), primary_key=True, nullable=False)
map_index = Column(Integer, primary_key=True, nullable=False, default=-1)
map_index = Column(Integer, primary_key=True, nullable=False, server_default=text("-1"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can possibly have default and server_default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked some sources and realised default isn’t actually much useful in ORM, only if we use the SQL expression builder. And with server_default set, default only really matters for UPDATE, which actually seems a bit wrong to me, so I’ll omit default until they are proven useful.

@ashb ashb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration change works.

@github-actions

Copy link
Copy Markdown
Contributor

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions Bot added the full tests needed We need to run full set of tests for this PR to merge label Jan 17, 2022
@uranusjr uranusjr merged commit 66276e6 into apache:main Jan 18, 2022
@uranusjr uranusjr deleted the map-index-server-default branch January 18, 2022 04:55
@jedcunningham jedcunningham added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Airflow database upgrade fails with "psycopg2.errors.NotNullViolation: column "map_index" of relation "task_instance" contains null value"s

3 participants