@@ -1239,22 +1239,31 @@ public void testMatchFunctionAndOperatorHaveCorrectErrorMessages() throws Except
12391239 assertEquals ("1:24: [:] operator cannot be used after LIMIT" , error ("from test | limit 10 | where first_name : \" Anna\" " ));
12401240 }
12411241
1242+ public void testFieldBasedFullTextFunctions () {
1243+ testFieldBasedWithNonIndexedColumn ("MATCH" , " match(text, \" cat\" )" , "function" );
1244+ testFieldBasedWithNonIndexedColumn (":" , " text : \" cat\" " , "operator" );
1245+ testFieldBasedWithNonIndexedColumn ("MultiMatch" , " multi_match(\" cat\" , text)" , "function" );
1246+ }
1247+
12421248 // These should pass eventually once we lift some restrictions on match function
1243- public void testMatchWithNonIndexedColumnCurrentlyUnsupported ( ) {
1244- assertEquals (
1245- "1:67: [MATCH] function cannot operate on [initial], which is not a field from an index mapping" ,
1246- error ( "from test | eval initial = substring(first_name, 1) | where match(initial, \" A \" ) " )
1249+ public void testFieldBasedWithNonIndexedColumn ( String functionName , String functionInvocation , String functionType ) {
1250+ assertThat (
1251+ error ( "from test | eval text = substring(first_name, 1) | where" + functionInvocation ) ,
1252+ containsString ( "[" + functionName + "] " + functionType + " cannot operate on [text], which is not a field from an index mapping " )
12471253 );
1248- assertEquals (
1249- "1:67: [MATCH] function cannot operate on [ text], which is not a field from an index mapping" ,
1250- error ( "from test | eval text=concat(first_name, last_name) | where match( text, \" cat \" ) " )
1254+ assertThat (
1255+ error ( "from test | eval text=concat(first_name, last_name) | where" + functionInvocation ) ,
1256+ containsString ( "[" + functionName + "] " + functionType + " cannot operate on [ text], which is not a field from an index mapping " )
12511257 );
1252- }
1253-
1254- public void testMatchFunctionIsNotNullable () {
1255- assertEquals (
1256- "1:48: [MATCH] function cannot operate on [text::keyword], which is not a field from an index mapping" ,
1257- error ("row n = null | eval text = n + 5 | where match(text::keyword, \" Anna\" )" )
1258+ var keywordInvocation = functionInvocation .replace ("text" , "text::keyword" );
1259+ String keywordError = error ("row n = null | eval text = n + 5 | where " + keywordInvocation );
1260+ assertThat (
1261+ keywordError ,
1262+ containsString ("[" + functionName + "] " + functionType + " cannot operate on" )
1263+ );
1264+ assertThat (
1265+ keywordError ,
1266+ containsString ("which is not a field from an index mapping" )
12581267 );
12591268 }
12601269
0 commit comments