@@ -0,0 +1,3231 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.prestosql.sql.query;%0A%0Aimport org.testng.annotations.AfterClass;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0Apublic class TestPredicatePushdown%0A%7B%0A    private QueryAssertions assertions;%0A%0A    @BeforeClass%0A    public void init()%0A    %7B%0A        assertions = new QueryAssertions();%0A    %7D%0A%0A    @AfterClass(alwaysRun = true)%0A    public void teardown()%0A    %7B%0A        assertions.close();%0A        assertions = null;%0A    %7D%0A%0A    @Test%0A    public void testConditionalExpressionWithFailingExpression()%0A    %7B%0A        assertions.assertQuery(%22%22 +%0A                        %22WITH t (k, a) AS ( %22 +%0A                        %22    VALUES %22 +%0A                        %22        (1, 1), %22 +%0A                        %22        (2, 0) %22 +%0A                        %22),%22 +%0A                        %22u (k, v) AS ( %22 +%0A                        %22    VALUES%22 +%0A                        %22        (1, 'x'), %22 +%0A                        %22        (2, 'y') %22 +%0A                        %22) %22 +%0A                        %22SELECT * %22 +%0A                        %22FROM ( %22 +%0A                        %22    SELECT v, if(v = 'x', 1 / a) AS r%22 +%0A                        %22    FROM t JOIN u ON t.k = u.k %22 +%0A                        %22) %22 +%0A                        %22WHERE v = 'x' AND r IS NOT NULL%22,%0A                %22VALUES ('x', 1)%22);%0A%0A        assertions.assertQuery(%0A                %22WITH t (k, v) AS ( %22 +%0A                        %22    VALUES %22 +%0A                        %22        (1, 1), %22 +%0A                        %22        (2, 0) %22 +%0A                        %22), %22 +%0A                        %22u (k) AS ( %22 +%0A                        %22    VALUES 1, 2 %22 +%0A                        %22) %22 +%0A                        %22SELECT * %22 +%0A                        %22FROM ( %22 +%0A                        %22    SELECT t.k, if(t.k = 1, 1 / t.v) AS r %22 +%0A                        %22    FROM t JOIN u ON t.k = u.k %22 +%0A                        %22) %22 +%0A                        %22WHERE k = 1 AND r %3C%3E 0%22,%0A                %22VALUES (1, 1)%22);%0A%0A        assertions.assertQuery(%0A                %22WITH t (k, v) AS ( %22 +%0A                        %22    VALUES %22 +%0A                        %22        (1, 1), %22 +%0A                        %22        (2, 0) %22 +%0A                        %22), %22 +%0A                        %22u (k) AS ( %22 +%0A                        %22    VALUES 1, 2 %22 +%0A                        %22) %22 +%0A                        %22SELECT * %22 +%0A                        %22FROM ( %22 +%0A                        %22    SELECT t.k, if(t.k = 1, 1 / t.v) AS r %22 +%0A                        %22    FROM t LEFT JOIN u ON t.k = u.k %22 +%0A                        %22) %22 +%0A                        %22WHERE k = 1 AND r %3C%3E 0%22,%0A                %22VALUES (1, 1)%22);%0A    %7D%0A%7D%0A

Add tests for pedicate pushdown