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

Flag From Tag dimension #913

Merged
merged 45 commits into from
Jun 11, 2019
Merged

Flag From Tag dimension #913

merged 45 commits into from
Jun 11, 2019

Conversation

efronbs
Copy link
Contributor

@efronbs efronbs commented May 28, 2019

issue: #915

@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment May 29, 2019
@yahoo yahoo deleted a comment Jun 6, 2019
@yahoo yahoo deleted a comment Jun 6, 2019
@yahoo yahoo deleted a comment Jun 6, 2019
@yahoo yahoo deleted a comment Jun 6, 2019
@yahoo yahoo deleted a comment Jun 6, 2019
if (! (entry.getKey() instanceof FilterOptimizable)) {
newFilters.put(entry.getKey(), entry.getValue());
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bug.
If Dimension A is processed and optimizes filters into Dimension B, and then Dimension B is processed, this put will cause it's filters to overwrite the filters that were originally dimension A.

Probably the best approach here is to create a List of entries and push values into it and then do a grouping collect at the end.

@@ -1,4 +1,4 @@
// Copyright 2019 Oath Inc.
// Copyright 2019 Verizon Media Group.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly we can't use Verizon Media Group yet as copyright. We're still legally Oath.

apiRequest.getApiFilters() >> new ApiFilters([(resources.d14) : [new ApiFilter(resources.d14, DefaultDimensionField.ID, DefaultFilterOperation.in, ["TRUE_VALUE"] as Collection)] as Set] as Map)
}

def "Flag from tag dimension based on lookup dimension serializes to cascade extraction function with tag extraction and transformation in grouping context"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider parameterizing these expected values a little more so it's easier to fix the tests is there are subtle changes. Extract the formula for the final extraction function perhaps.

objectMapper.writeValueAsString(druidQuery).contains('{"type":"extraction","dimension":"breed","outputName":"flagFromTagRegisteredLookup","extractionFn":{"type":"cascade","extractionFns":[{"type":"registeredLookup","lookup":"BREED__SPECIES","retainMissingValue":false,"replaceMissingValueWith":"Unknown BREED__SPECIES","injective":false,"optimize":true},{"type":"registeredLookup","lookup":"BREED__OTHER","retainMissingValue":false,"replaceMissingValueWith":"Unknown BREED__OTHER","injective":false,"optimize":true},{"type":"registeredLookup","lookup":"BREED__COLOR","retainMissingValue":false,"replaceMissingValueWith":"Unknown BREED__COLOR","injective":false,"optimize":true},{"type":"regex","expr":"(.+,)*(TAG_VALUE)(,.+)*","index":2,"replaceMissingValue":true,"replaceMissingValueWith":""},{"type":"lookup","lookup":{"type":"map","map":{"TAG_VALUE":"TRUE_VALUE"}},"retainMissingValue":false,"replaceMissingValueWith":"FALSE_VALUE","injective":false,"optimize":false}]}}')
}

def "Flag from tag dimension pushes extraction and transformation to innermost query when nesting"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch here!

@@ -65,9 +66,15 @@ class ConjunctionDruidFilterBuilderSpec extends Specification {
}

@Unroll
def "buildFilters takes a conjunction of clauses, one for each dimension in #dimensions"() {
def "buildFilters takes a conjunction of clauses, onex for each dimension in #dimensions"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?

(dim2) : [dim2OutputFilter] as Set
] as Map<Dimension, Set<ApiFilter>>)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test where if dimension A optimizes into dimension B that the resulting query has the merge of filters for dimension B. Ensure this happens regardless of the order of the dimensions.

@@ -273,7 +273,7 @@
<module name="RegexpHeader">
<property name="severity" value="error" />
<property name="header"
value="// Copyright 20[0-1][0-9],? (Yahoo Inc.|Oath Inc.)\n// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms\.\n" />
value="// Copyright 20[0-1][0-9],? (Yahoo Inc.|Oath Inc.|Verizon Media Group.)\n// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms\.\n" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert this, per Gil Yehuda, we can't use this copyright yet.

@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@yahoo yahoo deleted a comment Jun 10, 2019
@efronbs efronbs merged commit 74e9372 into master Jun 11, 2019
@efronbs efronbs deleted the TagFromFlagDimension branch June 11, 2019 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants