Home

scalar variable support for matches regex

%3CLINGO-SUB%20id%3D%22lingo-sub-269592%22%20slang%3D%22en-US%22%3Escalar%20variable%20support%20for%20matches%20regex%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-269592%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20following%20example%20shows%20how%20the%20binary%20operator%20%3D%3D%20works%20with%20a%20scalar%20variable%20as%20the%20right%20hand%20side.%3C%2FP%3E%3CPRE%3Edatatable(a%3A%20string%2C%20b%3A%20string)%20%5B%20%0A%22foo%22%2C%20%22blah*%22%2C%0A%22bar%22%2C%20%22ba*%22%2C%0A%22same%22%2C%20%22same%22%0A%5D%20%7C%20where%20a%20%3D%3D%20b%3C%2FPRE%3E%3CP%3EThis%20works%20fine%20and%20returns%20the%20%22same%22%2C%20%22same%22%20row...%3C%2FP%3E%3CP%3EWhy%20doesn't%20the%20matches%20regex%20operator%20work%20the%20same%20way%3F%3C%2FP%3E%3CPRE%3Edatatable(a%3A%20string%2C%20b%3A%20string)%20%5B%20%0A%22foo%22%2C%20%22blah*%22%2C%0A%22bar%22%2C%20%22ba*%22%2C%0A%22same%22%2C%20%22same%22%0A%5D%20%7C%20where%20a%20matches%20regex%20b%3C%2FPRE%3E%3CP%3EI%20would%20have%20expected%20it%20to%20return%20the%20%22bar%22%2C%20%22ba*%22%20row.%3C%2FP%3E%3CP%3EInstead%20it%20says%3A%3C%2FP%3E%3CPRE%3ESYNTAX%20ERROR%0Amatches%20regex%3A%20failed%20to%20cast%20argument%202%20to%20scalar%20constant%0ASupport%20id%3A%20a11422a7-01b7-486b-84f1-e7473be0e164%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-269592%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271281%22%20slang%3D%22en-US%22%3ERe%3A%20scalar%20variable%20support%20for%20matches%20regex%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271281%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Patrick%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20argument%20to%20'matches%20regex'%20is%20a%20constant%20as%20the%20error%20message%20says.%20This%20is%20in%20order%20to%20ensure%20that%20the%20predicate%20is%20not%20calculated%20for%20each%20row%20something%20that%20will%20result%20in%20a%20very%20poor%20performance.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EAvner%3C%2FP%3E%3C%2FLINGO-BODY%3E
Patrick Naughton
Contributor

The following example shows how the binary operator == works with a scalar variable as the right hand side.

datatable(a: string, b: string) [ 
"foo", "blah*",
"bar", "ba*",
"same", "same"
] | where a == b

This works fine and returns the "same", "same" row...

Why doesn't the matches regex operator work the same way?

datatable(a: string, b: string) [ 
"foo", "blah*",
"bar", "ba*",
"same", "same"
] | where a matches regex b

I would have expected it to return the "bar", "ba*" row.

Instead it says:

SYNTAX ERROR
matches regex: failed to cast argument 2 to scalar constant
Support id: a11422a7-01b7-486b-84f1-e7473be0e164
1 Reply

Hi Patrick,

 

The argument to 'matches regex' is a constant as the error message says. This is in order to ensure that the predicate is not calculated for each row something that will result in a very poor performance. 

 

Thanks,

Avner

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies