morningman commented on a change in pull request #3150: Support non-correlated subquery in having clause URL: https://github.com/apache/incubator-doris/pull/3150#discussion_r396201257
########## File path: fe/src/test/java/org/apache/doris/analysis/StmtRewriterTest.java ########## @@ -0,0 +1,63 @@ +// 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. + +package org.apache.doris.analysis; + +import org.apache.doris.common.FeConstants; +import org.apache.doris.utframe.DorisAssert; +import org.apache.doris.utframe.UtFrameUtils; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.UUID; + +public class StmtRewriterTest { + + private static String baseDir = "fe"; + private static String runningDir = baseDir + "/mocked/StmtRewriterTest/" + + UUID.randomUUID().toString() + "/"; + private static final String TABLE_NAME = "table1"; + private static final String DB_NAME = "db1"; + private static DorisAssert dorisAssert; + + @BeforeClass + public static void beforeClass() throws Exception{ + FeConstants.runningUnitTest = true; + UtFrameUtils.createMinDorisCluster(runningDir); + dorisAssert = new DorisAssert(); + dorisAssert.withDatabase(DB_NAME).useDatabase(DB_NAME); + String createTableSQL = "create table " + DB_NAME + "." + TABLE_NAME + " (empid int, name varchar, " + + "deptno int, salary int, commission int) " + + "distributed by hash(empid) buckets 3 properties('replication_num' = '1');"; + dorisAssert.withTable(createTableSQL); + } + + @Test + public void testRewriteHavingClauseSubqueries() throws Exception { Review comment: Add this case to the queryPlanTest to reduce the running time of FE ut. And how about adding more tests to cover this case? such as query with limit ? And could you add the final rewritten stmt in comment: ``` select empid, x from (select empid, sum(salary) x from tbl group by empid) v where v.x > (select avg(salary) from tbl); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
