Category: Arrays

ARRAY_CONTAINS

ARRAY_CONTAINS checks whether a value occurs in an array and returns true or false.

Syntax

ARRAY_CONTAINS(array1, value_to_check)

AMC specifics

  • Handy for finding users whose collected values contain a given product or format.
  • The value is compared with the array, not with a sensitive column; AMC does reject literal comparisons on columns with a high threshold.

Example

Users with at least one Sponsored Brands row.

WITH paths AS (
  SELECT
    user_id,
    COLLECT(DISTINCT ad_product_type) AS products
  FROM
    sponsored_ads_traffic
  GROUP BY
    1
)
SELECT
  COUNT(DISTINCT user_id) AS users_with_sponsored_brands
FROM
  paths
WHERE
  ARRAY_CONTAINS(products, 'sponsored_brands')

Checked against the AMC schema, not executed on an AMC instance.

Related functions: COLLECT, ARRAY_INTERSECT

Source: advertising.amazon.com (retrieved 2026-10-09)