From e9fb28defd1ab114f0af7a45cde737075ae59fa8 Mon Sep 17 00:00:00 2001
From: huangfeng1993 <715187657@qq.com>
Date: Wed, 19 Jan 2022 16:45:52 +0800
Subject: [PATCH] KE-34157 max expr limit for cnf
---
cassandra/pom.xml | 4 ++--
core/pom.xml | 4 ++--
.../java/org/apache/calcite/rex/RexUtil.java | 18 ++++++++++++++++++
druid/pom.xml | 4 ++--
elasticsearch2/pom.xml | 4 ++--
elasticsearch5/pom.xml | 4 ++--
example/csv/pom.xml | 4 ++--
example/function/pom.xml | 4 ++--
example/pom.xml | 4 ++--
file/pom.xml | 4 ++--
geode/pom.xml | 4 ++--
linq4j/pom.xml | 4 ++--
mongodb/pom.xml | 4 ++--
pig/pom.xml | 4 ++--
piglet/pom.xml | 4 ++--
plus/pom.xml | 4 ++--
pom.xml | 2 +-
server/pom.xml | 4 ++--
spark/pom.xml | 4 ++--
splunk/pom.xml | 4 ++--
ubenchmark/pom.xml | 2 +-
21 files changed, 56 insertions(+), 38 deletions(-)
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index bc81900d4836..d7c86734cce3 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-cassandra
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Cassandra
Cassandra adapter for Calcite
diff --git a/core/pom.xml b/core/pom.xml
index 7047552cab44..2e05ac3f96a4 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-core
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Core
Core Calcite APIs and engine.
diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index 6f467bed761f..1e135f8cff2e 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -1491,6 +1491,15 @@ public static RexNode toCnf(RexBuilder rexBuilder, int maxCnfNodeCount,
return new CnfHelper(rexBuilder, maxCnfNodeCount).toCnf(rex);
}
+ /**
+ * for example (a AND b) OR c -> (a OR c) AND (b OR c)
+ * maxCnfExprCount = 2 1. (a OR c) 2.(b OR c)
+ */
+ public static RexNode toCnf(RexBuilder rexBuilder, int maxCnfNodeCount, int maxCnfExprCount,
+ RexNode rex) {
+ return new CnfHelper(rexBuilder, maxCnfNodeCount, maxCnfExprCount).toCnf(rex);
+ }
+
/** Converts an expression to disjunctive normal form (DNF).
*
*
DNF: It is a form of logical formula which is disjunction of conjunctive
@@ -2213,12 +2222,18 @@ private static class CnfHelper {
final RexBuilder rexBuilder;
int currentCount;
final int maxNodeCount; // negative means no limit
+ int maxExprCount = 10000;
private CnfHelper(RexBuilder rexBuilder, int maxNodeCount) {
this.rexBuilder = rexBuilder;
this.maxNodeCount = maxNodeCount;
}
+ private CnfHelper(RexBuilder rexBuilder, int maxNodeCount, int maxExprCount) {
+ this(rexBuilder, maxNodeCount);
+ this.maxExprCount = maxExprCount;
+ }
+
public RexNode toCnf(RexNode rex) {
try {
this.currentCount = 0;
@@ -2264,6 +2279,9 @@ private RexNode toCnf2(RexNode rex) {
list.add(or(ImmutableList.of(h, t)));
}
}
+ if (list.size() > maxExprCount) {
+ throw OverflowError.INSTANCE;
+ }
return and(list);
case NOT:
final RexNode arg = ((RexCall) rex).getOperands().get(0);
diff --git a/druid/pom.xml b/druid/pom.xml
index 6abc12c386e4..64ec8f14254e 100644
--- a/druid/pom.xml
+++ b/druid/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-druid
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Druid
Druid adapter for Calcite
diff --git a/elasticsearch2/pom.xml b/elasticsearch2/pom.xml
index 951ccd1e53ca..bb70925a0560 100644
--- a/elasticsearch2/pom.xml
+++ b/elasticsearch2/pom.xml
@@ -21,12 +21,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-elasticsearch2
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Elasticsearch
Elasticsearch adapter for Calcite
diff --git a/elasticsearch5/pom.xml b/elasticsearch5/pom.xml
index 3b9fe8562ca9..078fadf2d13e 100644
--- a/elasticsearch5/pom.xml
+++ b/elasticsearch5/pom.xml
@@ -21,12 +21,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-elasticsearch5
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Elasticsearch5
Elasticsearch5 adapter for Calcite
diff --git a/example/csv/pom.xml b/example/csv/pom.xml
index 49a84c9c2f3b..f18f2ba66705 100644
--- a/example/csv/pom.xml
+++ b/example/csv/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite-example
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-example-csv
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Example CSV
An example Calcite provider that reads CSV files
diff --git a/example/function/pom.xml b/example/function/pom.xml
index c1d74b597e37..aec41f4f799c 100644
--- a/example/function/pom.xml
+++ b/example/function/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite-example
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-example-function
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Example Function
Examples of user-defined Calcite functions
diff --git a/example/pom.xml b/example/pom.xml
index 36e015377ee5..6f215a5e1462 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -20,13 +20,13 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-example
pom
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Examples
Calcite examples
diff --git a/file/pom.xml b/file/pom.xml
index 35b12a66db57..abe6abbe57a8 100644
--- a/file/pom.xml
+++ b/file/pom.xml
@@ -19,13 +19,13 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-file
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite File
Calcite provider that reads files and URIs
diff --git a/geode/pom.xml b/geode/pom.xml
index 99e8c72e95f4..aa83a50dae35 100644
--- a/geode/pom.xml
+++ b/geode/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-geode
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Geode
Geode adapter for Calcite
diff --git a/linq4j/pom.xml b/linq4j/pom.xml
index 5c84f9fb161d..2a5e3d2db286 100644
--- a/linq4j/pom.xml
+++ b/linq4j/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-linq4j
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Linq4j
Calcite APIs for LINQ (Language-Integrated Query) in Java
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index d9d2e755eba5..c6bcb6a55550 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-mongodb
jar
-1.16.0-kylin-4.x-r68
+1.16.0-kylin-4.x-r69
Calcite MongoDB
MongoDB adapter for Calcite
diff --git a/pig/pom.xml b/pig/pom.xml
index b615511c5676..f0dbd7790aef 100644
--- a/pig/pom.xml
+++ b/pig/pom.xml
@@ -20,11 +20,11 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-pig
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Pig
Pig adapter for Calcite
diff --git a/piglet/pom.xml b/piglet/pom.xml
index a10da517b282..ed5e4391536d 100644
--- a/piglet/pom.xml
+++ b/piglet/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-piglet
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Piglet
Pig-like language built on top of Calcite algebra
diff --git a/plus/pom.xml b/plus/pom.xml
index 42bb86c86d85..1d1275cdbec0 100644
--- a/plus/pom.xml
+++ b/plus/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-plus
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Plus
Miscellaneous extras for Calcite
diff --git a/pom.xml b/pom.xml
index b5089369ad21..3b53dc1efd0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@ limitations under the License.
org.apache.calcite
calcite
pom
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite
diff --git a/server/pom.xml b/server/pom.xml
index 970bafee1d31..bfc5944a3884 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-server
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Server
Calcite Server
diff --git a/spark/pom.xml b/spark/pom.xml
index 0f74876e3c14..92e1740d6891 100644
--- a/spark/pom.xml
+++ b/spark/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
calcite-spark
jar
- 1.16.0-kylin-4.x-r68
+ 1.16.0-kylin-4.x-r69
Calcite Spark
diff --git a/splunk/pom.xml b/splunk/pom.xml
index 2644e6df4d7d..866b41b848cb 100644
--- a/splunk/pom.xml
+++ b/splunk/pom.xml
@@ -20,12 +20,12 @@ limitations under the License.
org.apache.calcite
calcite
-1.16.0-kylin-4.x-r68
+1.16.0-kylin-4.x-r69
calcite-splunk
jar
-1.16.0-kylin-4.x-r68
+1.16.0-kylin-4.x-r69
Calcite Splunk
Splunk adapter for Calcite; also a JDBC driver for Splunk
diff --git a/ubenchmark/pom.xml b/ubenchmark/pom.xml
index fb0f26c7d495..822bff87f3c2 100644
--- a/ubenchmark/pom.xml
+++ b/ubenchmark/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
org.apache.calcite
calcite
-1.16.0-kylin-4.x-r68
+1.16.0-kylin-4.x-r69