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.
-
Sign into the Athena console at https://console.aws.amazon.com/athena/
as the DataAnalystUS
user. -
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.
-
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 themarketplace
column value is equal toUS
. -
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
. -
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
.