Skip to content

Apply AWS Lake Formation Fine Grained Access Control (FGAC) on an Apache Iceberg V3 table from a Glue 6.0 Spark job

6 minute read
Content level: Advanced
0

Apache Iceberg V3 provides the new VARIANT column type for semi-structured data. While Glue 6.0 and EMR 8.1 supports reading and writing Iceberg V3 tables, including the Variant type, these support it only in Full Table Access (FTA) mode and not FGAC mode. This article shows a workaround on how to apply FGAC on the Iceberg V3 table that includes Variant type for restricted access of the table.

A background on the what and why of FGAC with Iceberg V3 in AWS Glue and EMR

Apache Iceberg V3 specification introduced a new Variant column type allows you to keep the semi-structured data, such as JSON, struct or array as it is without flattening it. A common requirement from many large enterprise data lakehouses is to keep the single source of truth data in the Iceberg V3 table, while applying row and column filters on it to share restricted subset of data to various users and applications in the organization.

Glue 6.0 and EMR 8.1 onwards provides support for reading and writing Iceberg V3 tables, including Variant type, but only in FTA mode and not FGAC. That is, if the Glue job execution role/EMR runtime role has SELECT and DESCRIBE permissions on all columns and rows of the table, then the compute cluster needs to be configured only in FTA mode. Glue 6.0/EMR 8.1 in FGAC mode cannot process the Variant column type. The engines and AWS Lake Formation do not support FGAC(mode) on the Variant type.

To apply row and column filters on an Iceberg V3 table that has Variant types, then is not possible. To share a restricted subset of the Iceberg V3 table, you can exclude the Variant column type and apply Lake Formation Row Level Security policies on the rest of the columns.

This solution can be used where a single source of truth table needs to be maintained; where row and column filters need to be applied to create a restricted share of the source table; where the Variant column need not be shared.

Another option is to create a Glue Iceberg Materialized View on the source Iceberg V3 table, with the view's SQL expression providing the required row and column restrictions. For low latency applications and where high frequency queries are done on large data sets, MV is a better choice. Remember, you will pay additionally for the MV's storage and compute.

In this knowledge article, I'll walk you through the key steps on how to exclude the Variant column and apply Lake Formation RLS policies for two different users. Working knowledge of Lake Formation is expected from readers, so you could apply it on your tables. Account IDs, bucket names, and database names below are placeholders. Substitute your own.

Test table

iceberg_v3_variant_db.variant_evolution_test   (Iceberg format-version 3, populated with 8 rows of data)

id           int
name         string
event_time   timestamp_ns      <- V3 nanosecond timestamp type
payload      variant           <- V3 Variant type
status       string

Setup:

  • Principal to be granted access to the database and table = Glue 6.0 job execution role = JOB_ROLE_ARN
  • What the job does = Reads id, name, event_time, and status with RLS policies applied, and cannot read payload.

Lake Formation grants

Grant DESCRIBE on the database so the job can run SHOW TABLES:

lf.grant_permissions(
    Principal={"DataLakePrincipalIdentifier": JOB_ROLE_ARN},
    Resource={"Database": {"CatalogId": ACCOUNT_ID, "Name": "iceberg_v3_variant_db"}},
    Permissions=["DESCRIBE"])

Then grant SELECT on the permitted columns only:

lf.grant_permissions(
    Principal={"DataLakePrincipalIdentifier": JOB_ROLE_ARN},
    Resource={"TableWithColumns": {
        "CatalogId": ACCOUNT_ID,
        "DatabaseName": "iceberg_v3_variant_db",
        "Name": "variant_evolution_test",
        "ColumnNames": ["id", "name", "event_time", "status"]}},
    Permissions=["SELECT"])

Important notes on Lake Formation permissions:

(1) TableWithColumns accepts either ColumnNames (an inclusion list) or ColumnWildcard.ExcludedColumnNames (an exclusion list). Both deny payload today. They diverge when someone adds a column later: an inclusion list keeps the new column hidden until you grant it, while an exclusion list admits it automatically. For a column whose whole purpose is to hold unreviewed payload data, the inclusion list is the safer default.

(2) Check for grants the role already holds before you start. Lake Formation takes the union of all grants to a principal, so one leftover SELECT with ColumnWildcard: {} from earlier testing cancels out the column restriction without raising any error.

Glue job configuration

Glue 6.0, --datalake-formats iceberg, --enable-lakeformation-fine-grained-access true, 6 G.1X workers. The Spark configuration:

spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions
spark.sql.catalog.glue_catalog=org.apache.iceberg.spark.SparkCatalog
spark.sql.catalog.glue_catalog.catalog-impl=org.apache.iceberg.aws.glue.GlueCatalog
spark.sql.catalog.glue_catalog.io-impl=org.apache.iceberg.aws.s3.S3FileIO
spark.sql.catalog.glue_catalog.warehouse=s3://<bucket>/<prefix>/
spark.sql.catalog.glue_catalog.glue.id=<account-id>
spark.sql.catalog.glue_catalog.glue.account-id=<account-id>
spark.sql.catalog.glue_catalog.glue.region=<region>
spark.sql.catalog.glue_catalog.client.region=<region>
spark.sql.catalog.glue_catalog.glue.lakeformation-enabled=true
spark.sql.defaultCatalog=glue_catalog

Result: column restriction

SHOW TABLES lists the table from the database DESCRIBE grant alone. DESCRIBE TABLE returns four columns, with payload absent:

+----------+----------------+
|col_name  |data_type       |
+----------+----------------+
|id        |int             |
|name      |string          |
|event_time|timestamp_ntz(9)|
|status    |string          |
+----------+----------------+

SELECT * returns all 8 rows across the four permitted columns, and nanosecond precision survives:

STAR_COLUMNS: ['id', 'name', 'event_time', 'status']
STAR_SCHEMA: struct<id:int,name:string,event_time:timestamp_ntz(9),status:string>
STAR_ROWCOUNT: 8
+---+-------+-----------------------------+-------+
|id |name   |event_time                   |status |
+---+-------+-----------------------------+-------+
|1  |alpha  |2026-06-01 10:00:00.123456789|flagged|
|2  |bravo  |2026-06-01 10:00:01.223456789|review |
|3  |charlie|2026-06-01 10:00:02.323456789|flagged|
|4  |delta  |2026-06-01 10:00:03.423456789|review |
|5  |echo   |2026-06-01 10:00:04.523456789|flagged|
|6  |foxtrot|2026-06-02 11:00:00.623456789|active |
|7  |golf   |2026-06-02 11:00:01.723456789|active |
|8  |hotel  |2026-06-02 11:00:02.823456789|active |
+---+-------+-----------------------------+-------+

Naming the column explicitly fails during analysis rather than returning nulls or an authorization error:

[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column, variable, or function parameter
with name `payload` cannot be resolved.
Did you mean one of the following? [`id`, `name`, `status`, `event_time`]

The column does not exist in the schema the role receives. payload:field path extraction and to_json(payload) both fail the same way, so there is no route to the value through variant-specific syntax.

Adding row-level security

Lake Formation row-level security policies are a separate API from data cells filters. A policy is created on its own, then attached to a resource and a principal in a second call:

lf.create_rls_policy(
    Name="rls_active_only",
    AttachmentColumns=[{"Name": "status", "Type": "string"}],
    FilterExpression="status = 'active'")

lf.attach_rls_policy(
    Name="rls_active_only",
    Resource={"Table": {
        "CatalogId": ACCOUNT_ID,
        "DatabaseName": "iceberg_v3_variant_db",
        "Name": "variant_evolution_test"}},
    Principal={"DataLakePrincipalIdentifier": JOB_ROLE_ARN})

AttachmentColumns declares the columns the filter expression references. Because the policy holds no table reference of its own, the same policy can be attached to any table carrying those columns, and to different principals with different resources.

The column restriction stays where it was. The TableWithColumns SELECT grant from the previous section is left in place, and the RLS policy composes with it: rows come from the policy, columns from the grant. This differs from a data cells filter, which carries both in one object and therefore replaces the table grant rather than layering on top of it.

With the RLS policy attached and the column grant untouched, the same Glue job returns 3 of 8 rows:

STAR_COLUMNS: ['id', 'name', 'event_time', 'status']
STAR_ROWCOUNT: 3
+---+-------+-----------------------------+------+
|id |name   |event_time                   |status|
+---+-------+-----------------------------+------+
|6  |foxtrot|2026-06-02 11:00:00.623456789|active|
|7  |golf   |2026-06-02 11:00:01.723456789|active|
|8  |hotel  |2026-06-02 11:00:02.823456789|active|
+---+-------+-----------------------------+------+
COUNT: 3

SELECT count(*) also returned 3. The policy applies to aggregates, not only to projections, so row counts do not leak the filtered rows. payload remains unresolvable, so row and column restrictions hold at the same time.

SDK version requirement

The RLS policies are supported from boto3 1.43.123 onwards. It requires Python 3.10 or later.

AWS
EXPERT

published 4 days ago138 views