<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Flex map functions</title>
    <link>/en/sql-reference/functions/flex-functions/flex-map-functions/</link>
    <description>Recent content in Flex map functions on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/functions/flex-functions/flex-map-functions/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: EMPTYMAP</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/</guid>
      <description>
        
        
        &lt;p&gt;Constructs a new VMap with one row but without keys or data. Use this transform function to populate a map without using a flex parser. Instead, you use either from SQL queries or from map data present elsewhere in the database.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;EMPTYMAP()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Create an Empty Map&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT EMPTYMAP();
                             emptymap
------------------------------------------------------------------
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Create an Empty Map from an Existing Flex Table&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you create an empty map from an existing flex table, the new map has the same number of rows as the table from which it was created.&lt;/p&gt;
&lt;p&gt;This example shows the result if you create an empty map from the &lt;code&gt;darkdata&lt;/code&gt; table, which has 12 rows of JSON data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT EMPTYMAP() FROM darkdata;
                             emptymap
------------------------------------------------------------------
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
 \001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000
(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPAGGREGATE</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/</guid>
      <description>
        
        
        &lt;p&gt;Returns a LONG VARBINARY VMap with key and value pairs supplied from two VARCHAR input columns. This function requires an OVER clause.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPAGGREGATE (&lt;span class=&#34;code-variable&#34;&gt;keys-column1&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;values-column2&lt;/span&gt; [USING PARAMETERS &lt;span class=&#34;code-variable&#34;&gt;param&lt;/span&gt;=&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt;[,...]])
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;keys-column&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Table column with the keys for the key/value pairs of the returned &lt;code&gt;VMap&lt;/code&gt; data. Keys with a NULL value are excluded. If there are duplicate keys, the duplicate key and value that appear first in the query result are used, while the other duplicates are omitted.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;values-column&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Table column with the values for the key/value pairs of the returned &lt;code&gt;VMap&lt;/code&gt; data.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;max_vmap_length&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Maximum length in bytes for the VMap result, an integer between 1-32000000 inclusive.&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; 130000&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;on_overflow&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Overflow behavior for cases when the VMap result is larger than the &lt;code&gt;max_vmap_length&lt;/code&gt;. The value must be one of the following strings:
&lt;ul&gt;
&lt;li&gt;&#39;ERROR&#39;: Returns an error when overflow occurs.&lt;/li&gt;
&lt;li&gt;&#39;TRUNCATE&#39;: Stops aggregating key/value pairs if the result exceeds &lt;code&gt;max_vmap_length&lt;/code&gt;. The query executes, but the resulting VMap does not have all key/value pairs. When the provided &lt;code&gt;max_vmap_length&lt;/code&gt; is not large enough to store an empty VMap, the result returned is NULL. Note that you need to specify order criteria in the OVER clause to get consistent results.&lt;/li&gt;
&lt;li&gt;&#39;RETURN_NULL&#39;: Return NULL if overflow occurs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; &#39;ERROR&#39;&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following examples use this input table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM inventory;
  product     | stock
--------------+--------
  Planes      | 100
  Trains      | 50
  Automobiles | 200
(3 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Call MAPAGGREGATE as follows to return the &lt;code&gt;raw_map&lt;/code&gt; data of the resulting VMap:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT raw_map FROM (SELECT MAPAGGREGATE(product, stock) OVER(ORDER BY product) FROM inventory) inventory;
raw_map
------------------------------------------------------------------------------------------------------------
\001\000\000\000\030\000\000\000\003\000\000\000\020\000\000\000\023\000\000\000\026\000\000\00020010050\003
\000\000\000\020\000\000\000\033\000\000\000!\000\000\000AutomobilesPlanesTrains
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To transform the returned &lt;code&gt;raw_map&lt;/code&gt; data into string representation, use MAPAGGREGATE with &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT MAPTOSTRING(raw_map) FROM (SELECT MAPAGGREGATE(product, stock) OVER(ORDER BY product) FROM
inventory) inventory;
MAPTOSTRING
--------------------------------------------------------------
{
  &amp;#34;Automobiles&amp;#34;: &amp;#34;200&amp;#34;,
  &amp;#34;Planes&amp;#34;: &amp;#34;100&amp;#34;,
  &amp;#34;Trains&amp;#34;: &amp;#34;50&amp;#34;
}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you run the above query with &lt;code&gt;on_overflow&lt;/code&gt; left as default and a &lt;code&gt;max_vmap_length&lt;/code&gt; less than the returned VMap size, the function returns with an error message indicating the need to increase VMap length:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT MAPTOSTRING(raw_map) FROM (SELECT MAPAGGREGATE(product, stock USING PARAMETERS max_vmap_length=60)
OVER(ORDER BY product) FROM inventory) inventory;
----------------------------------------------------------------------------------------------------------
ERROR 5861:  Error calling processPartition() in User Function MapAggregate at [/data/jenkins/workspace
/RE-PrimaryBuilds/RE-Build-Master_2/server/udx/supported/flextable/Dict.cpp:1324], error code: 0, message:
Exception while finalizing map aggregation: Output VMap length is too small [60]. HINT: Set the parameter
max_vmap_length=71 and retry your query
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Switching the value of &lt;code&gt;on_overflow&lt;/code&gt; allows you to alter how MAPAGGREGATE behaves in the case of overflow. For example, changing &lt;code&gt;on_overflow&lt;/code&gt; to &#39;RETURN_NULL&#39; causes the above query to execute and return NULL:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
SELECT raw_map IS NULL FROM (SELECT MAPAGGREGATE(product, stock USING PARAMETERS max_vmap_length=60,
on_overflow=&amp;#39;RETURN_NULL&amp;#39;) OVER(ORDER BY product) FROM inventory) inventory;
?column?
----------
t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If &lt;code&gt;on_overflow&lt;/code&gt; is set to &#39;TRUNCATE&#39;, the resulting VMap has enough space for two of the key/value pairs, but must cut the third:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
SELECT raw_map IS NULL FROM (SELECT MAPAGGREGATE(product, stock USING PARAMETERS max_vmap_length=60,
on_overflow=&amp;#39;TRUNCATE&amp;#39;) OVER(ORDER BY product) FROM inventory) inventory;
MAPTOSTRING
---------------------------------------------
{
  &amp;#34;Automobiles&amp;#34;: &amp;#34;200&amp;#34;,
  &amp;#34;Planes&amp;#34;: &amp;#34;100&amp;#34;
}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPCONTAINSKEY</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/</guid>
      <description>
        
        
        &lt;p&gt;Determines whether a VMap contains a virtual column (key). This scalar function returns true (&lt;code&gt;t&lt;/code&gt;), if the virtual column exists, or false (&lt;code&gt;f&lt;/code&gt;) if it does not. Determining that a key exists before calling &lt;code&gt;maplookup()&lt;/code&gt; lets you distinguish between NULL returns. The &lt;code&gt;maplookup()&lt;/code&gt; function uses for both a non-existent key and an existing key with a NULL value.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPCONTAINSKEY (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;virtual-column-name&lt;/span&gt;&amp;#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;virtual-column-name&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Name of the key to check.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example shows how to use the &lt;code&gt;mapcontainskey()&lt;/code&gt; functions with &lt;code&gt;maplookup()&lt;/code&gt;. View the results returned from both functions. Check whether the empty fields that &lt;code&gt;maplookup()&lt;/code&gt; returns indicate a &lt;code&gt;NULL&lt;/code&gt; value for the row (&lt;strong&gt;&lt;code&gt;t&lt;/code&gt;&lt;/strong&gt;) or no value (&lt;code&gt;f&lt;/code&gt;):&lt;/p&gt;
&lt;p&gt;You can use mapcontainskey( ) to determine that a key exists before calling maplookup(). The maplookup() function uses both NULL returns and existing keys with NULL values to indicate a non-existent key.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;user.location&amp;#39;), MAPCONTAINSKEY(__raw__, &amp;#39;user.location&amp;#39;)
FROM darkdata ORDER BY 1;
 maplookup | mapcontainskey
-----------+----------------
           | t
           | t
           | t
           | t
 Chile     | t
 Narnia    | t
 Uptown..  | t
 chicago   | t
           | &lt;span class=&#34;code-input&#34;&gt;f&lt;/span&gt;
           | &lt;span class=&#34;code-input&#34;&gt;f&lt;/span&gt;
           | &lt;span class=&#34;code-input&#34;&gt;f&lt;/span&gt;
           | &lt;span class=&#34;code-input&#34;&gt;f&lt;/span&gt;

(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPCONTAINSVALUE</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/</guid>
      <description>
        
        
        &lt;p&gt;Determines whether a VMap contains a specific value. Use this scalar function to return true (&lt;code&gt;t&lt;/code&gt;) if the value exists, or false (&lt;code&gt;f&lt;/code&gt;) if it does not.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPCONTAINSVALUE (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;virtual-column-value&lt;/span&gt;&amp;#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;virtual-column-value&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Value to confirm.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example shows how to use &lt;code&gt;mapcontainsvalue()&lt;/code&gt; to determine whether or not a virtual column contains a particular value. Create a flex table (&lt;code&gt;ftest&lt;/code&gt;), and populate it with some virtual columns and values. Name both virtual columns &lt;code&gt;one&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE FLEX TABLE ftest();
CREATE TABLE
=&amp;gt; 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.
&amp;gt;&amp;gt; {&amp;#34;one&amp;#34;:1, &amp;#34;two&amp;#34;:2}
&amp;gt;&amp;gt; {&amp;#34;one&amp;#34;:&amp;#34;one&amp;#34;,&amp;#34;2&amp;#34;:&amp;#34;2&amp;#34;}
&amp;gt;&amp;gt; \.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Call &lt;code&gt;mapcontainsvalue()&lt;/code&gt; on the &lt;code&gt;ftest&lt;/code&gt; map data. The query returns false (&lt;code&gt;f&lt;/code&gt;) for the first virtual column, and true (&lt;code&gt;t&lt;/code&gt;) for the second , which contains the value &lt;code&gt;one&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT MAPCONTAINSVALUE(__raw__, &amp;#39;one&amp;#39;) FROM ftest;
mapcontainsvalue
------------------
f
t
(2 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPITEMS</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/</guid>
      <description>
        
        
        &lt;p&gt;Returns information about items in a VMap. Use this transform function with one or more optional arguments to access polystructured values within the VMap data. This function requires an over()` clause.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPITEMS (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt; [, &lt;span class=&#34;code-variable&#34;&gt;passthrough-arg&lt;/span&gt;[,...] ])
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;In a &lt;code&gt;__raw__&lt;/code&gt; column, determines the maximum length of keys that the function can return. Keys that are longer than &lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt; cause the query to fail. Defaults to the smaller of VMap column length and 65K.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;max_value_length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;In a &lt;code&gt;__raw__&lt;/code&gt; column, determines the maximum length of values the function can return. Values that are larger than &lt;em&gt;&lt;code&gt;max_value_length&lt;/code&gt;&lt;/em&gt; cause the query to fail. Defaults to the smaller of VMap column length and 65K.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;passthrough-arg&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;One or more arguments indicating keys within the map data in &lt;code&gt;VMap-data&lt;/code&gt;.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following examples illustrate using &lt;code&gt;MAPITEMS()&lt;/code&gt;with the &lt;code&gt;over(PARTITION BEST)&lt;/code&gt; clause.&lt;/p&gt;
&lt;p&gt;This example determines the number of virtual columns in the map data using a flex table, labeled &lt;code&gt;darkmountain&lt;/code&gt;. Query using the &lt;code&gt;count()&lt;/code&gt; function to return the number of virtual columns in the map data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT COUNT(keys) FROM (SELECT MAPITEMS(darkmountain.__raw__) OVER(PARTITION BEST) FROM
 darkmountain) AS a;
 count
-------
    19
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The next example determines what items exist in the map data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM (SELECT MAPITEMS(darkmountain.__raw__) OVER(PARTITION BEST) FROM darkmountain) AS a;
    keys     |    values
-------------+---------------
 hike_safety | 50.6
 name        | Mt Washington
 type        | mountain
 height      | 17000
 hike_safety | 12.2
 name        | Denali
 type        | mountain
 height      | 29029
 hike_safety | 34.1
 name        | Everest
 type        | mountain
 height      | 14000
 hike_safety | 22.8
 name        | Kilimanjaro
 type        | mountain
 height      | 29029
 hike_safety | 15.4
 name        | Mt St Helens
 type        | volcano
(19 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example shows how to restrict the length of returned values to 100000:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT LENGTH(keys), LENGTH(values) FROM (SELECT MAPITEMS(__raw__ USING PARAMETERS max_value_length=100000) OVER() FROM t1) x;
 LENGTH | LENGTH
--------+--------
      9 | 98899
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Directly Query a Key Value in a VMap&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Review the following JSON input file, &lt;code&gt;simple.json&lt;/code&gt;. In particular, notice the array called &lt;code&gt;three_Array&lt;/code&gt;, and its four values:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{
  &amp;#34;one&amp;#34;: &amp;#34;one&amp;#34;,
  &amp;#34;two&amp;#34;: 2,
  &amp;#34;three_Array&amp;#34;:
  [
    &amp;#34;three_One&amp;#34;,
    &amp;#34;three_Two&amp;#34;,
    3,
    &amp;#34;three_Four&amp;#34;
  ],
  &amp;#34;four&amp;#34;: 4,
  &amp;#34;five_Map&amp;#34;:
  {
    &amp;#34;five_One&amp;#34;: 51,
    &amp;#34;five_Two&amp;#34;: &amp;#34;Fifty-two&amp;#34;,
    &amp;#34;five_Three&amp;#34;: &amp;#34;fifty three&amp;#34;,
    &amp;#34;five_Four&amp;#34;: 54,
    &amp;#34;five_Five&amp;#34;: &amp;#34;5 x 5&amp;#34;
  },
  &amp;#34;six&amp;#34;: 6
}
&lt;/code&gt;&lt;/pre&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a flex table, mapper:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE FLEX TABLE mapper();
CREATE TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Load &lt;code&gt;simple.json&lt;/code&gt; into the flex table mapper:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; COPY mapper FROM &amp;#39;/home/dbadmin/data/simple.json&amp;#39; parser fjsonparser (flatten_arrays=false,
flatten_maps=false);
 Rows Loaded
-------------
           1
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Call MAPKEYS on the flex table&#39;s &lt;code&gt;__raw__&lt;/code&gt; column to see the flex table&#39;s keys, but not the key submaps. The return values indicate &lt;code&gt;three_Array&lt;/code&gt; as one of the virtual columns:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPKEYS(__raw__) OVER() FROM mapper;
    keys
-------------
 five_Map
 four
 one
 six
 three_Array
 two
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Call &lt;code&gt;mapitems&lt;/code&gt; on flex table &lt;code&gt;mapper&lt;/code&gt; with &lt;code&gt;three_Array&lt;/code&gt; as a pass-through 					argument to the function. The call returns these array values:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT __identity__, MAPITEMS(three_Array) OVER(PARTITION BY __identity__) FROM mapper;
 __identity__ | keys |   values
--------------+------+------------
            1 | 0    | three_One
            1 | 1    | three_Two
            1 | 2    | 3
            1 | 3    | three_Four
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPKEYS</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/</guid>
      <description>
        
        
        &lt;p&gt;Returns the virtual columns (and values) present in any VMap data. This transform function requires an &lt;code&gt;OVER(PARTITION BEST)&lt;/code&gt; clause.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPKEYS (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;In a &lt;code&gt;__raw__&lt;/code&gt; column, specifies the maximum length of keys that the function can return. Keys that are longer than &lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt; cause the query to fail. Defaults to the smaller of VMap column length and 65K.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Determine Number of Virtual Columns in Map Data&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This example shows how to create a query, using an &lt;code&gt;over(PARTITION BEST)&lt;/code&gt; clause with a flex table, &lt;code&gt;darkdata&lt;/code&gt; to find the number of virtual column in the map data. The table is populated with JSON tweet data.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT COUNT(keys) FROM (SELECT MAPKEYS(darkdata.__raw__) OVER(PARTITION BEST) FROM darkdata) AS a;
 count
-------
   550
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Query Ordered List of All Virtual Columns in the Map&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This example shows a snippet of the return data when you query an ordered list of all virtual columns in the map data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM (SELECT MAPKEYS(darkdata.__raw__) OVER(PARTITION BEST) FROM darkdata) AS a;
    keys
-------------------------------------
 contributors
 coordinates
 created_ at
 delete.status.id
 delete.status.id_str
 delete.status.user_id
 delete.status.user_id_str
 entities.hashtags
 entities.media
 entities.urls
 entities.user_mentions
 favorited
 geo
 id
.
.
.
 user.statuses_count
 user.time_zone
 user.url
 user.utc_offset
 user.verified
(125 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Specify the Maximum Length of Keys that MAPKEYS Can Return&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPKEYS(__raw__ USING PARAMETERS max_key_length=100000) OVER() FROM mapper;
    keys
-------------
 five_Map
 four
 one
 six
 three_Array
 two
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPKEYSINFO</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/</guid>
      <description>
        
        
        &lt;p&gt;Returns virtual column information from a given map. This transform function requires an &lt;code&gt;OVER(PARTITION BEST)&lt;/code&gt; clause.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPKEYSINFO (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;In a &lt;code&gt;__raw__&lt;/code&gt; column, determines the maximum length of keys that the function can return. Keys that are longer than &lt;em&gt;&lt;code&gt;max_key_length&lt;/code&gt;&lt;/em&gt; cause the query to fail. Defaults to the smaller of VMap column length and 65K.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;returns&#34;&gt;Returns&lt;/h2&gt;
&lt;p&gt;This function is a superset of the &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;() function. It returns the following information about each virtual column:

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Column&lt;/th&gt; 

&lt;th &gt;
Description&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;keys&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


The virtual column names in the raw data.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;length&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


The data length of the key name, which can differ from the actual string length.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;type_oid&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


The OID type into which the value should be converted. Currently, the type is always &lt;code&gt;116&lt;/code&gt; for a &lt;code&gt;LONG VARCHAR&lt;/code&gt;, or &lt;code&gt;199&lt;/code&gt; for a nested map that is stored as a &lt;code&gt;LONG VARBINARY&lt;/code&gt;.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;row_num&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


The number of rows in which the key was found.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;field_num&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


The field number in which the key exists.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example shows a snippet of the return data you receive if you query an ordered list of all virtual columns in the map data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM (SELECT MAPKEYSINFO(darkdata.__raw__) OVER(PARTITION BEST) FROM darkdata) AS a;
                          keys                           | length | type_oid | row_num | field_num
----------------------------------------------------------+--------+----------+---------+-----------
 contributors                                             |      0 |      116 |       1 |         0
 coordinates                                              |      0 |      116 |       1 |         1
 created_at                                               |     30 |      116 |       1 |         2
 entities.hashtags                                        |     93 |      199 |       1 |         3
 entities.media                                           |    772 |      199 |       1 |         4
 entities.urls                                            |     16 |      199 |       1 |         5
 entities.user_mentions                                   |     16 |      199 |       1 |         6
 favorited                                                |      1 |      116 |       1 |         7
 geo                                                      |      0 |      116 |       1 |         8
 id                                                       |     18 |      116 |       1 |         9
 id_str                                                   |     18 |      116 |       1 |        10
.
.
.
 delete.status.id                                         |     18 |      116 |      11 |         0
 delete.status.id_str                                     |     18 |      116 |      11 |         1
 delete.status.user_id                                    |      9 |      116 |      11 |         2
 delete.status.user_id_str                                |      9 |      116 |      11 |         3
 delete.status.id                                         |     18 |      116 |      12 |         0
 delete.status.id_str                                     |     18 |      116 |      12 |         1
 delete.status.user_id                                    |      9 |      116 |      12 |         2
 delete.status.user_id_str                                |      9 |      116 |      12 |         3
(550 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Specify the Maximum Length of Keys that MAPKEYSINFO Can Return&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPKEYSINFO(__raw__ USING PARAMETERS max_key_length=100000) OVER() FROM mapper;
    keys
-------------
 five_Map
 four
 one
 six
 three_Array
 two
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPLOOKUP</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/</guid>
      <description>
        
        
        &lt;p&gt;Returns single-key values from VMAP data. This scalar function returns a &lt;code&gt;LONG VARCHAR&lt;/code&gt;, with values, or &lt;code&gt;NULL&lt;/code&gt; if the virtual column does not have a value.&lt;/p&gt;
&lt;p&gt;Using &lt;code&gt;maplookup&lt;/code&gt; is case insensitive to virtual column names. To avoid loading same-name values, set the &lt;code&gt;fjsonparser&lt;/code&gt; parser &lt;code&gt;reject_on_duplicate&lt;/code&gt; parameter to &lt;code&gt;true&lt;/code&gt; when data loading.&lt;/p&gt;
&lt;p&gt;You can control the behavior for non-scalar values in a VMAP (like arrays), when loading data with the &lt;code&gt;fjsonparser&lt;/code&gt; or &lt;code&gt;favroparser&lt;/code&gt; parsers and its &lt;code&gt;flatten-arrays&lt;/code&gt; argument. See &lt;a href=&#34;../../../../../en/data-load/data-formats/json-data/#&#34;&gt;JSON data&lt;/a&gt; and the &lt;a href=&#34;../../../../../en/flex-tables/using-flex-table-parsers/&#34;&gt;FJSONPARSER&lt;/a&gt; reference.&lt;/p&gt;
&lt;p&gt;For information about using maplookup() to access nested JSON data, see &lt;a href=&#34;../../../../../en/flex-tables/querying-nested-data/#&#34;&gt;Querying nested data&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPLOOKUP (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;virtual-column-name&lt;/span&gt;&amp;#39; [USING PARAMETERS [case_sensitive={false | true}] [, buffer_size=&lt;span class=&#34;code-variable&#34;&gt;n&lt;/span&gt;] ] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;virtual-column-name&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The name of the virtual column whose values this function returns.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;buffer_size&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;[Optional parameter] Specifies the maximum length (in bytes) of each value returned for &lt;em&gt;&lt;code&gt;virtual-column-name&lt;/code&gt;&lt;/em&gt;. To return all values for &lt;em&gt;&lt;code&gt;virtual-column-name&lt;/code&gt;&lt;/em&gt;, specify a &lt;code&gt;buffer_size&lt;/code&gt; equal to or greater than (&lt;code&gt;=&amp;gt;&lt;/code&gt;) the number of bytes for any returned value. Any returned values greater in length than &lt;code&gt;buffer_size&lt;/code&gt; are rejected.
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; &lt;code&gt;0&lt;/code&gt; (No limit on &lt;code&gt;buffer_size&lt;/code&gt;)&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;case_sensitive&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;[Optional parameter]
&lt;p&gt;Specifies whether to return values for &lt;em&gt;&lt;code&gt;virtual-column-name&lt;/code&gt;&lt;/em&gt; if keys with different cases exist.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;(... USING PARAMETERS case_sensitive=true)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; &lt;code&gt;false&lt;/code&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example returns the values of one virtual column, &lt;code&gt;user.location&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;user.location&amp;#39;) FROM darkdata ORDER BY 1;
 maplookup
-----------
 Chile
 Nesnia
 Uptown
 .
 .
 chicago
(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Using maplookup buffer_size&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Use the &lt;code&gt;buffer_size=&lt;/code&gt; parameter to indicate the maximum length of any value that maplookup returns for the virtual column you specify. If none of the returned key values can be greater than &lt;code&gt;n&lt;/code&gt; bytes, use this parameter to allocate &lt;code&gt;n&lt;/code&gt; bytes as the &lt;code&gt;buffer_size&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For the next example, save this JSON data to a file, &lt;code&gt;simple_name.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{
  &amp;#34;name&amp;#34;: &amp;#34;sierra&amp;#34;,
  &amp;#34;age&amp;#34;: &amp;#34;63&amp;#34;,
  &amp;#34;eyes&amp;#34;: &amp;#34;brown&amp;#34;,
  &amp;#34;weapon&amp;#34;: &amp;#34;doggie&amp;#34;
}
{
  &amp;#34;name&amp;#34;: &amp;#34;janis&amp;#34;,
  &amp;#34;age&amp;#34;: &amp;#34;10&amp;#34;,
  &amp;#34;eyes&amp;#34;: &amp;#34;blue&amp;#34;,
  &amp;#34;weapon&amp;#34;: &amp;#34;humor&amp;#34;
}
{
  &amp;#34;name&amp;#34;: &amp;#34;ben&amp;#34;,
  &amp;#34;age&amp;#34;: &amp;#34;43&amp;#34;,
  &amp;#34;eyes&amp;#34;: &amp;#34;blue&amp;#34;,
  &amp;#34;weapon&amp;#34;: &amp;#34;sword&amp;#34;
}
{
  &amp;#34;name&amp;#34;: &amp;#34;jen&amp;#34;,
  &amp;#34;age&amp;#34;: &amp;#34;38&amp;#34;,
  &amp;#34;eyes&amp;#34;: &amp;#34;green&amp;#34;,
  &amp;#34;weapon&amp;#34;: &amp;#34;shopping&amp;#34;
}
&lt;/code&gt;&lt;/pre&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a flex table, &lt;code&gt;logs&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Load the &lt;code&gt;simple_name.json&lt;/code&gt; data into &lt;code&gt;logs&lt;/code&gt;, using the &lt;code&gt;fjsonparser&lt;/code&gt;. Specify the &lt;code&gt;flatten_arrays&lt;/code&gt; option as &lt;code&gt;True&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; COPY logs FROM &amp;#39;/home/dbadmin/data/simple_name.json&amp;#39;
  PARSER fjsonparser(flatten_arrays=True);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;maplookup&lt;/code&gt; with &lt;code&gt;buffer_size=0&lt;/code&gt; for the &lt;code&gt;logs&lt;/code&gt; table &lt;code&gt;name&lt;/code&gt; key. This query returns all of the values:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;name&amp;#39; USING PARAMETERS buffer_size=0) FROM logs;
 MapLookup
-----------
 sierra
 ben
 janis
 jen
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, call &lt;code&gt;maplookup()&lt;/code&gt; three times, specifying the &lt;code&gt;buffer_size&lt;/code&gt; parameter as &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;5&lt;/code&gt;, and &lt;code&gt;6&lt;/code&gt;, respectively. Now, &lt;code&gt;maplookup()&lt;/code&gt; returns values with a byte length less than or equal to (&amp;lt;=) &lt;code&gt;buffer_size&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;name&amp;#39; USING PARAMETERS buffer_size=3) FROM logs;
 MapLookup
-----------

 ben

 jen
(4 rows)
=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;name&amp;#39; USING PARAMETERS buffer_size=5) FROM logs;
 MapLookup
-----------

 janis
 jen
 ben
(4 rows)
=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;name&amp;#39; USING PARAMETERS buffer_size=6) FROM logs;
 MapLookup
-----------
 sierra
 janis
 jen
 ben
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Disambiguate Empty Output Rows&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This example shows how to interpret empty rows. Using &lt;code&gt;maplookup&lt;/code&gt; without first checking whether a key exists can be ambiguous. When you review the following output, 12 empty rows, you cannot determine whether a &lt;code&gt;user.location&lt;/code&gt; key has:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A non-NULL value&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A &lt;code&gt;NULL&lt;/code&gt; value&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No value&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;user.location&amp;#39;) FROM darkdata;
 maplookup
-----------












(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To disambiguate empty output rows, use the &lt;code&gt;mapcontainskey()&lt;/code&gt; function in conjunction with &lt;code&gt;maplookup()&lt;/code&gt;. When &lt;code&gt;maplookup&lt;/code&gt; returns an empty field, the corresponding value from &lt;code&gt;mapcontainskey&lt;/code&gt; indicates &lt;code&gt;t&lt;/code&gt; for a &lt;code&gt;NULL&lt;/code&gt; or other value, or &lt;code&gt;f&lt;/code&gt;for no value.&lt;/p&gt;
&lt;p&gt;The following example output using both functions lists rows with NULL or a name value as &lt;code&gt;t&lt;/code&gt;, and rows with no value as &lt;code&gt;f&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPLOOKUP(__raw__, &amp;#39;user.location&amp;#39;), MAPCONTAINSKEY(__raw__, &amp;#39;user.location&amp;#39;)
FROM darkdata ORDER BY 1;
 maplookup | mapcontainskey
-----------+----------------
           | t
           | t
           | t
           | t
 Chile     | t
 Nesnia    | t
 Uptown    | t
 chicago   | t
           | f &lt;span class=&#34;code-input&#34;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;No value&lt;/span&gt;
           | f &lt;span class=&#34;code-input&#34;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;No value&lt;/span&gt;
           | f &lt;span class=&#34;code-input&#34;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;No value&lt;/span&gt;
           | f &lt;span class=&#34;code-input&#34;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;No value&lt;/span&gt;
(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Check for Case-Sensitive Virtual Columns&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can use &lt;code&gt;maplookup()&lt;/code&gt; with the &lt;code&gt;case_sensitive&lt;/code&gt; parameter to return results when key names with different cases exist.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Save the following sample content as a JSON file. This example saves the file as &lt;code&gt;repeated_key_name.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{
  &amp;#34;test&amp;#34;: &amp;#34;lower1&amp;#34;
}
{
  &amp;#34;TEST&amp;#34;: &amp;#34;upper1&amp;#34;
}
{
  &amp;#34;TEst&amp;#34;: &amp;#34;half1&amp;#34;
}
{
  &amp;#34;test&amp;#34;: &amp;#34;lower2&amp;#34;,
  &amp;#34;TEst&amp;#34;: &amp;#34;half2&amp;#34;
}
{
  &amp;#34;TEST&amp;#34;: &amp;#34;upper2&amp;#34;,
  &amp;#34;TEst&amp;#34;: &amp;#34;half3&amp;#34;
}
{
  &amp;#34;test&amp;#34;: &amp;#34;lower3&amp;#34;,
  &amp;#34;TEST&amp;#34;: &amp;#34;upper3&amp;#34;
}
{
  &amp;#34;TEst&amp;#34;: &amp;#34;half4&amp;#34;,
  &amp;#34;test&amp;#34;: &amp;#34;lower4&amp;#34;,
  &amp;#34;TEST&amp;#34;: &amp;#34;upper4&amp;#34;
}
{
  &amp;#34;TesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttest
TesttestTesttestTesttestTesttest&amp;#34;:&amp;#34;1&amp;#34;,
    &amp;#34;TesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttestTesttest
TesttestTesttestTesttestTesttestTest12345&amp;#34;:&amp;#34;2&amp;#34;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a flex table, &lt;code&gt;dupe&lt;/code&gt;, and load the JSON file:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE FLEX TABLE dupe();
CREATE TABLE
dbt=&amp;gt; COPY dupe FROM &amp;#39;/home/release/KData/repeated_key_name.json&amp;#39; parser fjsonparser();
 Rows Loaded
-------------
           8
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;    &lt;/p&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPPUT</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapput/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapput/</guid>
      <description>
        
        
        &lt;p&gt;Accepts a VMap and one or more key/value pairs and returns a new VMap with the key/value pairs added. Keys must be set using the auxiliary function &lt;code&gt;SetMapKeys()&lt;/code&gt;, and can only be constant strings. If the VMap has any of the new input keys, then the original values are replaced by the new ones.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPPUT (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt;[,...] USING PARAMETERS keys=SetMapKeys(&amp;#39;key&amp;#39;[,...])
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Any VMap data. The VMap can exist as:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;value&lt;/code&gt;&lt;/em&gt;&lt;code&gt;[,...]&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;One or more values to add to the VMap specified in &lt;code&gt;VMap-data&lt;/code&gt;.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;keys&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The result of &lt;code&gt;SetMapKeys()&lt;/code&gt;. &lt;code&gt;SetMapKeys()&lt;/code&gt; takes one or more constant string arguments.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;The following example shows how to create a flex table and use COPY to enter some basic JSON data. After creating a second flex table, insert the new VMap results from &lt;code&gt;mapput()&lt;/code&gt;, with additional key/value pairs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create sample table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE FLEX TABLE vmapdata1();
CREATE TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Load sample JSON data from STDIN:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; COPY vmapdata1 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.
&amp;gt;&amp;gt; {&amp;#34;aaa&amp;#34;: 1, &amp;#34;bbb&amp;#34;: 2, &amp;#34;ccc&amp;#34;: 3}
&amp;gt;&amp;gt; \.
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create another flex table and use the function to insert data into it:  &lt;code&gt;=&amp;gt; CREATE FLEX TABLE vmapdata2(); =&amp;gt; INSERT INTO vmapdata2 SELECT MAPPUT(__raw__, &#39;7&#39;,&#39;8&#39;,&#39;9&#39;   using parameters keys=SetMapKeys(&#39;xxx&#39;,&#39;yyy&#39;,&#39;zzz&#39;)) from vmapdata1; &lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;View the difference between the original and the new flex tables:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPTOSTRING(__raw__) FROM vmapdata1;
                     maptostring
-----------------------------------------------------
 {
   &amp;#34;aaa&amp;#34; : &amp;#34;1&amp;#34;,
   &amp;#34;bbb&amp;#34; : &amp;#34;2&amp;#34;,
   &amp;#34;ccc&amp;#34; : &amp;#34;3&amp;#34;
 }
 (1 row)

=&amp;gt; SELECT MAPTOSTRING(__raw__) from vmapdata2;
                     maptostring
-------------------------------------------------------
 {
   &amp;#34;mapput&amp;#34; : {
      &amp;#34;aaa&amp;#34; : &amp;#34;1&amp;#34;,
      &amp;#34;bbb&amp;#34; : &amp;#34;2&amp;#34;,
      &amp;#34;ccc&amp;#34; : &amp;#34;3&amp;#34;,
      &amp;#34;xxx&amp;#34; : &amp;#34;7&amp;#34;,
      &amp;#34;yyy&amp;#34; : &amp;#34;8&amp;#34;,
      &amp;#34;zzz&amp;#34; : &amp;#34;9&amp;#34;
   }
 }
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPSIZE</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/</guid>
      <description>
        
        
        &lt;p&gt;Returns the number of virtual columns present in any VMap data. Use this scalar function to determine the size of keys.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPSIZE (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example shows the returned sizes from the number of keys in the flex table &lt;code&gt;darkmountain&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPSIZE(__raw__) FROM darkmountain;
 mapsize
---------
       3
       4
       4
       4
       4
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPTOSTRING</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/</guid>
      <description>
        
        
        &lt;p&gt;Recursively builds a string representation of VMap data, including nested JSON maps. Use this transform function to display the VMap contents in a LONG VARCHAR format. You can use MAPTOSTRING to see how map data is nested before querying virtual columns with &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPTOSTRING ( &lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt; [ USING PARAMETERS &lt;span class=&#34;code-variable&#34;&gt;param&lt;/span&gt;=&lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt; ] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;canonical_json&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Boolean, whether to produce canonical JSON format, using the first instance of any duplicate keys in the map data. If false, the function returns duplicate keys and their values.
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; true&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example uses this table definition and sample data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE FLEX TABLE darkdata();
CREATE TABLE

=&amp;gt; COPY darkdata 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.
&amp;gt;&amp;gt; {&amp;#34;aaa&amp;#34;: 1, &amp;#34;aaa&amp;#34;: 2, &amp;#34;AAA&amp;#34;: 3, &amp;#34;bbb&amp;#34;: &amp;#34;aaa\&amp;#34;bbb&amp;#34;}
&amp;gt;&amp;gt; \.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Calling MAPTOSTRING with the default value of &lt;code&gt;canonical_json&lt;/code&gt; returns only the first instance of the duplicate key:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPTOSTRING (__raw__) FROM darkdata;
                        maptostring
------------------------------------------------------------
 {
   &amp;#34;AAA&amp;#34; : &amp;#34;3&amp;#34;,
   &amp;#34;aaa&amp;#34; : &amp;#34;1&amp;#34;,
   &amp;#34;bbb&amp;#34; : &amp;#34;aaa\&amp;#34;bbb&amp;#34;
}
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;With &lt;code&gt;canonical_json&lt;/code&gt; set to false, the function returns all of the keys, including duplicates:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPTOSTRING(__raw__ using parameters canonical_json=false) FROM darkdata;
                          maptostring
---------------------------------------------------------------
 {
        &amp;#34;aaa&amp;#34;:  &amp;#34;1&amp;#34;,
        &amp;#34;aaa&amp;#34;:  &amp;#34;2&amp;#34;,
        &amp;#34;AAA&amp;#34;:  &amp;#34;3&amp;#34;,
        &amp;#34;bbb&amp;#34;:  &amp;#34;aaa&amp;#34;bbb&amp;#34;
 }
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPVALUES</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/</guid>
      <description>
        
        
        &lt;p&gt;Returns a string representation of the top-level values from a VMap. This transform function requires an &lt;code&gt;OVER()&lt;/code&gt; clause.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPVALUES (&lt;span class=&#34;code-variable&#34;&gt;VMap-data&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;max_value_length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;In a &lt;code&gt;__raw__&lt;/code&gt; column, specifies the maximum length of values the function can return. Values that are larger than &lt;em&gt;&lt;code&gt;max_value_length&lt;/code&gt;&lt;/em&gt; cause the query to fail. Defaults to the smaller of VMap column length and 65K.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example shows how to query a &lt;code&gt;darkmountain&lt;/code&gt; flex table, using an &lt;code&gt;over()&lt;/code&gt; clause (in this case, the &lt;code&gt;over(PARTITION BEST)&lt;/code&gt; clause) with &lt;code&gt;mapvalues()&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM (SELECT MAPVALUES(darkmountain.__raw__) OVER(PARTITION BEST) FROM darkmountain) AS a;
    values
---------------
 29029
 34.1
 Everest
 mountain
 29029
 15.4
 Mt St Helens
 volcano
 17000
 12.2
 Denali
 mountain
 14000
 22.8
 Kilimanjaro
 mountain
 50.6
 Mt Washington
 mountain
(19 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Specify the Maximum Length of Values that MAPVALUES Can Return&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPVALUES(__raw__ USING PARAMETERS max_value_length=100000) OVER() FROM mapper;
    keys
-------------
 five_Map
 four
 one
 six
 three_Array
 two
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/#&#34;&gt;MAPVERSION&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MAPVERSION</title>
      <link>/en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/flex-functions/flex-map-functions/mapversion/</guid>
      <description>
        
        
        &lt;p&gt;Returns the version or invalidity of any map data. This scalar function returns the map version (such as &lt;code&gt;1&lt;/code&gt;) or &lt;code&gt;-1&lt;/code&gt;, if the map data is invalid.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MAPVERSION (VMap-data)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;VMap-data&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Any VMap data. The VMap can exist as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__raw__&lt;/code&gt; column of a flex table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data returned from a map function such as &lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other database content&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example shows how to use &lt;code&gt;mapversion()&lt;/code&gt; with the &lt;code&gt;darkmountain&lt;/code&gt;flex table, returning &lt;code&gt;mapversion 1&lt;/code&gt; for the flex table map data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAPVERSION(__raw__) FROM darkmountain;
 mapversion
------------
          1
          1
          1
          1
          1
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/emptymap/#&#34;&gt;EMPTYMAP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapaggregate/#&#34;&gt;MAPAGGREGATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainskey/#&#34;&gt;MAPCONTAINSKEY&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapcontainsvalue/#&#34;&gt;MAPCONTAINSVALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapitems/#&#34;&gt;MAPITEMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeys/#&#34;&gt;MAPKEYS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapkeysinfo/#&#34;&gt;MAPKEYSINFO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maplookup/#&#34;&gt;MAPLOOKUP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapsize/#&#34;&gt;MAPSIZE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/maptostring/#&#34;&gt;MAPTOSTRING&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/flex-functions/flex-map-functions/mapvalues/#&#34;&gt;MAPVALUES&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
