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

 ##########
 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:
   I don't remember exactly, I opened this PR too long ago 😜. If you look at 
the filter portion of the sql expression, ``` bloom_filter_test(2 * CAST(dim1 
AS float), '%s')```,
   I _think_ it's because the expression is coming up as having a `float` type 
in sql, which makes the virtual column have `ValueType.FLOAT`, where as perhaps 
`ExpressionDimFilter` was either (incorrectly?) coercing as `ValueType.DOUBLE` 
previously? I'll look further into this issue, but this version seems to match 
the intention of the SQL expression more correctly to me.

----------------------------------------------------------------
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