@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user