Add OR statement to match V1 and V2 Scheduler BusinessIds#10248
Conversation
1b0fed5 to
07767a4
Compare
07767a4 to
2294a95
Compare
2294a95 to
e1d0bb7
Compare
| // This block runs after the STARTS_WITH → LIKE conversion above so the V1 clone inherits the | ||
| // already-converted operator and escape settings. | ||
| // TODO: once V1 schedules are fully migrated to CHASM, remove this OR/AND block and only use V2 (unprefixed) values. | ||
| if saColNameExpr.alias == sadefs.ScheduleID && c.archetypeID == chasm.SchedulerArchetypeID { |
There was a problem hiding this comment.
🤖 Missing fieldName guard — the generic converter (converter.go:399) and ES legacy converter (converter_legacy.go:319) both check colName.FieldName == sadefs.WorkflowID here, but this condition only checks the alias. If a user defines a custom ScheduleId search attribute (which would map to a different field name), this block would still fire and incorrectly inject the V1 prefix OR/AND logic.
| if saColNameExpr.alias == sadefs.ScheduleID && c.archetypeID == chasm.SchedulerArchetypeID { | |
| if saColNameExpr.alias == sadefs.ScheduleID && saColNameExpr.fieldName == sadefs.WorkflowID && c.archetypeID == chasm.SchedulerArchetypeID { |
There was a problem hiding this comment.
I'm not super familiar with this portion of the codebase.
There was a problem hiding this comment.
ah this is correct, just need to verify the field name, thanks
| }, 15*time.Second, 1*time.Second) | ||
| } | ||
|
|
||
| func testListSchedulesFilterByScheduleID(t *testing.T, newContext contextFactory) { |
There was a problem hiding this comment.
this set test only checks v1 xor v2. could you add one that has results for both?
|
|
||
| { | ||
| name: "CHASM path IN generates OR of prefixed and unprefixed", | ||
| in: "ScheduleId IN ('foo', 'bar')", |
lina-temporal
left a comment
There was a problem hiding this comment.
few small comments, otherwise LGTM; would appreciate a stamp from visi/foundations as well, though.
| }) | ||
|
|
||
| // Not equal: ScheduleId != 'sid1' should return sid2 but not sid1. | ||
| t.Run("NotEqual", func(t *testing.T) { |
There was a problem hiding this comment.
Can you also add the Len assertions on the cases with 2 schedules returned? This will guard against something in the handler returning duplicate results.
| if comparisonExpr.Operator == sqlparser.NotEqualStr || | ||
| comparisonExpr.Operator == sqlparser.NotInStr || | ||
| comparisonExpr.Operator == sqlparser.NotStartsWithStr { |
There was a problem hiding this comment.
(minor) Can you reuse isNegativeScheduleIDOperator here?
| isNegative := expr.Operator == sqlparser.NotEqualStr || | ||
| expr.Operator == sqlparser.NotInStr || | ||
| expr.Operator == sqlparser.NotLikeStr |
There was a problem hiding this comment.
(minor) Ditto for reusing isNegativeScheduleIDOperator here
0922434 to
3e13a0f
Compare
3e13a0f to
254bea8
Compare
a4ad61e to
6c25432
Compare
6c25432 to
7512038
Compare
review is complete, pending discussion has been done offline
…10316) ## What changed? Add a Scheduler specific query converter to handle ScheduleId search attribute alias to underlying WorkflowId system search attribute field. If chasm is enabled, the query converter will match against both V1 and V2 Scheduler workflowId formats. V1 prefixes the workflowId with temporal-sys-scheduler, while V2 doesn't, so to handle either case, we need to add a OR/AND statement to match both V1 and V2 Scheduler BusinessId. OR will be used if the operator's boolean is positive, AND if the operator's boolean is negative. ## Why? Unable to retrieve V2 Schedules that query using ScheduleId as a search attribute. ## How did you test it? - [X] built - [X] run locally and tested manually - [X] covered by existing tests - [X] added new unit test(s) - [X] added new functional test(s)
What changed?
Add a Scheduler specific query converter to handle
ScheduleIdsearch attribute alias to underlyingWorkflowIdsystem search attribute field. If chasm is enabled, the query converter will match against both V1 and V2 Scheduler workflowId formats. V1 prefixes the workflowId withtemporal-sys-scheduler, while V2 doesn't, so to handle either case, we need to add a OR/AND statement to match both V1 and V2 Scheduler BusinessId. OR will be used if the operator's boolean is positive, AND if the operator's boolean is negative.Why?
Unable to retrieve V2 Schedules that query using
ScheduleIdas a search attribute.How did you test it?