9595import org .apache .calcite .rel .rules .SortUnionTransposeRule ;
9696import org .apache .calcite .rel .rules .SpatialRules ;
9797import org .apache .calcite .rel .rules .SubQueryRemoveRule ;
98- import org .apache .calcite .rel .rules .ValuesReduceRule ;
9998import org .apache .calcite .rel .type .RelDataType ;
10099import org .apache .calcite .rel .type .RelDataTypeFactory ;
101100import org .apache .calcite .rel .type .RelDataTypeSystemImpl ;
@@ -1730,12 +1729,6 @@ private void checkReduceNullableToNotNull(ReduceExpressionsRule<?> rule) {
17301729 .check ();
17311730 }
17321731
1733- /** Test case that reduces a nullable expression to a NOT NULL literal that
1734- * is cast to nullable. */
1735- @ Test void testReduceNullableToNotNull () {
1736- checkReduceNullableToNotNull (CoreRules .PROJECT_REDUCE_EXPRESSIONS );
1737- }
1738-
17391732 /** Test case that reduces a nullable expression to a NOT NULL literal. */
17401733 @ Test void testReduceNullableToNotNull2 () {
17411734 final ProjectReduceExpressionsRule rule =
@@ -1813,161 +1806,6 @@ RelOptFixture checkDynamicFunctions(boolean treatDynamicCallsAsConstant) {
18131806 .checkUnchanged ();
18141807 }
18151808
1816- @ Test void testCasePushIsAlwaysWorking () {
1817- final String sql = "select empno from emp"
1818- + " where case when sal > 1000 then empno else sal end = 1" ;
1819- sql (sql )
1820- .withRule (CoreRules .FILTER_REDUCE_EXPRESSIONS ,
1821- CoreRules .CALC_REDUCE_EXPRESSIONS ,
1822- CoreRules .PROJECT_REDUCE_EXPRESSIONS )
1823- .check ();
1824- }
1825-
1826-
1827- @ Test void testReduceValuesToEmpty () {
1828- // Plan should be same as for
1829- // select * from (values (11, 1, 10), (23, 3, 20)) as t(x, b, a)");
1830- final String sql = "select a + b as x, b, a from (values (10, 1), (30, 7)) as t(a, b)\n "
1831- + "where a - b < 0" ;
1832- sql (sql )
1833- .withRule (CoreRules .FILTER_PROJECT_TRANSPOSE ,
1834- CoreRules .PROJECT_MERGE ,
1835- CoreRules .PROJECT_FILTER_VALUES_MERGE )
1836- .check ();
1837- }
1838-
1839- @ Test void testReduceConstantsWindow () {
1840- final String sql = "select col1, col2, col3\n "
1841- + "from (\n "
1842- + " select empno,\n "
1843- + " sum(100) over (partition by deptno, sal order by sal) as col1,\n "
1844- + " sum(100) over (partition by sal order by deptno) as col2,\n "
1845- + " sum(sal) over (partition by deptno order by sal) as col3\n "
1846- + " from emp where sal = 5000)" ;
1847-
1848- sql (sql )
1849- .withRule (CoreRules .PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW ,
1850- CoreRules .PROJECT_MERGE ,
1851- CoreRules .PROJECT_WINDOW_TRANSPOSE ,
1852- CoreRules .WINDOW_REDUCE_EXPRESSIONS )
1853- .check ();
1854- }
1855-
1856- @ Test void testReduceConstantsWithMultipleOrderByWindow () {
1857- final String sql = "select col1, col2\n "
1858- + "from (\n "
1859- + " select empno,\n "
1860- + " sum(100) over (order by deptno, empno range between current row and unbounded following) as col1,\n "
1861- + " sum(100) over (partition by sal, deptno order by deptno, empno range between unbounded preceding and unbounded following) as col2\n "
1862- + " from emp where sal = 5000)" ;
1863-
1864- sql (sql )
1865- .withRule (CoreRules .PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW ,
1866- CoreRules .PROJECT_MERGE ,
1867- CoreRules .PROJECT_WINDOW_TRANSPOSE ,
1868- CoreRules .WINDOW_REDUCE_EXPRESSIONS )
1869- .check ();
1870- }
1871-
1872- @ Test void testProjectOverWithAvg () {
1873- final String sql = "select avg(sal) over (order by empno rows 3 preceding) from emp" ;
1874-
1875- sql (sql )
1876- .withRule (CoreRules .PROJECT_OVER_SUM_TO_SUM0_RULE ,
1877- CoreRules .PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW ,
1878- CoreRules .PROJECT_MERGE ,
1879- CoreRules .PROJECT_WINDOW_TRANSPOSE ,
1880- CoreRules .WINDOW_REDUCE_EXPRESSIONS )
1881- .check ();
1882- }
1883-
1884- /** Test case for
1885- * <a href="https://issues.apache.org/jira/browse/CALCITE-1488">[CALCITE-1488]
1886- * ValuesReduceRule should ignore empty Values</a>. */
1887- @ Test void testEmptyProject () {
1888- final String sql = "select z + x from (\n "
1889- + " select x + y as z, x from (\n "
1890- + " select * from (values (10, 1), (30, 3)) as t (x, y)\n "
1891- + " where x + y > 50))" ;
1892- sql (sql )
1893- .withRule (CoreRules .PROJECT_FILTER_VALUES_MERGE ,
1894- CoreRules .FILTER_VALUES_MERGE ,
1895- CoreRules .PROJECT_VALUES_MERGE )
1896- .check ();
1897- }
1898-
1899- /** Same query as {@link #testEmptyProject()}, and {@link PruneEmptyRules}
1900- * is able to do the job that {@link ValuesReduceRule} cannot do. */
1901- @ Test void testEmptyProject2 () {
1902- final String sql = "select z + x from (\n "
1903- + " select x + y as z, x from (\n "
1904- + " select * from (values (10, 1), (30, 3)) as t (x, y)\n "
1905- + " where x + y > 50))" ;
1906- sql (sql )
1907- .withRule (CoreRules .FILTER_VALUES_MERGE ,
1908- PruneEmptyRules .PROJECT_INSTANCE )
1909- .check ();
1910- }
1911-
1912- @ Test void testEmptyIntersect () {
1913- final String sql = "select * from (values (30, 3))"
1914- + "intersect\n "
1915- + "select *\n from (values (10, 1), (30, 3)) as t (x, y) where x > 50\n "
1916- + "intersect\n "
1917- + "select * from (values (30, 3))" ;
1918- sql (sql )
1919- .withRule (CoreRules .PROJECT_FILTER_VALUES_MERGE ,
1920- PruneEmptyRules .PROJECT_INSTANCE ,
1921- PruneEmptyRules .INTERSECT_INSTANCE )
1922- .check ();
1923- }
1924-
1925- @ Test void testEmptyMinus () {
1926- // First input is empty; therefore whole expression is empty
1927- final String sql = "select * from (values (30, 3)) as t (x, y)\n "
1928- + "where x > 30\n "
1929- + "except\n "
1930- + "select * from (values (20, 2))\n "
1931- + "except\n "
1932- + "select * from (values (40, 4))" ;
1933- sql (sql )
1934- .withRule (CoreRules .PROJECT_FILTER_VALUES_MERGE ,
1935- PruneEmptyRules .PROJECT_INSTANCE ,
1936- PruneEmptyRules .MINUS_INSTANCE )
1937- .check ();
1938- }
1939-
1940- @ Test void testEmptyMinus2 () {
1941- // Second and fourth inputs are empty; they are removed
1942- final String sql = "select * from (values (30, 3)) as t (x, y)\n "
1943- + "except\n "
1944- + "select * from (values (20, 2)) as t (x, y) where x > 30\n "
1945- + "except\n "
1946- + "select * from (values (40, 4))\n "
1947- + "except\n "
1948- + "select * from (values (50, 5)) as t (x, y) where x > 50" ;
1949- sql (sql )
1950- .withRule (CoreRules .PROJECT_FILTER_VALUES_MERGE ,
1951- PruneEmptyRules .PROJECT_INSTANCE ,
1952- PruneEmptyRules .MINUS_INSTANCE )
1953- .check ();
1954- }
1955-
1956- /** Test case for
1957- * <a href="https://issues.apache.org/jira/browse/CALCITE-6955">[CALCITE-6955]
1958- * PruneEmptyRules does not handle the all attribute of SetOp correctly</a>. */
1959- @ Test void testEmptyMinus3 () {
1960- // First input is empty; therefore whole expression is empty
1961- final String sql = "select * from (values (30, 3), (30, 3)) as t (x, y)\n "
1962- + "except\n "
1963- + "select * from (values (20, 2)) as t (x, y) where x > 30" ;
1964- sql (sql )
1965- .withRule (CoreRules .PROJECT_FILTER_VALUES_MERGE ,
1966- PruneEmptyRules .PROJECT_INSTANCE ,
1967- PruneEmptyRules .MINUS_INSTANCE )
1968- .check ();
1969- }
1970-
19711809 @ Test void testEmptyTable () {
19721810 // table is transformed to empty values and extra project will be removed.
19731811 final String sql = "select * from EMPTY_PRODUCTS\n " ;
@@ -2389,15 +2227,6 @@ private void checkEmptyJoin(RelOptFixture f) {
23892227 PruneEmptyRules .JOIN_RIGHT_INSTANCE ).check ();
23902228 }
23912229
2392- @ Test void testEmptySort () {
2393- final String sql = "select * from emp where false order by deptno" ;
2394- sql (sql )
2395- .withRule (CoreRules .FILTER_REDUCE_EXPRESSIONS ,
2396- PruneEmptyRules .PROJECT_INSTANCE ,
2397- PruneEmptyRules .SORT_INSTANCE )
2398- .check ();
2399- }
2400-
24012230 @ Test void testEmptySort2 () {
24022231 final Function <RelBuilder , RelNode > relFn = b -> b
24032232 .scan ("DEPT" ).empty ()
@@ -2408,33 +2237,6 @@ private void checkEmptyJoin(RelOptFixture f) {
24082237 relFn (relFn ).withRule (PruneEmptyRules .SORT_INSTANCE ).check ();
24092238 }
24102239
2411- @ Test void testEmptySortLimitZero () {
2412- final String sql = "select * from emp order by deptno limit 0" ;
2413- sql (sql ).withRule (PruneEmptyRules .SORT_FETCH_ZERO_INSTANCE ).check ();
2414- }
2415-
2416- @ Test void testEmptyAggregate () {
2417- final String sql = "select sum(empno) from emp where false group by deptno" ;
2418- sql (sql )
2419- .withPreRule (CoreRules .FILTER_REDUCE_EXPRESSIONS ,
2420- PruneEmptyRules .PROJECT_INSTANCE )
2421- .withRule (CoreRules .FILTER_REDUCE_EXPRESSIONS ,
2422- PruneEmptyRules .PROJECT_INSTANCE ,
2423- PruneEmptyRules .AGGREGATE_INSTANCE ,
2424- PruneEmptyRules .PROJECT_INSTANCE )
2425- .check ();
2426- }
2427-
2428- @ Test void testEmptyAggregateEmptyKey () {
2429- final String sql = "select sum(empno) from emp where false" ;
2430- sql (sql )
2431- .withPreRule (CoreRules .FILTER_REDUCE_EXPRESSIONS ,
2432- PruneEmptyRules .PROJECT_INSTANCE )
2433- .withRule (PruneEmptyRules .AGGREGATE_INSTANCE )
2434- .checkUnchanged ();
2435- }
2436-
2437-
24382240 /** Test case for
24392241 * <a href="https://issues.apache.org/jira/browse/CALCITE-5117">[CALCITE-5117]
24402242 * Optimize the EXISTS sub-query by Metadata RowCount</a>. */
0 commit comments