This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new bb4881b [fix](planner) fix using clause npe (#7952)
bb4881b is described below
commit bb4881bb0469dbe014ab3ee866a47695f32ee563
Author: shee <[email protected]>
AuthorDate: Wed Feb 16 11:56:44 2022 +0800
[fix](planner) fix using clause npe (#7952)
Issue Number: close #7953
---
.../java/org/apache/doris/analysis/FromClause.java | 4 +--
.../java/org/apache/doris/analysis/TableRef.java | 4 +++
.../org/apache/doris/planner/QueryPlanTest.java | 38 ++++++++++++++++++++++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
index fba2085..be71841 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FromClause.java
@@ -101,10 +101,10 @@ public class FromClause implements ParseNode,
Iterable<TableRef> {
public int compare(TableRef tableref1, TableRef tableref2) {
int i1 = 0;
int i2 = 0;
- if (tableref1.getOnClause() != null) {
+ if (tableref1.getOnClause() != null ||
tableref1.getUsingClause() != null) {
i1 = 1;
}
- if (tableref2.getOnClause() != null) {
+ if (tableref2.getOnClause() != null ||
tableref2.getUsingClause() != null) {
i2 = 1;
}
return i1 - i2;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java
index c0c39ed..ced85f1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java
@@ -306,6 +306,10 @@ public class TableRef implements ParseNode, Writable {
this.usingColNames = colNames;
}
+ public List<String> getUsingClause() {
+ return this.usingColNames;
+ }
+
public TableRef getLeftTblRef() {
return leftTblRef;
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index 5e876a1..dc2206e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -38,6 +38,7 @@ import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.Replica;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.Type;
+import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.jmockit.Deencapsulation;
@@ -410,6 +411,28 @@ public class QueryPlanTest {
createView("create view test.function_view AS SELECT query_id,
client_ip, concat(user, db) as concat FROM test.test1;");
+ createTable("create table test.tbl_using_a\n" +
+ "(\n" +
+ " k1 int,\n" +
+ " k2 int,\n" +
+ " v1 int sum\n" +
+ ")\n" +
+ "DISTRIBUTED BY HASH(k1) BUCKETS 3 " +
+ "PROPERTIES (\n" +
+ "\"replication_num\" = \"1\"" +
+ ");");
+
+ createTable("create table test.tbl_using_b\n" +
+ "(\n" +
+ " k1 int,\n" +
+ " k2 int,\n" +
+ " k3 int \n" +
+ ")\n" +
+ "DISTRIBUTED BY HASH(k1) BUCKETS 3 " +
+ "PROPERTIES (\n" +
+ "\"replication_num\" = \"1\"" +
+ ");");
+
}
@AfterClass
@@ -1988,4 +2011,19 @@ public class QueryPlanTest {
Assert.assertTrue(explainStr.contains("errCode = 2"));
}
+ @Test
+ public void testQueryWithUsingClause() throws Exception {
+ connectContext.setDatabase("default_cluster:test");
+ String iSql1 = "insert into test.tbl_using_a
values(1,3,7),(2,2,8),(3,1,9)";
+ String iSql2 = "insert into test.tbl_using_b
values(1,3,1),(3,1,1),(4,1,1),(5,2,1)";
+ UtFrameUtils.getSqlStmtExecutor(connectContext, iSql1);
+ UtFrameUtils.getSqlStmtExecutor(connectContext, iSql2);
+ String qSQL = "select t1.* from test.tbl_using_a t1 join
test.tbl_using_b t2 using(k1,k2) where t1.k1 between 1 and 3 and t2.k3 between
1+0 and 3+0";
+ try {
+ UtFrameUtils.getSqlStmtExecutor(connectContext, qSQL);
+ } catch (AnalysisException e) {
+ Assert.fail();
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]