clintropolis commented on a change in pull request #6902: sql, filters, and 
virtual columns 
URL: https://github.com/apache/incubator-druid/pull/6902#discussion_r258368750
 
 

 ##########
 File path: 
extensions-core/druid-bloom-filter/src/test/java/org/apache/druid/query/filter/sql/BloomDimFilterSqlTest.java
 ##########
 @@ -165,11 +166,41 @@ public void testBloomFilterVirtualColumn() throws 
Exception
     );
   }
 
+  @Test
+  public void testBloomFilterVirtualColumn() throws Exception
+  {
+    BloomKFilter filter = new BloomKFilter(1500);
+    filter.addString("def-foo");
+    byte[] bytes = BloomFilterSerializersModule.bloomKFilterToBytes(filter);
+    String base64 = StringUtils.encodeBase64String(bytes);
+
+    testQuery(
+        StringUtils.format("SELECT COUNT(*) FROM druid.foo WHERE 
bloom_filter_test(concat(dim1, '-foo'), '%s')", base64),
+        ImmutableList.of(
+            Druids.newTimeseriesQueryBuilder()
+                  .dataSource(CalciteTests.DATASOURCE1)
+                  .intervals(QSS(Filtration.eternity()))
+                  .granularity(Granularities.ALL)
+                  .virtualColumns(EXPRESSION_VIRTUAL_COLUMN("v0", 
"concat(\"dim1\",'-foo')", ValueType.STRING))
+                  .filters(
+                      new BloomDimFilter("v0", 
BloomKFilterHolder.fromBloomKFilter(filter), null)
+                  )
+                  .aggregators(AGGS(new CountAggregatorFactory("a0")))
+                  .context(TIMESERIES_CONTEXT_DEFAULT)
+                  .build()
+        ),
+        ImmutableList.of(
+            new Object[]{1L}
+        )
+    );
+  }
+
+
   @Test
   public void testBloomFilterVirtualColumnNumber() throws Exception
   {
     BloomKFilter filter = new BloomKFilter(1500);
-    filter.addDouble(20.2);
+    filter.addFloat(20.2f);
 
 Review comment:
   Ah, so the issue here I think is that ```bloom_filter_test(2 * CAST(dim1 AS 
float), '...')``` the _native Druid expression_ in the `ExpressionDimFilter` 
will treat the `2 * CAST(dim1 AS float)` as a `DoubleExpr` since there are no 
floats in native expressions, which will call `testDouble` on the bloom filter 
part of the expression. The SQL parser will treat the `2 * CAST(dim1 AS float)` 
sub expression as a `ValueType.FLOAT` typed virtual column input to the bloom 
filter, which will call `testFloat` instead.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to