You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/16 09:09:56 UTC

[GitHub] [druid] maytasm opened a new pull request #11922: Support filtering data in Auto Compaction

maytasm opened a new pull request #11922:
URL: https://github.com/apache/druid/pull/11922


   Support filtering data in Auto Compaction
   
   ### Description
   
   This PR adds `filter` field via the `transformSpec` to manual compaction and auto compaction.
   By setting `filter`, the user will be able to drop data matching the `filter` from the datasource.
   
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] suneet-s commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r752596716



##########
File path: core/src/test/java/org/apache/druid/timeline/DataSegmentTest.java
##########
@@ -145,7 +146,7 @@ public void testV1Serialization() throws Exception
     Assert.assertEquals(ImmutableMap.of("type", "numbered", "partitionNum", 3, "partitions", 0), objectMap.get("shardSpec"));
     Assert.assertEquals(TEST_VERSION, objectMap.get("binaryVersion"));
     Assert.assertEquals(1, objectMap.get("size"));
-    Assert.assertEquals(4, ((Map) objectMap.get("lastCompactionState")).size());
+    Assert.assertEquals(5, ((Map) objectMap.get("lastCompactionState")).size());

Review comment:
       Scratch that. It's v1 of DataSegment. This seems fine.




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] maytasm commented on pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
maytasm commented on pull request #11922:
URL: https://github.com/apache/druid/pull/11922#issuecomment-971488319


   > is the PR going to add more changes? One thing I found interesting is that we are re-compacting the data if the filter changes. But the data we are compacting has already passed through a filter. Those records are gone and are not going to come back. Say if I first do a filter on `dim = a` and then change the filter to `dim = b`. It might be nice to add a warning in the UI for this when we eventually add those changes.
   
   I have finish adding all changes to this PR (implementation, unit tests, docs, integration tests). Your understanding is correct. That is now true for other auto compaction config that can remove data. For example, if you remove one of your dimension using auto compaction then add that dimension back later, the removed dimension will not come back (although that dimension in future data will not be removed). I'll work on clarifying this in the docs to make sure that user are well aware of this new behavior in a separate PR.  


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] suneet-s commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r752596131



##########
File path: core/src/test/java/org/apache/druid/timeline/DataSegmentTest.java
##########
@@ -145,7 +146,7 @@ public void testV1Serialization() throws Exception
     Assert.assertEquals(ImmutableMap.of("type", "numbered", "partitionNum", 3, "partitions", 0), objectMap.get("shardSpec"));
     Assert.assertEquals(TEST_VERSION, objectMap.get("binaryVersion"));
     Assert.assertEquals(1, objectMap.get("size"));
-    Assert.assertEquals(4, ((Map) objectMap.get("lastCompactionState")).size());
+    Assert.assertEquals(5, ((Map) objectMap.get("lastCompactionState")).size());

Review comment:
       this is a test for "V1" Shouldn't this test remain without the `filter` being part of the CompactionState?




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] maytasm commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r751148615



##########
File path: server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
##########
@@ -364,6 +365,16 @@ private CoordinatorStats doRun(
           dimensionsSpec = null;
         }
 
+        // Create transformSpec to send to compaction task
+        ClientCompactionTaskTransformSpec transformSpec;
+        if (config.getTransformSpec() != null) {
+          transformSpec = new ClientCompactionTaskTransformSpec(
+              config.getTransformSpec().getFilter()
+          );
+        } else {
+          transformSpec = null;
+        }

Review comment:
       Done




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] maytasm merged pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
maytasm merged pull request #11922:
URL: https://github.com/apache/druid/pull/11922


   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] abhishekagarwal87 commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r750287308



##########
File path: server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
##########
@@ -364,6 +365,16 @@ private CoordinatorStats doRun(
           dimensionsSpec = null;
         }
 
+        // Create transformSpec to send to compaction task
+        ClientCompactionTaskTransformSpec transformSpec;
+        if (config.getTransformSpec() != null) {
+          transformSpec = new ClientCompactionTaskTransformSpec(
+              config.getTransformSpec().getFilter()
+          );
+        } else {
+          transformSpec = null;
+        }

Review comment:
       ```suggestion
           ClientCompactionTaskTransformSpec transformSpec = null;
           if (config.getTransformSpec() != null) {
             transformSpec = new ClientCompactionTaskTransformSpec(
                 config.getTransformSpec().getFilter()
             );
           } 
   ```

##########
File path: server/src/main/java/org/apache/druid/client/indexing/ClientCompactionTaskTransformSpec.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.client.indexing;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.query.filter.DimFilter;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+/**
+ * Spec containing transform configs for Compaction Task.
+ * This class mimics JSON field names for fields supported in compaction task with
+ * the corresponding fields in {@link org.apache.druid.segment.transform.TransformSpec}.
+ * This is done for end-user ease of use. Basically, end-user will use the same syntax / JSON structure to set
+ * transform configs for Compaction task as they would for any other ingestion task.
+ */
+public class ClientCompactionTaskTransformSpec
+{
+  @Nullable private final DimFilter filter;
+
+  @JsonCreator
+  public ClientCompactionTaskTransformSpec(
+      @JsonProperty("filter") final DimFilter filter
+  )
+  {
+    this.filter = filter;
+  }
+
+  @Nullable
+  public DimFilter getFilter()

Review comment:
       is it missing `JsonProperty` annotation? 

##########
File path: server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
##########
@@ -364,6 +365,16 @@ private CoordinatorStats doRun(
           dimensionsSpec = null;
         }
 
+        // Create transformSpec to send to compaction task
+        ClientCompactionTaskTransformSpec transformSpec;
+        if (config.getTransformSpec() != null) {
+          transformSpec = new ClientCompactionTaskTransformSpec(
+              config.getTransformSpec().getFilter()
+          );
+        } else {
+          transformSpec = null;
+        }

Review comment:
       nit - could be simplified. 




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] suneet-s commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r754590267



##########
File path: server/src/test/java/org/apache/druid/server/coordinator/duty/NewestSegmentFirstPolicyTest.java
##########
@@ -1144,7 +1149,123 @@ public void testIteratorReturnsSegmentsAsSegmentsWasCompactedAndHaveDifferentDim
             130000,
             new Period("P0D"),
             null,
-            new UserCompactionTaskDimensionsConfig(null)
+            new UserCompactionTaskDimensionsConfig(null),
+            null
+        )),
+        ImmutableMap.of(DATA_SOURCE, timeline),
+        Collections.emptyMap()
+    );
+    // No more
+    Assert.assertFalse(iterator.hasNext());
+  }
+
+  @Test
+  public void testIteratorReturnsSegmentsAsSegmentsWasCompactedAndHaveDifferentFilter() throws Exception
+  {
+    NullHandling.initializeForTests();

Review comment:
       nit: I think this should be done at the test class level.




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [druid] maytasm commented on a change in pull request #11922: Support filtering data in Auto Compaction

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #11922:
URL: https://github.com/apache/druid/pull/11922#discussion_r751148059



##########
File path: server/src/main/java/org/apache/druid/client/indexing/ClientCompactionTaskTransformSpec.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.client.indexing;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.query.filter.DimFilter;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+/**
+ * Spec containing transform configs for Compaction Task.
+ * This class mimics JSON field names for fields supported in compaction task with
+ * the corresponding fields in {@link org.apache.druid.segment.transform.TransformSpec}.
+ * This is done for end-user ease of use. Basically, end-user will use the same syntax / JSON structure to set
+ * transform configs for Compaction task as they would for any other ingestion task.
+ */
+public class ClientCompactionTaskTransformSpec
+{
+  @Nullable private final DimFilter filter;
+
+  @JsonCreator
+  public ClientCompactionTaskTransformSpec(
+      @JsonProperty("filter") final DimFilter filter
+  )
+  {
+    this.filter = filter;
+  }
+
+  @Nullable
+  public DimFilter getFilter()

Review comment:
       Yes. Fixed




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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