Fixes a bug when deploying a cube with partitioned columns due to autoflush#1828
Merged
shangyian merged 2 commits intoDataJunction:mainfrom Mar 6, 2026
Merged
Fixes a bug when deploying a cube with partitioned columns due to autoflush#1828shangyian merged 2 commits intoDataJunction:mainfrom
shangyian merged 2 commits intoDataJunction:mainfrom
Conversation
…oflush on orphaned columns
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The bug was in
_create_cube_node_revision_from_validation_datain the deployment orchestrator:Columnobjects and attaches aPartitionto each one.self.session.add(partition), which seems reasonable, but SQLAlchemy's back-populate relationship meant adding partition to the session also silently addednode_columnto the session.no_autoflushblock, so this was safe while inside it._create_cube_node_revision_from_validation_datareturnsnode_revisionwithout adding it to the session. The caller appends it to a list of revisions and adds it later viasession.add_all(revisions)no_autoflushblock exited, those node_columns were stranded in the session withnode_revision_id=null, because node_revision (which would have given them their FK value) hadn't been added to the session yet.NOT NULLviolation onnode_revision_idInstead of
session.add(partition), we can just assignnode_column.partition = Partition(...)directly. Since Column.partition hascascade="all,delete", SQLAlchemy will automatically save the partition when the column is saved. This way node_column never enters the session prematurely; it only gets added when node_revision is added, at which point SQLAlchemy correctly orders the inserts:NodeRevisionfirst (to get its id), thenColumn(withnode_revision_idset), thenPartition(withcolumn_idset).Test Plan
Verified locally
make checkpassesmake testshows 100% unit test coverageDeployment Plan