Step 4: Query with data filters - Amazon Lake Formation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Step 4: Query with data filters

With the data filters attached to the product reviews table, run some queries and see how permissions are enforced by Lake Formation.

  1. Sign into the Athena console at https://console.amazonaws.cn/athena/ as the DataAnalystUS user.

  2. Run the following query to retrieve a few records, which are filtered based on the row-level permissions we defined:

    SELECT * FROM lakeformation_tutorial_row_security.amazon_reviews LIMIT 10

    The following screenshot shows the query result.

  3. Similarly, run a query to count the total number of records per marketplace.

    SELECT marketplace , count ( * ) as total_count FROM lakeformation_tutorial_row_security .amazon_reviews GROUP BY marketplace

    The query result only shows the marketplace US in the results. This is because the user is only allowed to see rows where the marketplace column value is equal to US.

  4. Switch to the DataAnalystJP user and run the same query.

    SELECT * FROM lakeformation_tutorial_row_security.amazon_reviews LIMIT 10

    The query result shows only the records belong to the JP marketplace.

  5. Run the query to count the total number of records per marketplace.

    SELECT marketplace, count(*) as total_count FROM lakeformation_tutorial_row_security.amazon_reviews GROUP BY marketplace

    The query result shows only the row belonging to the JP marketplace.