Skip to content

Commit

Permalink
Add interface method for returning canonical lookup name (#16557)
Browse files Browse the repository at this point in the history
* Add interface method for returning canonical lookup name

* Address review comment

* Add test in LookupReferencesManagerTest for coverage check

* Add test in LookupSerdeModuleTest for coverage check
  • Loading branch information
Akshat-Jain authored Jun 5, 2024
1 parent 7aecc09 commit 6d7d2ff
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
return Optional.empty();
}
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public interface LookupExtractorFactoryContainerProvider
* Returns a lookup container for the provided lookupName, if it exists.
*/
Optional<LookupExtractorFactoryContainer> get(String lookupName);

/**
* Returns the canonical lookup name from a given lookup name, if special syntax exists.
*/
String getCanonicalLookupName(String lookupName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
{
return Optional.empty();
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ public Set<String> getAllLookupNames()
return stateRef.get().lookupMap.keySet();
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}

// Note that this should ensure that "toLoad" and "toDrop" are disjoint.
LookupsState<LookupExtractorFactoryContainer> getAllLookupsState()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,11 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
{
return Optional.empty();
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
return Optional.empty();
}
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,13 @@ public void testGetAllLookupNames() throws Exception
);
}

@Test
public void testGetCanonicalLookupName()
{
String lookupName = "lookupName1";
Assert.assertEquals(lookupName, lookupReferencesManager.getCanonicalLookupName(lookupName));
}

@Test
public void testGetAllLookupsState() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,12 @@ public void testExpressionTransformSerde() throws Exception
objectMapper.readValue(objectMapper.writeValueAsBytes(transform), ExpressionTransform.class)
);
}

@Test
public void testGetCanonicalLookupName()
{
LookupExtractorFactoryContainerProvider instance = injector.getInstance(LookupExtractorFactoryContainerProvider.class);
String lookupName = "lookupName1";
Assert.assertEquals(lookupName, instance.getCanonicalLookupName(lookupName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public Optional<LookupExtractorFactoryContainer> get(final String lookupName)
return Optional.empty();
}
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
return Optional.empty();
}
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
{
return Optional.empty();
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
};

public static SpecificSegmentsQuerySegmentWalker createWalker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
{
return Optional.empty();
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}

final TimeseriesQuery query =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public DruidExpression toDruidExpression(
final String lookupName = (String) lookupNameExpr.getLiteralValue();

// Add the lookup name to the set of lookups to selectively load.
plannerContext.addLookupToLoad(lookupName);
plannerContext.addLookupToLoad(lookupExtractorFactoryContainerProvider.getCanonicalLookupName(lookupName));

if (arg.isSimpleExtraction() && lookupNameExpr.isLiteral()) {
return arg.getSimpleExtraction().cascade(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ public Optional<LookupExtractorFactoryContainer> get(String lookupName)
return Optional.empty();
}
}

@Override
public String getCanonicalLookupName(String lookupName)
{
return lookupName;
}
}

0 comments on commit 6d7d2ff

Please sign in to comment.