From d3995fa29301ca1fdbaa93096fe72ef99679d5e8 Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Sun, 5 Apr 2020 18:16:25 -0700 Subject: [PATCH 1/6] Add selector null check to preserve null values as-is. --- .../apache/druid/segment/DoubleWrappingDimensionSelector.java | 4 +++- .../apache/druid/segment/FloatWrappingDimensionSelector.java | 4 +++- .../apache/druid/segment/LongWrappingDimensionSelector.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/segment/DoubleWrappingDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/DoubleWrappingDimensionSelector.java index 89cc99c89b15..4f1dac049f69 100644 --- a/processing/src/main/java/org/apache/druid/segment/DoubleWrappingDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/DoubleWrappingDimensionSelector.java @@ -43,7 +43,9 @@ public DoubleWrappingDimensionSelector( @Override protected String getValue() { - if (extractionFn == null) { + if (selector.isNull()) { + return null; + } else if (extractionFn == null) { return String.valueOf(selector.getDouble()); } else { return extractionFn.apply(selector.getDouble()); diff --git a/processing/src/main/java/org/apache/druid/segment/FloatWrappingDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/FloatWrappingDimensionSelector.java index 3e39e995fe7c..ec5f958dab9e 100644 --- a/processing/src/main/java/org/apache/druid/segment/FloatWrappingDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/FloatWrappingDimensionSelector.java @@ -40,7 +40,9 @@ public FloatWrappingDimensionSelector(BaseFloatColumnValueSelector selector, @Nu @Override protected String getValue() { - if (extractionFn == null) { + if (selector.isNull()) { + return null; + } else if (extractionFn == null) { return String.valueOf(selector.getFloat()); } else { return extractionFn.apply(selector.getFloat()); diff --git a/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java index 1388dcf04802..de25d2ebd874 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java @@ -40,7 +40,9 @@ public LongWrappingDimensionSelector(BaseLongColumnValueSelector selector, @Null @Override protected String getValue() { - if (extractionFn == null) { + if (selector.isNull()) { + return null; + } else if (extractionFn == null) { return String.valueOf(selector.getLong()); } else { return extractionFn.apply(selector.getLong()); From af65a9ddd294edfc589975fe161930033e8e2bff Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Sun, 5 Apr 2020 18:17:40 -0700 Subject: [PATCH 2/6] Fix typo. --- .../apache/druid/segment/loading/LocalDataSegmentPuller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java index 45121a96a074..5f63557f98eb 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java +++ b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPuller.java @@ -151,7 +151,7 @@ public FileUtils.FileCopyResult getSegmentFiles(final File sourceFile, final Fil ); } log.info( - "Coppied %d bytes from [%s] to [%s]", + "Copied %d bytes from [%s] to [%s]", result.size(), sourceFile.getAbsolutePath(), dir.getAbsolutePath() From b861e63da1eec33eb6d8b8a91ae914ec5c6ce46a Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Tue, 7 Apr 2020 08:35:53 -0700 Subject: [PATCH 3/6] add wrapping dimension selector test. --- .../TestNullableDoubleColumnSelector.java | 55 +++++++++ .../TestNullableFloatColumnSelector.java | 56 +++++++++ .../TestNullableLongColumnSelector.java | 55 +++++++++ .../TestWrappingDimensionSelector.java | 107 ++++++++++++++++++ 4 files changed, 273 insertions(+) create mode 100644 processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java create mode 100644 processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java create mode 100644 processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java create mode 100644 processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java new file mode 100644 index 000000000000..6889b100da95 --- /dev/null +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java @@ -0,0 +1,55 @@ +/* + * 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.segment; + +import org.apache.druid.common.config.NullHandling; + +public class TestNullableDoubleColumnSelector extends TestDoubleColumnSelector +{ + private final Double[] doubles; + + static { + NullHandling.initializeForTests(); + } + + private int index = 0; + + public TestNullableDoubleColumnSelector(Double[] doubles) + { + this.doubles = doubles; + } + + @Override + public double getDouble() + { + return doubles[index] == null ? NullHandling.ZERO_DOUBLE : doubles[index]; + } + + @Override + public boolean isNull() + { + return doubles[index] == null; + } + + public void increment() + { + ++index; + } +} diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java new file mode 100644 index 000000000000..c9f7315946c3 --- /dev/null +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java @@ -0,0 +1,56 @@ +/* + * 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.segment; + +import org.apache.druid.common.config.NullHandling; + +public class TestNullableFloatColumnSelector extends TestFloatColumnSelector +{ + + private final Float[] floats; + + static { + NullHandling.initializeForTests(); + } + + private int index = 0; + + public TestNullableFloatColumnSelector(Float[] floats) + { + this.floats = floats; + } + + @Override + public float getFloat() + { + return floats[index] == null ? NullHandling.ZERO_FLOAT : floats[index]; + } + + @Override + public boolean isNull() + { + return floats[index] == null; + } + + public void increment() + { + ++index; + } +} diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java new file mode 100644 index 000000000000..5606d7ccd586 --- /dev/null +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java @@ -0,0 +1,55 @@ +/* + * 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.segment; + +import org.apache.druid.common.config.NullHandling; + +public class TestNullableLongColumnSelector extends TestLongColumnSelector +{ + private final Long[] longs; + + static { + NullHandling.initializeForTests(); + } + + private int index = 0; + + public TestNullableLongColumnSelector(Long[] longs) + { + this.longs = longs; + } + + @Override + public long getLong() + { + return longs[index] == null ? NullHandling.ZERO_LONG : longs[index]; + } + + @Override + public boolean isNull() + { + return longs[index] == null; + } + + public void increment() + { + ++index; + } +} diff --git a/processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java b/processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java new file mode 100644 index 000000000000..6c4c6aa8ec47 --- /dev/null +++ b/processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java @@ -0,0 +1,107 @@ +/* + * 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.segment; + +import org.junit.Assert; +import org.junit.Test; + +public class TestWrappingDimensionSelector +{ + @Test + public void testLongWrappingDimensionSelector() + { + Long[] vals = new Long[]{24L, null, 50L, 0L, -60L}; + TestNullableLongColumnSelector lngSelector = new TestNullableLongColumnSelector(vals); + + LongWrappingDimensionSelector lngWrapSelector = new LongWrappingDimensionSelector(lngSelector, null); + Assert.assertEquals(24L, lngSelector.getLong()); + Assert.assertEquals("24", lngWrapSelector.getValue()); + + lngSelector.increment(); + Assert.assertEquals(0L, lngSelector.getLong()); + Assert.assertNull("must be the canonical null value", lngWrapSelector.getValue()); + + lngSelector.increment(); + Assert.assertEquals(50L, lngSelector.getLong()); + Assert.assertEquals("50", lngWrapSelector.getValue()); + + lngSelector.increment(); + Assert.assertEquals(0L, lngSelector.getLong()); + Assert.assertEquals("0", lngWrapSelector.getValue()); + + lngSelector.increment(); + Assert.assertEquals(-60L, lngSelector.getLong()); + Assert.assertEquals("-60", lngWrapSelector.getValue()); + } + + @Test + public void testDoubleWrappingDimensionSelector() + { + Double[] vals = new Double[]{32.0d, null, 5.0d, 0.0d, -45.0d}; + TestNullableDoubleColumnSelector dblColSelector = new TestNullableDoubleColumnSelector(vals); + + DoubleWrappingDimensionSelector dblWrapSelector = new DoubleWrappingDimensionSelector(dblColSelector, null); + Assert.assertEquals(32.0d, dblColSelector.getDouble(), 0); + Assert.assertEquals("32.0", dblWrapSelector.getValue()); + + dblColSelector.increment(); + Assert.assertEquals(0d, dblColSelector.getDouble(), 0); + Assert.assertNull("must be the canonical null value", dblWrapSelector.getValue()); + + dblColSelector.increment(); + Assert.assertEquals(5.0d, dblColSelector.getDouble(), 0); + Assert.assertEquals("5.0", dblWrapSelector.getValue()); + + dblColSelector.increment(); + Assert.assertEquals(0.0d, dblColSelector.getDouble(), 0); + Assert.assertEquals("0.0", dblWrapSelector.getValue()); + + dblColSelector.increment(); + Assert.assertEquals(-45.0d, dblColSelector.getDouble(), 0); + Assert.assertEquals("-45.0", dblWrapSelector.getValue()); + } + + @Test + public void testFloatWrappingDimensionSelector() + { + Float[] vals = new Float[]{32.0f, null, 5.0f, 0.0f, -45.0f}; + TestNullableFloatColumnSelector flSelector = new TestNullableFloatColumnSelector(vals); + + FloatWrappingDimensionSelector flWrapSelector = new FloatWrappingDimensionSelector(flSelector, null); + Assert.assertEquals(32.0f, flSelector.getFloat(), 0); + Assert.assertEquals("32.0", flWrapSelector.getValue()); + + flSelector.increment(); + Assert.assertEquals(0f, flSelector.getFloat(), 0); + Assert.assertNull("must be the canonical null value", flWrapSelector.getValue()); + + flSelector.increment(); + Assert.assertEquals(5.0f, flSelector.getFloat(), 0); + Assert.assertEquals("5.0", flWrapSelector.getValue()); + + flSelector.increment(); + Assert.assertEquals(0.0f, flSelector.getFloat(), 0); + Assert.assertEquals("0.0", flWrapSelector.getValue()); + + flSelector.increment(); + Assert.assertEquals(-45.0f, flSelector.getFloat(), 0); + Assert.assertEquals("-45.0", flWrapSelector.getValue()); + } +} From fa8510e91ab3b417aa67ef9495dbe9f9024f7510 Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Tue, 7 Apr 2020 18:45:18 -0700 Subject: [PATCH 4/6] Address review comments. --- .../TestNullableDoubleColumnSelector.java | 10 +++- .../TestNullableFloatColumnSelector.java | 8 +++- .../TestNullableLongColumnSelector.java | 10 +++- ...ava => WrappingDimensionSelectorTest.java} | 46 ++++++++++++------- 4 files changed, 51 insertions(+), 23 deletions(-) rename processing/src/test/java/org/apache/druid/segment/{TestWrappingDimensionSelector.java => WrappingDimensionSelectorTest.java} (72%) diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java index 6889b100da95..80874f39b43d 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java @@ -39,13 +39,19 @@ public TestNullableDoubleColumnSelector(Double[] doubles) @Override public double getDouble() { - return doubles[index] == null ? NullHandling.ZERO_DOUBLE : doubles[index]; + if (doubles[index] != null) { + return doubles[index]; + } else if (NullHandling.replaceWithDefault()) { + return NullHandling.ZERO_DOUBLE; + } else { + throw new UnsupportedOperationException(); + } } @Override public boolean isNull() { - return doubles[index] == null; + return !NullHandling.replaceWithDefault() && doubles[index] == null; } public void increment() diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java index c9f7315946c3..8833548d03e9 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java @@ -40,13 +40,17 @@ public TestNullableFloatColumnSelector(Float[] floats) @Override public float getFloat() { - return floats[index] == null ? NullHandling.ZERO_FLOAT : floats[index]; + if (floats[index] != null) { + return floats[index]; + } else { + return NullHandling.ZERO_FLOAT; + } } @Override public boolean isNull() { - return floats[index] == null; + return !NullHandling.replaceWithDefault() && floats[index] == null; } public void increment() diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java index 5606d7ccd586..674658af9412 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java @@ -39,13 +39,19 @@ public TestNullableLongColumnSelector(Long[] longs) @Override public long getLong() { - return longs[index] == null ? NullHandling.ZERO_LONG : longs[index]; + if (longs[index] != null) { + return longs[index]; + } else if (NullHandling.replaceWithDefault()) { + return NullHandling.ZERO_LONG; + } else { + throw new UnsupportedOperationException(); + } } @Override public boolean isNull() { - return longs[index] == null; + return !NullHandling.replaceWithDefault() && longs[index] == null; } public void increment() diff --git a/processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java b/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java similarity index 72% rename from processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java rename to processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java index 6c4c6aa8ec47..9e2f69bd8427 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestWrappingDimensionSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java @@ -19,10 +19,11 @@ package org.apache.druid.segment; +import org.apache.druid.common.config.NullHandling; import org.junit.Assert; import org.junit.Test; -public class TestWrappingDimensionSelector +public class WrappingDimensionSelectorTest { @Test public void testLongWrappingDimensionSelector() @@ -35,8 +36,11 @@ public void testLongWrappingDimensionSelector() Assert.assertEquals("24", lngWrapSelector.getValue()); lngSelector.increment(); - Assert.assertEquals(0L, lngSelector.getLong()); - Assert.assertNull("must be the canonical null value", lngWrapSelector.getValue()); + if (NullHandling.sqlCompatible()) { + Assert.assertTrue(lngSelector.isNull()); + } else { + Assert.assertEquals(0L, lngSelector.getLong()); + } lngSelector.increment(); Assert.assertEquals(50L, lngSelector.getLong()); @@ -55,26 +59,29 @@ public void testLongWrappingDimensionSelector() public void testDoubleWrappingDimensionSelector() { Double[] vals = new Double[]{32.0d, null, 5.0d, 0.0d, -45.0d}; - TestNullableDoubleColumnSelector dblColSelector = new TestNullableDoubleColumnSelector(vals); + TestNullableDoubleColumnSelector dblSelector = new TestNullableDoubleColumnSelector(vals); - DoubleWrappingDimensionSelector dblWrapSelector = new DoubleWrappingDimensionSelector(dblColSelector, null); - Assert.assertEquals(32.0d, dblColSelector.getDouble(), 0); + DoubleWrappingDimensionSelector dblWrapSelector = new DoubleWrappingDimensionSelector(dblSelector, null); + Assert.assertEquals(32.0d, dblSelector.getDouble(), 0); Assert.assertEquals("32.0", dblWrapSelector.getValue()); - dblColSelector.increment(); - Assert.assertEquals(0d, dblColSelector.getDouble(), 0); - Assert.assertNull("must be the canonical null value", dblWrapSelector.getValue()); + dblSelector.increment(); + if (NullHandling.sqlCompatible()) { + Assert.assertTrue(dblSelector.isNull()); + } else { + Assert.assertEquals(0d, dblSelector.getDouble(), 0); + } - dblColSelector.increment(); - Assert.assertEquals(5.0d, dblColSelector.getDouble(), 0); + dblSelector.increment(); + Assert.assertEquals(5.0d, dblSelector.getDouble(), 0); Assert.assertEquals("5.0", dblWrapSelector.getValue()); - dblColSelector.increment(); - Assert.assertEquals(0.0d, dblColSelector.getDouble(), 0); + dblSelector.increment(); + Assert.assertEquals(0.0d, dblSelector.getDouble(), 0); Assert.assertEquals("0.0", dblWrapSelector.getValue()); - dblColSelector.increment(); - Assert.assertEquals(-45.0d, dblColSelector.getDouble(), 0); + dblSelector.increment(); + Assert.assertEquals(-45.0d, dblSelector.getDouble(), 0); Assert.assertEquals("-45.0", dblWrapSelector.getValue()); } @@ -89,8 +96,13 @@ public void testFloatWrappingDimensionSelector() Assert.assertEquals("32.0", flWrapSelector.getValue()); flSelector.increment(); - Assert.assertEquals(0f, flSelector.getFloat(), 0); - Assert.assertNull("must be the canonical null value", flWrapSelector.getValue()); + if (NullHandling.sqlCompatible()) { + Assert.assertTrue(flSelector.isNull()); + Assert.assertNull(flWrapSelector.getValue()); + } else { + Assert.assertEquals(0f, flSelector.getFloat(), 0); + Assert.assertNotNull(flWrapSelector.getValue()); + } flSelector.increment(); Assert.assertEquals(5.0f, flSelector.getFloat(), 0); From 5952a800eb3544ae1ba24690334826bba1f435bd Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Tue, 7 Apr 2020 22:54:01 -0700 Subject: [PATCH 5/6] nit: replace exception type. --- .../apache/druid/segment/TestNullableDoubleColumnSelector.java | 2 +- .../apache/druid/segment/TestNullableLongColumnSelector.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java index 80874f39b43d..609ce1e01dce 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableDoubleColumnSelector.java @@ -44,7 +44,7 @@ public double getDouble() } else if (NullHandling.replaceWithDefault()) { return NullHandling.ZERO_DOUBLE; } else { - throw new UnsupportedOperationException(); + throw new IllegalStateException("Should never be invoked when current value is null && SQL-compatible null handling is enabled!"); } } diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java index 674658af9412..5e27e995c784 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableLongColumnSelector.java @@ -44,7 +44,7 @@ public long getLong() } else if (NullHandling.replaceWithDefault()) { return NullHandling.ZERO_LONG; } else { - throw new UnsupportedOperationException(); + throw new IllegalStateException("Should never be invoked when current value is null && SQL-compatible null handling is enabled!"); } } From b6f9b96915ffe1fc7a7211083f75ac18534ed976 Mon Sep 17 00:00:00 2001 From: Abhishek Balaji Radhakrishnan Date: Wed, 8 Apr 2020 14:23:46 -0700 Subject: [PATCH 6/6] uh, float is indeed NOT a special case. --- .../apache/druid/segment/TestNullableFloatColumnSelector.java | 4 +++- .../apache/druid/segment/WrappingDimensionSelectorTest.java | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java index 8833548d03e9..19b49610de48 100644 --- a/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java +++ b/processing/src/test/java/org/apache/druid/segment/TestNullableFloatColumnSelector.java @@ -42,8 +42,10 @@ public float getFloat() { if (floats[index] != null) { return floats[index]; - } else { + } else if (NullHandling.replaceWithDefault()) { return NullHandling.ZERO_FLOAT; + } else { + throw new IllegalStateException("Should never be invoked when current value is null && SQL-compatible null handling is enabled!"); } } diff --git a/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java b/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java index 9e2f69bd8427..b208b96f81f5 100644 --- a/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java +++ b/processing/src/test/java/org/apache/druid/segment/WrappingDimensionSelectorTest.java @@ -98,10 +98,8 @@ public void testFloatWrappingDimensionSelector() flSelector.increment(); if (NullHandling.sqlCompatible()) { Assert.assertTrue(flSelector.isNull()); - Assert.assertNull(flWrapSelector.getValue()); } else { Assert.assertEquals(0f, flSelector.getFloat(), 0); - Assert.assertNotNull(flWrapSelector.getValue()); } flSelector.increment();