druid/codestyle/spotbugs-exclude.xml
Gian Merlino 8f90589ce5
Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH. (#13247)
* Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH.

These aggregation functions are documented as creating sketches. However,
they are planned into native aggregators that include finalization logic
to convert the sketch to a number of some sort. This creates an
inconsistency: the functions sometimes return sketches, and sometimes
return numbers, depending on where they lie in the native query plan.

This patch changes these SQL aggregators to _never_ finalize, by using
the "shouldFinalize" feature of the native aggregators. It already
existed for theta sketches. This patch adds the feature for hll and
quantiles sketches.

As to impact, Druid finalizes aggregators in two cases:

- When they appear in the outer level of a query (not a subquery).
- When they are used as input to an expression or finalizing-field-access
  post-aggregator (not any other kind of post-aggregator).

With this patch, the functions will no longer be finalized in these cases.

The second item is not likely to matter much. The SQL functions all declare
return type OTHER, which would be usable as an input to any other function
that makes sense and that would be planned into an expression.

So, the main effect of this patch is the first item. To provide backwards
compatibility with anyone that was depending on the old behavior, the
patch adds a "sqlFinalizeOuterSketches" query context parameter that
restores the old behavior.

Other changes:

1) Move various argument-checking logic from runtime to planning time in
   DoublesSketchListArgBaseOperatorConversion, by adding an OperandTypeChecker.

2) Add various JsonIgnores to the sketches to simplify their JSON representations.

3) Allow chaining of ExpressionPostAggregators and other PostAggregators
   in the SQL layer.

4) Avoid unnecessary FieldAccessPostAggregator wrapping in the SQL layer,
   now that expressions can operate on complex inputs.

5) Adjust return type to thetaSketch (instead of OTHER) in
   ThetaSketchSetBaseOperatorConversion.

* Fix benchmark class.

* Fix compilation error.

* Fix ThetaSketchSqlAggregatorTest.

* Hopefully fix ITAutoCompactionTest.

* Adjustment to ITAutoCompactionTest.
2022-11-03 09:43:00 -07:00

139 lines
6.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!--
To enforce Spotbugs into the codebase, first, all the errors are
ignored, so we can add them one by one.
Some of the bugs will only occur once or twice on the codebase,
while others will occur potentially a lot.
Reference: https://github.com/apache/druid/pull/7894/files
-->
<FindBugsFilter>
<Match>
<Or>
<Class name="org.apache.druid.sql.calcite.parser.SimpleCharStream"/>
<Class name="org.apache.druid.sql.calcite.parser.TokenMgrError"/>
<Class name="org.apache.druid.sql.calcite.parser.Token"/>
<Class name="org.apache.druid.sql.calcite.parser.DruidSqlParserImplTokenManager"/>
<Class name="org.apache.druid.sql.calcite.parser.DruidSqlParserImplConstants"/>
<Class name="org.apache.druid.sql.calcite.parser.DruidSqlParserImpl"/>
<Class name="org.apache.druid.sql.calcite.parser.DruidSqlParserImpl$JJCalls"/>
</Or>
</Match>
<!-- Ignore "equals" bugs for JsonInclude filter classes. They rely on strange-looking "equals" methods. -->
<Match>
<And>
<Bug pattern="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS"/>
<Or>
<Class name="org.apache.druid.jackson.DefaultTrueJsonIncludeFilter"/>
<Class name="org.apache.druid.query.scan.ScanQuery$ScanRowsLimitJsonIncludeFilter"/>
<Class name="org.apache.druid.query.scan.ScanQuery$ScanTimeOrderJsonIncludeFilter"/>
<Class name="org.apache.druid.query.scan.ScanQuery$BatchSizeJsonIncludeFilter"/>
<Class name="org.apache.druid.query.groupby.orderby.DefaultLimitSpec$LimitJsonIncludeFilter"/>
<Class name="org.apache.druid.segment.VirtualColumns$JsonIncludeFilter"/>
</Or>
</And>
</Match>
<Match>
<And>
<Bug pattern="SE_BAD_FIELD_STORE" />
<Class name="org.apache.druid.server.AsyncQueryForwardingServlet" />
</And>
</Match>
<Match>
<And>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
<Class name="org.apache.druid.sql.calcite.planner.CapturedState" />
</And>
</Match>
<Match>
<!-- Spotbugs doesn't like the MAGIC array -->
<And>
<Bug pattern="MS_MUTABLE_ARRAY" />
<Class name="org.apache.druid.frame.file.FrameFileWriter" />
</And>
</Match>
<Match>
<!-- Spotbugs doesn't like awaiting a latch without checking return value -->
<And>
<Bug pattern="RV_RETURN_VALUE_IGNORED" />
<Class name="org.apache.druid.msq.indexing.MSQWorkerTaskLauncher" />
</And>
</Match>
<Bug pattern="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION"/>
<Bug pattern="BC_UNCONFIRMED_CAST"/>
<Bug pattern="BIT_SIGNED_CHECK_HIGH_BIT"/>
<Bug pattern="BX_UNBOXING_IMMEDIATELY_REBOXED"/>
<Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
<Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE"/>
<Bug pattern="DC_DOUBLECHECK"/>
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING"/>
<Bug pattern="DM_EXIT"/>
<Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/>
<Bug pattern="EI_EXPOSE_REP"/>
<Bug pattern="EI_EXPOSE_REP2"/>
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
<Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
<Bug pattern="EQ_UNUSUAL"/>
<Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ"/>
<Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
<Bug pattern="HE_EQUALS_USE_HASHCODE"/>
<Bug pattern="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD"/>
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE"/>
<Bug pattern="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL"/>
<Bug pattern="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT"/>
<Bug pattern="IS2_INCONSISTENT_SYNC"/>
<Bug pattern="JLM_JSR166_UTILCONCURRENT_MONITORENTER"/>
<Bug pattern="JLM_JSR166_UTILCONCURRENT_MONITORENTER"/>
<Bug pattern="MS_FINAL_PKGPROTECT"/>
<Bug pattern="MS_PKGPROTECT"/>
<Bug pattern="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT"/>
<Bug pattern="NP_GUARANTEED_DEREF"/>
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
<Bug pattern="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION"/>
<Bug pattern="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE"/>
<Bug pattern="NP_NULL_PARAM_DEREF"/>
<Bug pattern="NP_NULL_PARAM_DEREF_NONVIRTUAL"/>
<Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE"/>
<Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT"/>
<Bug pattern="OBL_UNSATISFIED_OBLIGATION"/>
<Bug pattern="OS_OPEN_STREAM"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
<Bug pattern="REC_CATCH_EXCEPTION"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
<Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION"/>
<Bug pattern="SE_BAD_FIELD"/>
<Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/>
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
<Bug pattern="SR_NOT_CHECKED"/>
<Bug pattern="SWL_SLEEP_WITH_LOCK_HELD"/>
<Bug pattern="UL_UNRELEASED_LOCK_EXCEPTION_PATH"/>
<Bug pattern="URF_UNREAD_FIELD"/>
</FindBugsFilter>