|
12 | 12 | import org.elasticsearch.xcontent.XContentBuilder; |
13 | 13 | import org.elasticsearch.xcontent.json.JsonXContent; |
14 | 14 | import org.elasticsearch.xpack.esql.LoadMapping; |
| 15 | +import org.elasticsearch.xpack.esql.action.EsqlCapabilities; |
15 | 16 | import org.elasticsearch.xpack.esql.core.expression.Expression; |
16 | 17 | import org.elasticsearch.xpack.esql.core.type.DataType; |
17 | 18 | import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; |
@@ -111,6 +112,46 @@ public void testTooBigQuery() { |
111 | 112 | assertEquals("-1:-1: ESQL statement is too large [1000011 characters > 1000000]", error(query.toString())); |
112 | 113 | } |
113 | 114 |
|
| 115 | + public void testJoinOnConstant() { |
| 116 | + assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled()); |
| 117 | + assertEquals( |
| 118 | + "1:55: JOIN ON clause only supports fields at the moment, found [123]", |
| 119 | + error("row languages = 1, gender = \"f\" | lookup join test on 123") |
| 120 | + ); |
| 121 | + assertEquals( |
| 122 | + "1:55: JOIN ON clause only supports fields at the moment, found [\"abc\"]", |
| 123 | + error("row languages = 1, gender = \"f\" | lookup join test on \"abc\"") |
| 124 | + ); |
| 125 | + assertEquals( |
| 126 | + "1:55: JOIN ON clause only supports fields at the moment, found [false]", |
| 127 | + error("row languages = 1, gender = \"f\" | lookup join test on false") |
| 128 | + ); |
| 129 | + } |
| 130 | + |
| 131 | + public void testJoinOnMultipleFields() { |
| 132 | + assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled()); |
| 133 | + assertEquals( |
| 134 | + "1:35: JOIN ON clause only supports one field at the moment, found [2]", |
| 135 | + error("row languages = 1, gender = \"f\" | lookup join test on gender, languages") |
| 136 | + ); |
| 137 | + } |
| 138 | + |
| 139 | + public void testJoinTwiceOnTheSameField() { |
| 140 | + assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled()); |
| 141 | + assertEquals( |
| 142 | + "1:35: JOIN ON clause only supports one field at the moment, found [2]", |
| 143 | + error("row languages = 1, gender = \"f\" | lookup join test on languages, languages") |
| 144 | + ); |
| 145 | + } |
| 146 | + |
| 147 | + public void testJoinTwiceOnTheSameField_TwoLookups() { |
| 148 | + assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled()); |
| 149 | + assertEquals( |
| 150 | + "1:80: JOIN ON clause only supports one field at the moment, found [2]", |
| 151 | + error("row languages = 1, gender = \"f\" | lookup join test on languages | eval x = 1 | lookup join test on gender, gender") |
| 152 | + ); |
| 153 | + } |
| 154 | + |
114 | 155 | private String functionName(EsqlFunctionRegistry registry, Expression functionCall) { |
115 | 156 | for (FunctionDefinition def : registry.listFunctions()) { |
116 | 157 | if (functionCall.getClass().equals(def.clazz())) { |
|
0 commit comments