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

Handle namespace division filter in SQL queries #3931

Merged

Conversation

rodrigozhou
Copy link
Contributor

@rodrigozhou rodrigozhou commented Feb 9, 2023

What changed?
Handle namespace division filter in the new SQL visibility store.

Why?
Copying logic from Elasticsearch visibility store/query builder (namespace division was previously ignored).

How did you test it?
Existing tests.

Potential risks
No risks.

Is hotfix candidate?
No.

@rodrigozhou rodrigozhou requested a review from alexshtin February 9, 2023 23:52
@rodrigozhou rodrigozhou requested a review from a team as a code owner February 9, 2023 23:52
@rodrigozhou rodrigozhou changed the title Add check for namespace divisiion in SQL queries Add check for namespace division in SQL queries Feb 9, 2023
@@ -179,7 +183,25 @@ func (c *QueryConverter) convertSelectStmt(sel *sqlparser.Select) error {
}

if sel.Where != nil {
Copy link
Member

Choose a reason for hiding this comment

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

When might Where be nil? (I haven't really read any of this code yet so sorry if it's a dumb question)

Is this change enough to make things work for old-style ListOpenWorkflowExecutionsByType, etc. as well as string queries?

Copy link
Contributor Author

@rodrigozhou rodrigozhou Feb 10, 2023

Choose a reason for hiding this comment

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

If the user query string is empty.
Actually, I think I made a mistake... I think I have to add either way (ie, even if it's nil)

Copy link
Member

Choose a reason for hiding this comment

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

Hm, but we do want to add the constraint in that case. Basically in all cases unless they specifically query for a different division

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnr Fixed the query converter, and visibility store to handle namespace division field.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have enough context to review the whole thing but that part looks good.

Unfortunately we don't have a standalone integration test for that, since only ES supported it at all before, but ScheduleIntegrationSuite exercises the NamespaceDivision stuff (as Alex discovered)

@rodrigozhou rodrigozhou force-pushed the add-namespace-division-cmp branch from c9069aa to 2055eb9 Compare February 10, 2023 03:37
@rodrigozhou rodrigozhou changed the title Add check for namespace division in SQL queries Handle namespace division filter in SQL queries Feb 10, 2023
fmt.Sprintf(
"%s != %d",
searchattribute.ExecutionStatus,
int32(enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING),
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realized that ExecutionStatus is int. I changed in in ES, but we can't change here :-(

searchattribute.StartTime,
request.EarliestStartTime.UTC().Format(time.RFC3339Nano),
request.LatestStartTime.UTC().Format(time.RFC3339Nano),
Query: s.buildQueryStringFromListRequest(
Copy link
Member

Choose a reason for hiding this comment

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

I hope we will deprecate and remove all these methods soon.

@rodrigozhou rodrigozhou force-pushed the add-namespace-division-cmp branch from 2055eb9 to a6bd463 Compare February 10, 2023 05:27
@rodrigozhou rodrigozhou merged commit 7faf6f8 into temporalio:master Feb 10, 2023
@rodrigozhou rodrigozhou deleted the add-namespace-division-cmp branch February 10, 2023 07:27
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.

3 participants