You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "abhishekagarwal87 (via GitHub)" <gi...@apache.org> on 2023/01/25 11:37:09 UTC

[GitHub] [druid] abhishekagarwal87 commented on a diff in pull request #13704: Support postaggregation function as in Math.pow() (#13703)

abhishekagarwal87 commented on code in PR #13704:
URL: https://github.com/apache/druid/pull/13704#discussion_r1086528987


##########
processing/src/test/java/org/apache/druid/query/aggregation/post/ArithmeticPostAggregatorTest.java:
##########
@@ -183,7 +183,36 @@ public void testQuotient()
     Assert.assertEquals(Double.POSITIVE_INFINITY, agg.compute(ImmutableMap.of("value", 1)));
     Assert.assertEquals(Double.NEGATIVE_INFINITY, agg.compute(ImmutableMap.of("value", -1)));
   }
+  @Test
+  public void testPow()
+  {
+    ArithmeticPostAggregator agg = new ArithmeticPostAggregator(
+            null,
+            "pow",
+            ImmutableList.of(
+                    new ConstantPostAggregator("value", 4),
+                    new ConstantPostAggregator("power", .5)
+            ),
+            "numericFirst"
+    );
+    Assert.assertEquals(2.0, agg.compute(ImmutableMap.of("value", 0)));
 
+    agg = new ArithmeticPostAggregator(
+            null,
+            "pow",
+            ImmutableList.of(
+                    new FieldAccessPostAggregator("value", "value"),
+                    new ConstantPostAggregator("zero", 0)

Review Comment:
   can you use a different value here so the asserts below all get a different result with a different value? LGTM otherwise. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org