github-advanced-security[bot] commented on code in PR #18531:
URL: https://github.com/apache/druid/pull/18531#discussion_r2349898935


##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/filter/IcebergTimeWindowFilter.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.iceberg.filter;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.common.config.Configs;
+import org.apache.druid.java.util.common.DateTimes;
+import org.apache.iceberg.TableScan;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.expressions.Expressions;
+import org.apache.iceberg.expressions.Literal;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Period;
+
+public class IcebergTimeWindowFilter implements IcebergFilter
+{
+  @JsonProperty
+  private final String filterColumn;
+
+  @JsonProperty
+  private final Duration lookbackDuration;
+
+  @JsonProperty
+  private final Duration lookaheadDuration;
+
+  @JsonProperty
+  private final DateTime baseTime;
+
+  @JsonCreator
+  public IcebergTimeWindowFilter(
+      @JsonProperty("filterColumn") String filterColumn,
+      @JsonProperty("lookbackDuration") Duration lookbackDuration,
+      @JsonProperty("lookaheadDuration") Duration lookaheadDuration,
+      @JsonProperty("baseTime") DateTime baseTime
+  )
+  {
+    Preconditions.checkNotNull(filterColumn, "You must specify a filter column 
on the timeWindow filter");
+    this.filterColumn = filterColumn;
+    this.lookbackDuration = Configs.valueOrDefault(lookbackDuration, new 
Period("P1D").toStandardDuration());
+    this.lookaheadDuration = Configs.valueOrDefault(lookaheadDuration, 
Duration.ZERO);
+    this.baseTime = Configs.valueOrDefault(baseTime, DateTimes.nowUtc());
+  }
+
+  @Override
+  public TableScan filter(TableScan tableScan)
+  {
+    return tableScan.filter(getFilterExpression());
+  }
+
+  @Override
+  public Expression getFilterExpression()
+  {
+    // Convert milliseconds to microseconds because Iceberg TimestampType uses 
microsecond precision
+    Long lookbackDurationinMicros = (baseTime.getMillis() - 
lookbackDuration.getMillis()) * 1000L;
+    Long lookforwardDurationinMicros = (baseTime.getMillis() + 
lookaheadDuration.getMillis()) * 1000L;

Review Comment:
   ## Boxed variable is never null
   
   The variable 'lookforwardDurationinMicros' is only assigned values of 
primitive type and is never 'null', but it is declared with the boxed type 
'Long'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10332)



##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/filter/IcebergTimeWindowFilter.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.iceberg.filter;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.common.config.Configs;
+import org.apache.druid.java.util.common.DateTimes;
+import org.apache.iceberg.TableScan;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.expressions.Expressions;
+import org.apache.iceberg.expressions.Literal;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Period;
+
+public class IcebergTimeWindowFilter implements IcebergFilter
+{
+  @JsonProperty
+  private final String filterColumn;
+
+  @JsonProperty
+  private final Duration lookbackDuration;
+
+  @JsonProperty
+  private final Duration lookaheadDuration;
+
+  @JsonProperty
+  private final DateTime baseTime;
+
+  @JsonCreator
+  public IcebergTimeWindowFilter(
+      @JsonProperty("filterColumn") String filterColumn,
+      @JsonProperty("lookbackDuration") Duration lookbackDuration,
+      @JsonProperty("lookaheadDuration") Duration lookaheadDuration,
+      @JsonProperty("baseTime") DateTime baseTime
+  )
+  {
+    Preconditions.checkNotNull(filterColumn, "You must specify a filter column 
on the timeWindow filter");
+    this.filterColumn = filterColumn;
+    this.lookbackDuration = Configs.valueOrDefault(lookbackDuration, new 
Period("P1D").toStandardDuration());
+    this.lookaheadDuration = Configs.valueOrDefault(lookaheadDuration, 
Duration.ZERO);
+    this.baseTime = Configs.valueOrDefault(baseTime, DateTimes.nowUtc());
+  }
+
+  @Override
+  public TableScan filter(TableScan tableScan)
+  {
+    return tableScan.filter(getFilterExpression());
+  }
+
+  @Override
+  public Expression getFilterExpression()
+  {
+    // Convert milliseconds to microseconds because Iceberg TimestampType uses 
microsecond precision
+    Long lookbackDurationinMicros = (baseTime.getMillis() - 
lookbackDuration.getMillis()) * 1000L;

Review Comment:
   ## Boxed variable is never null
   
   The variable 'lookbackDurationinMicros' is only assigned values of primitive 
type and is never 'null', but it is declared with the boxed type 'Long'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10331)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to