@@ -1810,6 +1810,106 @@ public void testCombineOrderByThroughFilter() {
1810
1810
as (filter .child (), EsRelation .class );
1811
1811
}
1812
1812
1813
+ /**
1814
+ * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
1815
+ * uages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
1816
+ * \_Limit[1000[INTEGER],false]
1817
+ * \_Filter[ISNULL(language_name{f}#19)]
1818
+ * \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
1819
+ * |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
1820
+ * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
1821
+ */
1822
+ public void testDoNotPushDownIsNullFilterPastLookupJoin () {
1823
+ var plan = plan ("""
1824
+ FROM test
1825
+ | RENAME languages AS language_code
1826
+ | LOOKUP JOIN languages_lookup ON language_code
1827
+ | WHERE language_name IS NULL
1828
+ """ );
1829
+
1830
+ var project = as (plan , Project .class );
1831
+ var limit = as (project .child (), Limit .class );
1832
+ var filter = as (limit .child (), Filter .class );
1833
+ var join = as (filter .child (), Join .class );
1834
+ assertThat (join .right (), instanceOf (EsRelation .class ));
1835
+ }
1836
+
1837
+ /**
1838
+ * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
1839
+ * uages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
1840
+ * \_Limit[1000[INTEGER],false]
1841
+ * \_Filter[language_name{f}#19 > a[KEYWORD]]
1842
+ * \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
1843
+ * |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
1844
+ * \_Filter[language_name{f}#19 > a[KEYWORD]]
1845
+ * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
1846
+ */
1847
+ public void testPushDownGreaterThanFilterPastLookupJoin () {
1848
+ var plan = plan ("""
1849
+ FROM test
1850
+ | RENAME languages AS language_code
1851
+ | LOOKUP JOIN languages_lookup ON language_code
1852
+ | WHERE language_name > "a"
1853
+ """ );
1854
+
1855
+ var project = as (plan , Project .class );
1856
+ var limit = as (project .child (), Limit .class );
1857
+ var filter = as (limit .child (), Filter .class );
1858
+ var join = as (filter .child (), Join .class );
1859
+ var right = as (join .right (), Filter .class );
1860
+ assertThat (right .condition ().toString (), is ("language_name > \" a\" " ));
1861
+ }
1862
+
1863
+ /**
1864
+ * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
1865
+ * uages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
1866
+ * \_Limit[1000[INTEGER],false]
1867
+ * \_Filter[COALESCE(language_name{f}#19,a[KEYWORD]) == a[KEYWORD]]
1868
+ * \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
1869
+ * |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
1870
+ * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
1871
+ */
1872
+ public void testDoNotPushDownCoalesceFilterPastLookupJoin () {
1873
+ var plan = plan ("""
1874
+ FROM test
1875
+ | RENAME languages AS language_code
1876
+ | LOOKUP JOIN languages_lookup ON language_code
1877
+ | WHERE COALESCE(language_name, "a") == "a"
1878
+ """ );
1879
+
1880
+ var project = as (plan , Project .class );
1881
+ var limit = as (project .child (), Limit .class );
1882
+ var filter = as (limit .child (), Filter .class );
1883
+ var join = as (filter .child (), Join .class );
1884
+ assertThat (join .right (), instanceOf (EsRelation .class ));
1885
+ }
1886
+
1887
+ /**
1888
+ * Project[[_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, gender{f}#9, hire_date{f}#14, job{f}#15, job.raw{f}#16, lang
1889
+ * uages{f}#10 AS language_code#4, last_name{f}#11, long_noidx{f}#17, salary{f}#12, language_name{f}#19]]
1890
+ * \_Limit[1000[INTEGER],false]
1891
+ * \_Filter[ISNOTNULL(language_name{f}#19)]
1892
+ * \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
1893
+ * |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
1894
+ * \_Filter[ISNOTNULL(language_name{f}#19)]
1895
+ * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
1896
+ */
1897
+ public void testPushDownIsNotNullFilterPastLookupJoin () {
1898
+ var plan = plan ("""
1899
+ FROM test
1900
+ | RENAME languages AS language_code
1901
+ | LOOKUP JOIN languages_lookup ON language_code
1902
+ | WHERE language_name IS NOT NULL
1903
+ """ );
1904
+
1905
+ var project = as (plan , Project .class );
1906
+ var limit = as (project .child (), Limit .class );
1907
+ var filter = as (limit .child (), Filter .class );
1908
+ var join = as (filter .child (), Join .class );
1909
+ var right = as (join .right (), Filter .class );
1910
+ assertThat (right .condition ().toString (), is ("language_name IS NOT NULL" ));
1911
+ }
1912
+
1813
1913
/**
1814
1914
* Expected
1815
1915
* <pre>{@code
@@ -6973,7 +7073,8 @@ public void testLookupJoinPushDownFilterOnLeftSideField() {
6973
7073
* \_Filter[language_name{f}#19 == [45 6e 67 6c 69 73 68][KEYWORD]]
6974
7074
* \_Join[LEFT,[languages{f}#10],[languages{f}#10],[language_code{f}#18]]
6975
7075
* |_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
6976
- * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
7076
+ * \_Filter[language_name{f}#19 == English[KEYWORD]]
7077
+ * \_EsRelation[languages_lookup][LOOKUP][language_code{f}#18, language_name{f}#19]
6977
7078
* }</pre>
6978
7079
*/
6979
7080
public void testLookupJoinPushDownDisabledForLookupField () {
@@ -7002,7 +7103,10 @@ public void testLookupJoinPushDownDisabledForLookupField() {
7002
7103
assertThat (join .config ().type (), equalTo (JoinTypes .LEFT ));
7003
7104
7004
7105
var leftRel = as (join .left (), EsRelation .class );
7005
- var rightRel = as (join .right (), EsRelation .class );
7106
+ var filterRight = as (join .right (), Filter .class );
7107
+ assertEquals ("language_name == \" English\" " , filterRight .condition ().toString ());
7108
+ var joinRightEsRelation = as (filterRight .child (), EsRelation .class );
7109
+
7006
7110
}
7007
7111
7008
7112
/**
0 commit comments