Skip to content

CDA-120: TS and Loc Group ignore_missing flag support#195

Open
zack-rma wants to merge 6 commits into
HydrologicEngineeringCenter:mainfrom
zack-rma:feature/partial-group-saving
Open

CDA-120: TS and Loc Group ignore_missing flag support#195
zack-rma wants to merge 6 commits into
HydrologicEngineeringCenter:mainfrom
zack-rma:feature/partial-group-saving

Conversation

@zack-rma

@zack-rma zack-rma commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Includes new procedures for TS group and Location group assignment with ignore_missing flag.

Contributes to USACE/cwms-data-api#1731

@zack-rma zack-rma force-pushed the feature/partial-group-saving branch from e1bf406 to 7f6b9d5 Compare July 2, 2026 19:18
@zack-rma zack-rma marked this pull request as ready for review July 2, 2026 19:55
Comment thread schema/src/cwms/cwms_loc_pkg.sql Outdated
* @param p_ignore_missing Whether to fail on location assignments for locations that are not in the database
* @param p_missing_locations A list of locations that are not in the database and were not assigned to the group
*/
PROCEDURE assign_loc_groups4 (p_loc_category_id IN VARCHAR2,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rename procedure to something more informative. maybe assign_loc_groups_supports_missing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed as suggested

Comment thread schema/src/cwms/cwms_loc_pkg_body.sql Outdated
p_missing_locations (p_missing_locations.COUNT) :=
p_loc_alias_array (i);
ELSE
cwms_err.raise('LOCATION_ID_NOT_FOUND', p_loc_alias_array (i).location_id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fails immediately on the first missing location. That might be okay if that is expected behavior. Alternatively - you could always just add to the missing loc collection instead of failing early, then check if its non-empty at the end and raise an error reporting back everything that was missing.

@rma-bryson rma-bryson Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It appears the ts group procedure collects up the missing and reports it in the error. I would do the same here for consistency and to provide more insight to the caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated procedure to have the same error reporting behavior

Comment thread schema/src/cwms/cwms_ts_pkg.sql Outdated
* @param p_ignore_missing A flag ('T' or 'F') that specifies whether to ignore time series assignments that are not in the database
* @param p_missing_ts The time series identifiers for any assignments that are not in the database.
*/
PROCEDURE assign_ts_groups2 (p_ts_category_id IN VARCHAR2,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

prefer procedure names that describe their purpose or behavior rather than appending numeric suffixes like 2 (even though that is done in alot of the plsql codebase)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed

l_error_message := l_error_message || ', ' || p_missing_ts(j).ts_id;
END IF;
END LOOP;
cwms_err.raise ('ITEM_DOES_NOT_EXIST',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the behavior i would have expected for locations where we collect up the missing and report it in the error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added similar logic to location procedure

Comment thread schema/src/test/test_cwms_ts.sql Outdated
procedure test_assign_ts_ignore_missing;

--%test (Test TS group assignment with ignore missing flag set to false)
--%throws(-20001)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This checks the error code is thrown... should also be able to get the error message and verify it contains the list of missing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to check error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants