Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (s *ESVisibilitySuite) Test_convertQuery() {
query = `StartTime = "2018-06-07T15:04:05.123456789-08:00"`
queryParams, err = s.visibilityStore.convertQuery(testNamespace, testNamespaceID, query)
s.NoError(err)
s.Equal(`{"bool":{"filter":[{"term":{"NamespaceId":"bfd5c907-f899-4baf-a7b2-2ab85e623ebd"}},{"bool":{"filter":{"match":{"StartTime":{"query":"2018-06-07T15:04:05.123456789-08:00"}}}}}],"must_not":{"exists":{"field":"TemporalNamespaceDivision"}}}}`, s.queryToJSON(queryParams.Query))
s.JSONEq(`{"bool":{"filter":[{"term":{"NamespaceId":"bfd5c907-f899-4baf-a7b2-2ab85e623ebd"}},{"bool":{"filter":{"match":{"StartTime":{"query":"2018-06-07T15:04:05.123456789-08:00"}}}}}],"must_not":{"exists":{"field":"TemporalNamespaceDivision"}}}}`, s.queryToJSON(queryParams.Query))
s.Nil(queryParams.Sorter)

query = `WorkflowId = 'wid' and StartTime > "2018-06-07T15:04:05+00:00"`
Expand Down
31 changes: 23 additions & 8 deletions service/history/visibility_queue_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,33 @@ func (t *visibilityQueueTaskExecutor) processChasmTask(
return serviceerror.NewInternalf("expected visibility component, but got %T", visComponent)
}

searchattributes, err := visComponent.GetSearchAttributes(visTaskContext)
namespaceEntry, err := t.shardContext.GetNamespaceRegistry().
GetNamespaceByID(namespace.ID(task.GetNamespaceID()))
if err != nil {
return err
}

searchattributesMapperProvider := t.shardContext.GetSearchAttributesMapperProvider()
searchAttributesMapper, err := searchattributesMapperProvider.GetMapper(namespaceEntry.Name())
if err != nil {
return err
}
if searchattributes == nil {
searchattributes = make(map[string]*commonpb.Payload)

searchattributes := make(map[string]*commonpb.Payload)

aliasedSearchAttributes, err := visComponent.GetSearchAttributes(visTaskContext)
if err != nil {
return err
}

for alias, value := range aliasedSearchAttributes {
fieldName, err := searchAttributesMapper.GetFieldName(alias, namespaceEntry.Name().String())
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I thought we said we would log these errors since search attributes can be removed and we don't want to fail the visibility task for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, this should not fail the task executor, will address this in a follow up

return err
}
searchattributes[fieldName] = value
}

memo, err := visComponent.GetMemo(visTaskContext)
if err != nil {
return err
Expand All @@ -419,11 +439,6 @@ func (t *visibilityQueueTaskExecutor) processChasmTask(
}
}

namespaceEntry, err := t.shardContext.GetNamespaceRegistry().
GetNamespaceByID(namespace.ID(task.GetNamespaceID()))
if err != nil {
return err
}
requestBase := t.getVisibilityRequestBase(
task,
namespaceEntry,
Expand Down
11 changes: 11 additions & 0 deletions service/history/visibility_queue_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ func (s *visibilityQueueTaskExecutorSuite) SetupTest() {
config,
)

// Set up expectations on the SearchAttributesMapper mocks created by NewTestContext
mockMapper := searchattribute.NewMockMapper(s.controller)
mockMapper.EXPECT().GetFieldName(gomock.Any(), gomock.Any()).DoAndReturn(
func(alias string, _ string) (string, error) {
return alias, nil
},
).AnyTimes()

mockMapperProvider := s.mockShard.Resource.SearchAttributesMapperProvider
mockMapperProvider.EXPECT().GetMapper(gomock.Any()).Return(mockMapper, nil).AnyTimes()

reg := hsm.NewRegistry()
err := workflow.RegisterStateMachine(reg)
s.NoError(err)
Expand Down
Loading