All skills
aws avatar

/ingesting-into-data-lake

@b33847d

Import data into the AWS data lake from S3 files, local uploads, JDBC databases (Oracle, SQL Server, PostgreSQL, MySQL, RDS, Aurora), Amazon Redshift, Snowflake, BigQuery, DynamoDB, or existing Glue catalog tables (migration). Default target is S3 Tables; standard Iceberg on a general purpose bucket is supported where S3 Tables is not adopted. Handles one-time loads, recurring pipelines, migrations. Triggers on: import data, load data, ingest, sync database, migrate table, move data to AWS, set up pipeline, ETL, pull from Snowflake, query BigQuery into S3, export DynamoDB, CTAS, convert to Iceberg. Do NOT use for setting up or troubleshooting Glue connections (use connecting-to-data-source), creating empty tables (use creating-data-lake-table), running queries (use querying-data-lake), finding tables by fuzzy name (use finding-data-lake-assets), catalog audit (use exploring-data-catalog), or SaaS platforms like Salesforce, ServiceNow, SAP, MongoDB, Kafka.

Use this Skill: https://skilld.dev/gh/aws/agent-toolkit-for-aws/ingesting-into-data-lake

This session only. Nothing lands on disk.

referencesjdbc-ingest.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

JDBC Database Ingest

Move data from a JDBC source (Oracle, SQL Server, PostgreSQL, MySQL, RDS, Aurora, Redshift) into the data lake. Assumes a Glue connection exists. If it doesn't, delegate to the connecting-to-data-source skill first.

Contents

Prerequisites

  • A tested Glue connection (created via connecting-to-data-source skill)
  • Source table name, schema, and optional filter SQL
  • Target table (existing or to be created via creating-data-lake-table skill)
  • Target format decided (default S3 Tables; see iceberg-catalog-config-and-usage.md)

Workflow

1. Confirm connection exists

aws glue get-connection --name <CONNECTION_NAME> --region <REGION>

If the connection does not exist, stop and delegate to connecting-to-data-source.

2. Identify source scope

Ask the user which tables, views, or custom SQL query. See jdbc-schema-discovery.md for crawler-based discovery, direct schema inspection, and custom SQL patterns.

3. Decide load strategy

Intent Strategy Reference
One-time full load Full scan, write once glue-job-scripts.md full-refresh template
Recurring, append-only (events, logs) Incremental append with watermark incremental-loading.md
Recurring, mutable (customers, products) Incremental upsert with MERGE incremental-loading.md
Small dimension Full refresh via createOrReplace() glue-job-scripts.md

4. Create target table if needed

If the target table doesn't exist, delegate to creating-data-lake-table. Never create it inline.

5. Build the Glue 5.1 or higher job

Use the PySpark templates in glue-job-scripts.md and the job config guidance in glue-job-config.md.

Reference the Glue connection via job Connections property:

"Connections": {"Connections": ["<CONNECTION_NAME>"]}

In the script, read via connection name -- no credentials in code:

source_df = glueContext.create_dynamic_frame.from_options(
    connection_type="jdbc",
    connection_options={
        "useConnectionProperties": "true",
        "connectionName": args['connection_name'],
        "dbtable": args['source_table']
    }
).toDF()

6. Test, validate, schedule

Parallel Reads

For large tables, read in parallel via Spark partitioning on a numeric column:

jdbc_conf = glueContext.extract_jdbc_conf(args['connection_name'])

source_df = spark.read.format("jdbc").options(
    url=jdbc_conf["url"],
    user=jdbc_conf["user"],
    password=jdbc_conf["password"],
    dbtable="<SCHEMA>.<TABLE>",
    numPartitions=10,
    partitionColumn="<numeric_column>",
    lowerBound=1,
    upperBound="<max_value>"
).load()

Best practices:

  • Use a numeric column with even distribution for partitionColumn
  • Set numPartitions = number of Glue workers × 2
  • Ensure lowerBound/upperBound cover actual data range
  • Source database must handle concurrent connections

Retrieve credentials from the connection at runtime rather than hardcoding. See connecting-to-data-source credential-security.md for IAM DB auth and Secrets Manager patterns.

Type Mapping

Source-to-Iceberg type mappings for ingest. Apply via .cast() or column aliases in the Glue script.

Oracle

Oracle Iceberg Notes
VARCHAR2, CHAR STRING
NUMBER(p,s) DECIMAL(p,s)
NUMBER (no scale) BIGINT For integer values
DATE TIMESTAMP Oracle DATE includes time
TIMESTAMP TIMESTAMP
CLOB STRING
BLOB BINARY

SQL Server

SQL Server Iceberg Notes
VARCHAR, NVARCHAR, CHAR STRING
INT, SMALLINT INTEGER
BIGINT BIGINT
DECIMAL, NUMERIC DECIMAL(p,s)
FLOAT, REAL DOUBLE
BIT BOOLEAN
DATE DATE
DATETIME, DATETIME2 TIMESTAMP

PostgreSQL

PostgreSQL Iceberg Notes
VARCHAR, TEXT STRING
INTEGER, SMALLINT INTEGER
BIGINT BIGINT
NUMERIC, DECIMAL DECIMAL(p,s)
REAL FLOAT
DOUBLE PRECISION DOUBLE
BOOLEAN BOOLEAN
DATE DATE
TIMESTAMP, TIMESTAMPTZ TIMESTAMP
JSON, JSONB STRING Parse in Spark if needed
UUID STRING

MySQL

MySQL Iceberg Notes
VARCHAR, CHAR, TEXT STRING
INT, SMALLINT, TINYINT INTEGER TINYINT(1) is BOOLEAN
BIGINT BIGINT
DECIMAL DECIMAL(p,s)
FLOAT FLOAT
DOUBLE DOUBLE
DATE DATE
DATETIME, TIMESTAMP TIMESTAMP
JSON STRING

Redshift

Same as PostgreSQL mappings. Redshift-specific additions:

  • SUPER -> STRING (serialize) or STRUCT (parse)
  • GEOMETRY / GEOGRAPHY -> BINARY or STRING

Connection Errors

If the Glue job fails with a connection-related error (timeout, auth failure, driver not found, SSL handshake), delegate to connecting-to-data-source for troubleshooting. Do not attempt network or credential fixes in this skill.

See connecting-to-data-source troubleshooting.md.

Source: SKILL.md on GitHub

2 warnings17d3 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill facilitates the ingestion of data from various external sources into an AWS data lake. It contains security considerations related to the processing of untrusted data and the dynamic generation of Spark scripts, which are characteristic of ETL (Extract, Transform, Load) operations. These patterns are consistent with the skill's purpose and are used within a managed cloud environment.

  • Socket17d

    1 alert: gptAnomaly

  • Snyk17d

    Risk: MEDIUM · 1 issue

Signed by skilld at b33847d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
Other metadata
metadata
{
  "version": "1",
  "argument-hint": "'[source-path|connection-name|table-name] [--target s3-tables|iceberg|parquet]'"
}

README badge

README badge for aws/agent-toolkit-for-aws/ingesting-into-data-lake