Showing posts with label 222 )in medallion arch a invoice is shared as a pdf with tables .... do we save it as pdf only how to read that data later ?. Show all posts
Showing posts with label 222 )in medallion arch a invoice is shared as a pdf with tables .... do we save it as pdf only how to read that data later ?. Show all posts

Sunday, August 23, 2026

222 )in medallion arch a invoice is shared as a pdf with tables .... do we save it as pdf only how to read that data later ?

 222 )in medallion arch a invoice is shared as a pdf with tables

how the file is read in bronze and how it is saved to relational tables in bronze to gold

do we save it as pdf only

how to read that data later ?


In a Medallion Architecture (Bronze $\rightarrow$ Silver $\rightarrow$ Gold), you do not just save the raw PDF. Instead, you follow a path that preserves the original file for auditing while transforming its text and tables into structured, queryable relational tables.

The Medallion Strategy for PDFs

  1. Bronze Layer (Raw): Save the raw PDF file to cloud object storage. In your Bronze table, store a record containing the file path/URL, ingestion timestamp, and raw extracted text or JSON (if parsed).

  2. Silver Layer (Cleaned & Structured): Parse the PDF tables using Python libraries (like pdfplumber) or AI tools, clean the data types, handle missing values, and save it as a structured Delta/Parquet/Relational table.

  3. Gold Layer (Business Ready): Aggregate and model the data into clean dimensional tables (e.g., fact_invoices, dim_vendors) for reporting and dashboards.

Option A: Steps for Azure / Microsoft Fabric

  1. Bronze (Ingestion):

    • Drop the PDF into an Azure Data Lake Storage (ADLS Gen2) container or a Fabric Lakehouse Files section (Files/invoices/).

    • Create a Bronze table (bronze_invoices) using Spark that logs the file path and metadata.

  2. Silver (Processing):

    • Write a PySpark notebook in Fabric/Synapse using a library like pdfplumber or Azure Document Intelligence to extract the table rows from the PDF.

    • Convert the extracted rows into a Spark DataFrame.

    • Save this as a clean Delta table (silver_invoices).

  3. Gold (Business Modeling):

    • Write SQL transformations in Fabric to join silver_invoices with customer or product dimensions, outputting final Gold tables (gold_invoice_summary).

Option B: Steps for Snowflake

  1. Bronze (Ingestion):

    • Upload the PDF to a Snowflake Internal or External Stage (e.g., an S3 bucket linked to Snowflake).

    • Create a Bronze table containing the file path and metadata (you can use Snowflake's directory tables or a simple table listing file paths).

  2. Silver (Processing):

    • Use Snowpark (Python) inside Snowflake with pdfplumber (via Anaconda packages in Snowflake) to read the PDF from the stage, extract the table text, and parse it.

    • Alternatively, use Snowflake Document AI to extract the fields.

    • Save the parsed output into a standard Snowflake relational table (silver_invoices).

  3. Gold (Business Modeling):

    • Run standard SQL queries in Snowflake to clean, join, and insert the data into Gold-layer dimension and fact tables.

How Do You Read That Data Later?

Once the data reaches the Silver or Gold layers, you no longer read the PDF.

  • Because the tables were extracted and saved into relational rows and columns during the Silver step, business users and BI tools (like Power BI or Tableau) can query the invoice data instantly using standard SQL:

    SQL
    SELECT invoice_id, vendor_name, total_amount 
    FROM gold_invoices 
    WHERE invoice_date >= '2026-01-01';
    
  • If a user ever needs to see the original visual invoice, your application can use the file path stored in the metadata to fetch the exact PDF from cloud storage.

239 ) Metadata Management

Metadata Management and Modern Data Governance Tools Metadata management forms the backbone of data governance, data lineage, and data quali...