MAPCONTAINSVALUE
Determines whether a VMap contains a specific value. Use this scalar function to return true (t
), if the value exists, or false (f
), if it does not.
Syntax
MAPCONTAINSVALUE(VMap_data, 'virtual_column_value')
Arguments
VMap_data |
Any VMap data. The VMap can exist as:
|
virtual_column_value |
The value whose existence you want to confirm. |
Examples
This example shows how to use mapcontainsvalue()
to determine whether or not a virtual column contains a particular value. Create a flex table (ftest
), and populate it with some virtual columns and values. Name both virtual columns one
:
=> CREATE FLEX TABLE ftest(); CREATE TABLE => copy ftest from stdin parser fjsonparser(); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself. >> {"one":1, "two":2} >> {"one":"one","2":"2"} >> \.
Call mapcontainsvalue()
on the ftest
map data. The query returns false (f
) for the first virtual column, and true (t
) for the second , which contains the value one
:
=> SELECT MAPCONTAINSVALUE(__raw__, 'one') FROM ftest; mapcontainsvalue ------------------ f t (2 rows)