Skip to content
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

Change checkpoint's table DDL, set column measured_by_atum_agent to h… #319

Merged
merged 5 commits into from
Feb 28, 2025

Conversation

ABLL526
Copy link
Contributor

@ABLL526 ABLL526 commented Feb 21, 2025

  • Change checkpoint's table DDL, set column measured_by_atum_agent to have NOT NULL constraint.

Closes #242

Release Notes:

  • Changed checkpoints DDL column measured_by_atum_agent from BOOLEAN to BOOLEAN NOT NULL

…ave NOT NULL constraint with DEFAULT FALSE #242

Made changes:
1. Changed the value of measured_by_atum_agent in Checkpoints DDL to NOT NULL.
2. Changed the value of measured_by_atum_agent in Checkpoints DDL to DEFAULT FALSE.
3. Changed the value of measured_by_atum_agent in Write Checkpoints to DEFAULT FALSE.
4. Changed the tests to accommodate this change, it has been tested successfully.
@@ -159,7 +159,7 @@ class WriteCheckpointIntegrationTests extends DBTestSuite {
.setParam("i_process_start_time", startTime)
.setParam("i_process_end_time", endTime)
.setParam("i_measurements", CustomDBType(measurements, "JSONB[]"))
.setParam("i_measured_by_atum_agent", false)
//.setParam("i_measured_by_atum_agent", false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have simply commented this out to test the if default works. And it does.
I can always change it back or remove the comment altogether.

@@ -235,7 +235,7 @@ class WriteCheckpointIntegrationTests extends DBTestSuite {
.add("checkpoint_name", "I came before")
.add("process_start_time", now())
.add("process_end_time", now())
.add("measured_by_atum_agent", false)
//.add("measured_by_atum_agent", false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have simply commented this out to test the if default works. And it does.
I can always change it back or remove the comment altogether.

@@ -161,7 +161,7 @@ class WriteCheckpointOverloadedIntegrationTests extends DBTestSuite {
.setParam("i_process_start_time", startTime)
.setParam("i_process_end_time", endTime)
.setParam("i_measurements", CustomDBType(measurements, "JSONB[]"))
.setParam("i_measured_by_atum_agent", false)
//.setParam("i_measured_by_atum_agent", false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have simply commented this out to test the if default works. And it does.
I can always change it back or remove the comment altogether.

@@ -237,7 +237,7 @@ class WriteCheckpointOverloadedIntegrationTests extends DBTestSuite {
.add("checkpoint_name", "I came before")
.add("process_start_time", now())
.add("process_end_time", now())
.add("measured_by_atum_agent", false)
//.add("measured_by_atum_agent", false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have simply commented this out to test the if default works. And it does.
I can always change it back or remove the comment altogether.

…ave NOT NULL constraint with DEFAULT FALSE #242

Made changes:
1. Changed the value of measured_by_atum_agent in Checkpoints DDL to NOT NULL.
2. Changed the value of measured_by_atum_agent in Checkpoints DDL to DEFAULT FALSE.
3. Changed the value of measured_by_atum_agent in Write Checkpoints to DEFAULT FALSE.
4. Changed the tests to accommodate this change, it has been tested successfully.
5. Made changes to the WriteCheckpoint.scala files.
Copy link

JaCoCo model module code coverage report - scala 2.13.11

Overall Project 58.76% 🍏

There is no coverage information present for the Files changed

Copy link

JaCoCo agent module code coverage report - scala 2.13.11

Overall Project 78.2% 🍏

There is no coverage information present for the Files changed

Copy link

JaCoCo reader module code coverage report - scala 2.13.11

Overall Project 90.86% 🍏

There is no coverage information present for the Files changed

Copy link

github-actions bot commented Feb 21, 2025

JaCoCo server module code coverage report - scala 2.13.11

Overall Project 68.39% 🍏

There is no coverage information present for the Files changed

Copy link
Contributor

@benedeki benedeki left a comment

Choose a reason for hiding this comment

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

Sorry, you went far behind what was needed and actually desired.

All that is needed is in runs.checkpoints
measured_by_atum_agent BOOLEAN NOT NULL, default is not needed, but that I leave up to your discretion.
So please roll back all the other changes.

Unfortunately the table change cannot be done the way how you did it either. FLyway is a migration tool. It's sequence of DB modification scripts. And on each deploy it records and remembers where in the sequence it has ended. Therefor it's not possible (working) to change the previous item in the sequence. You have to create a new one that alters the state of the object in its most recent version.
The new script should be from the range of V0.4.0.

…ave NOT NULL constraint with DEFAULT FALSE #242

Made changes:
1. Changed the value of measured_by_atum_agent in Checkpoints DDL to NOT NULL.
2. Changed the value of measured_by_atum_agent in Checkpoints DDL to DEFAULT FALSE as according to the issue request.
@ABLL526
Copy link
Contributor Author

ABLL526 commented Feb 25, 2025

@benedeki I have kept the DEFAULT FALSE since it is a requirement in the issue, please let me know if you have an issue with this. I can always change it as needed.

@@ -20,7 +20,7 @@ CREATE TABLE runs.checkpoints
checkpoint_name TEXT NOT NULL,
process_start_time TIMESTAMP WITH TIME ZONE NOT NULL,
process_end_time TIMESTAMP WITH TIME ZONE,
measured_by_atum_agent BOOLEAN,
measured_by_atum_agent BOOLEAN NOT NULL DEFAULT FALSE,
Copy link
Collaborator

@lsulak lsulak Feb 26, 2025

Choose a reason for hiding this comment

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

I'm not sure if this will work like this with Flyway (please familiarze yourself with it: https://documentation.red-gate.com/flyway/getting-started-with-flyway and https://github.com/sbt/flyway-sbt) - this file V0.1.0.32 was already applied on the DB, and we should always implement increments. I propose to use ALTER TABLE statement in a new sql file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, just out of curiosity, did you or someone check the DB on DEV, UAT, and PROD to see if there are, by any chance records with empty values for this column? If yes we have to deal with it (there might not be any such records)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @lsulak This is useful to know. I will add a seperate sql file with alter table.
No I have not checked the DBs.

Added SQL file with alter table, added the NOT NULL constraint to measured_by_atum_agent.
* limitations under the License.
*/

ALTER TABLE runs.checkpoints ALTER COLUMN measured_by_atum_agent SET NOT NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for nitpicking and mentioning it earlier. Would be the safest to update the field value to 'false wherever it's NULL

Copy link
Collaborator

@lsulak lsulak Feb 27, 2025

Choose a reason for hiding this comment

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

also what do you think about default FALSE? I think I'm slightly more inclined to it but we can leave it up to table's 'users' to define basically. I just think that false is a good candidate here also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have taken these comments into account. I am not sure if what I have done is correct, specfically adding an update table query.

Made amendments to SQL code mentioned by PR.
- Added Update table
- Added Default false to table
UPDATE runs.checkpoints
SET measured_by_atum_agent = FALSE
WHERE measured_by_atum_agent IS NULL;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am very unsure about having an update function in this SQL. Please correct me as needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries, it's exactly what I was after.
This way it won't fail.

Copy link
Collaborator

@lsulak lsulak left a comment

Choose a reason for hiding this comment

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

I think it's okay now, I'd like the opinion of @benedeki before merging ideally though

@ABLL526 ABLL526 merged commit d9099aa into master Feb 28, 2025
9 checks passed
@ABLL526 ABLL526 deleted the #242-Change-checkpoint's-table-DDL branch February 28, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Issues touching the Database part of the project
Projects
Status: Done
3 participants