You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by gi...@apache.org on 2019/04/14 22:03:44 UTC

[incubator-druid] branch master updated: SQL: Include virtual columns used for filtering in ScanQuery. (#7472)

This is an automated email from the ASF dual-hosted git repository.

gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 7211916  SQL: Include virtual columns used for filtering in ScanQuery. (#7472)
7211916 is described below

commit 721191635aa719e8b82caacae7621478ab3b6ca5
Author: Gian Merlino <gi...@gmail.com>
AuthorDate: Sun Apr 14 15:03:36 2019 -0700

    SQL: Include virtual columns used for filtering in ScanQuery. (#7472)
    
    PR #6902 introduced the ability to use virtual columns for filters, but they
    were being omitted from "scan" queries, so filters would refer to a null column
    instead of the intended virtual column.
---
 .../apache/druid/sql/calcite/rel/DruidQuery.java   |  2 +-
 .../apache/druid/sql/calcite/CalciteQueryTest.java | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
index 43f8751..c5a7320 100644
--- a/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
+++ b/sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
@@ -1011,7 +1011,7 @@ public class DruidQuery
     return new ScanQuery(
         dataSource,
         filtration.getQuerySegmentSpec(),
-        selectProjection != null ? VirtualColumns.create(selectProjection.getVirtualColumns()) : VirtualColumns.EMPTY,
+        getVirtualColumns(true),
         ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST,
         0,
         scanLimit,
diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
index 2a9049d..1e4d799 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
@@ -576,6 +576,30 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
   }
 
   @Test
+  public void testSelectWithExpressionFilter() throws Exception
+  {
+    testQuery(
+        "SELECT dim1 FROM druid.foo WHERE m1 + 1 = 7",
+        ImmutableList.of(
+            newScanQueryBuilder()
+                .dataSource(CalciteTests.DATASOURCE1)
+                .intervals(querySegmentSpec(Filtration.eternity()))
+                .virtualColumns(
+                    expressionVirtualColumn("v0", "(\"m1\" + 1)", ValueType.FLOAT)
+                )
+                .filters(selector("v0", "7", null))
+                .columns("dim1")
+                .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+                .context(QUERY_CONTEXT_DEFAULT)
+                .build()
+        ),
+        ImmutableList.of(
+            new Object[]{"abc"}
+        )
+    );
+  }
+
+  @Test
   public void testSelectStarWithLimitTimeDescending() throws Exception
   {
     testQuery(


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