Skip to content

test: add projection with subpath test #132

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

Merged
merged 1 commit into from
Jan 4, 2022
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
2 changes: 1 addition & 1 deletion query-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testImplementation("org.mockito:mockito-core:3.8.0")
testImplementation("org.mockito:mockito-junit-jupiter:3.8.0")
testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0")
testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")
testImplementation("com.squareup.okhttp3:mockwebserver:4.9.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public static Expression.Builder createComplexAttributeExpression(
AttributeExpression.newBuilder().setAttributeId(attributeId).setSubpath(subPath));
}

public static Expression.Builder createAliasedComplexAttributeExpression(
String attributeId, String subPath, String alias) {
return Expression.newBuilder()
.setAttributeExpression(
AttributeExpression.newBuilder()
.setAttributeId(attributeId)
.setSubpath(subPath)
.setAlias(alias));
}

public static Expression createAliasedColumnExpression(String columnName, String alias) {
return Expression.newBuilder()
.setColumnIdentifier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.hypertrace.core.query.service.QueryFunctionConstants.QUERY_FUNCTION_HASH;
import static org.hypertrace.core.query.service.QueryFunctionConstants.QUERY_FUNCTION_STRINGEQUALS;
import static org.hypertrace.core.query.service.QueryRequestBuilderUtils.createAliasedAttributeExpression;
import static org.hypertrace.core.query.service.QueryRequestBuilderUtils.createAliasedComplexAttributeExpression;
import static org.hypertrace.core.query.service.QueryRequestBuilderUtils.createAliasedFunctionExpression;
import static org.hypertrace.core.query.service.QueryRequestBuilderUtils.createCompositeFilter;
import static org.hypertrace.core.query.service.QueryRequestBuilderUtils.createFilter;
Expand Down Expand Up @@ -92,6 +93,30 @@ void transformsBasicAliasProjection() {
.blockingGet());
}

@Test
void transformsBasicAliasProjectionWithSubpath() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be in AttributeExpressionSubpathExistsFilteringTransformationTest and a corresponding CONTAINS_KEY filter be added ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this test isn't about CONTAINS_KEY filters, those tests already exist in the class you referenced. This test is verifying projection works when using a subpath.

this.mockAttribute(PROJECTED_ATTRIBUTE_ID, this.attributeMetadata);
this.mockAttribute(SIMPLE_ATTRIBUTE_ID, AttributeMetadata.getDefaultInstance());
QueryRequest originalRequest =
QueryRequest.newBuilder()
.addSelection(
createAliasedComplexAttributeExpression(
PROJECTED_ATTRIBUTE_ID, "test-sub-path", "my-alias"))
.build();
QueryRequest expectedTransform =
QueryRequest.newBuilder()
.addSelection(
createAliasedComplexAttributeExpression(
SIMPLE_ATTRIBUTE_ID, "test-sub-path", "my-alias"))
.build();

assertEquals(
expectedTransform,
this.projectionTransformation
.transform(originalRequest, mockTransformationContext)
.blockingGet());
}

@Test
void transformsComplexFunctionProjection() {
// CONCAT(HASH(SIMPLE_ATTRIBUTE_ID), "projectionLiteral")
Expand Down
2 changes: 1 addition & 1 deletion query-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation("org.slf4j:slf4j-api:1.7.32")
implementation("com.typesafe:config:1.4.1")

runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")
runtimeOnly("io.grpc:grpc-netty")
integrationTestImplementation("com.google.protobuf:protobuf-java-util:3.17.3")
integrationTestImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
Expand Down