clintropolis commented on code in PR #14465: URL: https://github.com/apache/druid/pull/14465#discussion_r1237913207
########## processing/src/test/java/org/apache/druid/query/aggregation/TestFloatNullableColumnSelector.java: ########## @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.query.aggregation; + + +public class TestFloatNullableColumnSelector extends TestFloatColumnSelector Review Comment: nit: is this really worth being in its own file instead of just like.. overriding something inline or a static class in the test file? ########## processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java: ########## @@ -84,6 +85,40 @@ public void testAggregate() assertValues(agg, selector, expectedFirst, expectedSecond, expectedThird); } + @Test + public void testAggregateWithNullableSelectorAndNullValues() + { + NullHandling.initializeForTestsWithValues(false, true); + + final TestFloatNullableColumnSelector selector = new TestFloatNullableColumnSelector(null); + + final FilteredAggregatorFactory factory = new FilteredAggregatorFactory( + new FloatMaxAggregatorFactory("loss", "value"), + new SelectorDimFilter("dim", "a", null) + ); + + final FilteredAggregator agg = (FilteredAggregator) factory.factorize(makeColumnSelector(selector)); + aggregate(selector, agg); + assertValues(agg, selector); + } + + @Test + public void testAggregateWithNullableSelectorAndNonNullValues() Review Comment: nit: since isNull on the selector always returns true is this really testing null and non-null values? ########## processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java: ########## @@ -218,14 +253,22 @@ public ColumnCapabilities getColumnCapabilities(String columnName) private void assertValues(FilteredAggregator agg, TestFloatColumnSelector selector, double... expectedVals) { - Assert.assertEquals(NullHandling.defaultDoubleValue(), agg.get()); - Assert.assertEquals(NullHandling.defaultDoubleValue(), agg.get()); - Assert.assertEquals(NullHandling.defaultDoubleValue(), agg.get()); - for (double expectedVal : expectedVals) { Review Comment: maybe this should accept `Double...` instead of `double...` so that it confirms that it _actually_ tests the expected values, since in this case the selectory always returns null it seems like for the test cases using `TestFloatNullableColumnSelector` this `!agg.isNull` branch will never be hit... -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
