Skip to content

Redshift Spectrum truncates Iceberg metadata_location, causing performance issues

1

Issue

Redshift Spectrum appears to be truncating the metadata_location parameter for Iceberg tables to 128 characters. This prevents Spectrum from properly reading Iceberg metadata files, resulting in full sequential scans instead of partition-pruned reads.

Relevant content reviewed

Evidence & Impact

Identical query run with Athena vs Spectrum:

SELECT count(*)
FROM <my_table>
WHERE timestamp >= CURRENT_TIMESTAMP - interval '6' hour';
  • Athena: 3.2 seconds (scans 3.2MB)
  • Spectrum: 10+ minutes (full sequential scan)

All Iceberg tables in our schema show exactly 128-character parameter lengths:

SELECT tablename, 
       len(parameters) as param_length,
       parameters
FROM SVV_EXTERNAL_TABLES 
WHERE schemaname = '<my_schema>'
ORDER BY tablename;

Attempting to extract the metadata_location shows JSON parsing errors due to truncation:

SELECT tablename,
    json_extract_path_text(parameters, 'metadata_location') AS metadata_location
FROM SVV_EXTERNAL_TABLES 
WHERE schemaname = '<my_schema>';

Error:

JSON parsing error Detail: invalid json object {"metadata_location":"s3://<bucket>/.../tables/my_table/metadata/08857-a1f504fe-608c-4bab-92e6-749240a

(Note the incomplete UUID, missing .metadata.json extension & closing ").

Query plan shows Spectrum unable to utilize partitioning:

        ->  S3 HashAggregate  (cost=236199230.50..236199230.51 rows=2000 width=8)    
              ->  S3 Seq Scan my_schema.my_table location:"s3://<bucket>/.../tables/my_table" format:ICEBERG  (cost=0.00..235727774.95 rows=94291110 width=8)    
                    Filter: ((event)::text = 'Page View'::text)

Setup Details

Our Iceberg table is properly partitioned by hour:

CREATE TABLE my_table(
  timestamp timestamp,
  [other fields...]
)
PARTITIONED BY (hour(timestamp))
LOCATION '<location>'
TBLPROPERTIES ('table_type'='ICEBERG')

Iceberg metadata confirms partitioning is as expected:

{
  "format-version" : 2,
  "partition-specs" : [ {
    "spec-id" : 0,
    "fields" : [ {
      "name" : "timestamp_hour",
      "transform" : "hour",
      "source-id" : 1,
      "field-id" : 1000
    } ]
  } ]
}

Expected Behavior

Per AWS documentation:

Amazon Redshift can use the table statistics stored in Apache Iceberg metadata to optimize query plans and reduce file scans during query processing

Questions

  1. Is the 128-character limit on the svv_external_tables.parameters column, or this issue more broadly, a known limitation?
  2. Are there any workarounds to allow Spectrum to properly access Iceberg metadata files?
  3. Is there a timeline for fixing this issue?
  • We're literally getting the same error, as of 23/10/2025. Has this been looked at by AWS?

asked 2 years ago623 views

1 Answer
0

The issue you're experiencing with Redshift Spectrum truncating the metadata_location parameter for Iceberg tables to 128 characters is not a known or documented limitation of Amazon Redshift. This truncation is preventing Spectrum from properly reading Iceberg metadata files, which explains why you're seeing full sequential scans instead of partition-pruned reads.

This behavior is unexpected and appears to be a bug in Redshift Spectrum's handling of Iceberg tables. The proper functioning of Redshift with Iceberg tables should allow for optimized query plans and reduced file scans during query processing, as mentioned in AWS documentation.

Given the nature of this issue, there are a few steps you can take:

  1. Contact AWS Support: Since this appears to be a bug rather than a known limitation, the best course of action is to open a support case with AWS. Provide them with the details you've shared here, including the query plans, the truncated metadata location, and the performance discrepancy between Athena and Spectrum.

  2. Temporary Workaround: While waiting for a resolution from AWS, you might consider using Athena for these queries if possible, as it seems to be handling the Iceberg metadata correctly.

  3. Check for Updates: Keep an eye on Redshift release notes and patch updates. If this is indeed a bug, it may be addressed in a future release.

  4. Verify Table Properties: Although your table creation looks correct, double-check that all table properties related to Iceberg are properly set and that there are no conflicts or issues with how the table was created or how data is being ingested.

As for a timeline for fixing this issue, that would depend on AWS acknowledging the problem and prioritizing a fix. The best way to get this information would be through the AWS support channel.

In the meantime, continue to monitor your query performance and consider using alternative query methods (like Athena) for critical workloads affected by this issue. Also, keep your Redshift cluster updated to the latest version, as fixes for such issues are often included in regular updates.
Sources
Simplify your query performance diagnostics in Amazon Redshift with Query profiler | AWS Big Data Blog
Achieve the best price-performance in Amazon Redshift with elastic histograms for selectivity estimation | AWS Big Data Blog

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.