Skip to content

Commit

Permalink
vectorize logical operators and boolean functions (#11184)
Browse files Browse the repository at this point in the history
changes:
* adds new config, druid.expressions.useStrictBooleans which make longs the official boolean type of all expressions
* vectorize logical operators and boolean functions, some only if useStrictBooleans is true
  • Loading branch information
clintropolis authored Dec 3, 2021
1 parent f47afd7 commit 84b4bf5
Show file tree
Hide file tree
Showing 51 changed files with 2,753 additions and 677 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.druid.java.util.common.guava.Sequence;
import org.apache.druid.java.util.common.io.Closer;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.math.expr.ExpressionProcessing;
import org.apache.druid.query.DruidProcessingConfig;
import org.apache.druid.query.QueryContexts;
import org.apache.druid.query.QueryRunnerFactoryConglomerate;
Expand Down Expand Up @@ -80,6 +81,7 @@ public class SqlExpressionBenchmark
static {
NullHandling.initializeForTests();
Calcites.setSystemProperties();
ExpressionProcessing.initializeForStrictBooleansTests(true);
}

private static final DruidProcessingConfig PROCESSING_CONFIG = new DruidProcessingConfig()
Expand Down Expand Up @@ -181,8 +183,12 @@ public String getFormatString()
"SELECT CONCAT(string2, '-', long2), SUM(long1 * double4) FROM foo GROUP BY 1 ORDER BY 2",
// 28: group by single input string low cardinality expr with expr agg
"SELECT CONCAT(string2, '-', 'foo'), SUM(long1 * long4) FROM foo GROUP BY 1 ORDER BY 2",
// 28: group by single input string high cardinality expr with expr agg
"SELECT CONCAT(string3, '-', 'foo'), SUM(long1 * long4) FROM foo GROUP BY 1 ORDER BY 2"
// 29: group by single input string high cardinality expr with expr agg
"SELECT CONCAT(string3, '-', 'foo'), SUM(long1 * long4) FROM foo GROUP BY 1 ORDER BY 2",
// 30: logical and operator
"SELECT CAST(long1 as BOOLEAN) AND CAST (long2 as BOOLEAN), COUNT(*) FROM foo GROUP BY 1 ORDER BY 2",
// 31: isnull, notnull
"SELECT long5 IS NULL, long3 IS NOT NULL, count(*) FROM foo GROUP BY 1,2 ORDER BY 3"
);

@Param({"5000000"})
Expand Down Expand Up @@ -226,7 +232,9 @@ public String getFormatString()
"26",
"27",
"28",
"29"
"29",
"30",
"31"
})
private String query;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ public class NullValueHandlingConfig
@JsonProperty("useDefaultValueForNull")
private final boolean useDefaultValuesForNull;


@JsonCreator
public NullValueHandlingConfig(@JsonProperty("useDefaultValueForNull") Boolean useDefaultValuesForNull)
public NullValueHandlingConfig(
@JsonProperty("useDefaultValueForNull") Boolean useDefaultValuesForNull
)
{
this.useDefaultValuesForNull = useDefaultValuesForNull == null
? Boolean.valueOf(System.getProperty(NULL_HANDLING_CONFIG_STRING, "true"))
: useDefaultValuesForNull;
if (useDefaultValuesForNull == null) {
this.useDefaultValuesForNull = Boolean.valueOf(System.getProperty(NULL_HANDLING_CONFIG_STRING, "true"));
} else {
this.useDefaultValuesForNull = useDefaultValuesForNull;
}
}

public boolean isUseDefaultValuesForNull()
Expand Down
Loading

0 comments on commit 84b4bf5

Please sign in to comment.