Search docs.molo17.com

    Apache Iceberg glyph Apache Iceberg agent

    Target Apache Iceberg

    Prerequisites

    To have Gluesync writing into your Iceberg tables you will need:

    • A catalog that implements the Iceberg REST catalog specification, reachable over HTTP or HTTPS from Core Hub: for example Apache Polaris, Lakekeeper, Nessie, Unity Catalog, or AWS Glue and Amazon S3 Tables through their Iceberg REST endpoints;

    • Tables stored on Amazon S3 or an S3-compatible object store (MinIO, Cloudflare R2 and the like), reachable from Core Hub: Gluesync writes the data files itself. Azure Data Lake Storage and Google Cloud Storage are not supported in this release;

    • A principal Gluesync signs in to the catalog as, with the access listed in Access the principal needs. Choose one of the supported authentication modes;

    • Credentials for the object store: the ones the catalog vends for each table, static S3 keys, or the default AWS credentials chain of the Core Hub process. See Storage credentials.

    For a walkthrough from a PostgreSQL table to an Iceberg table, with the failures you are likely to meet, follow Replicate PostgreSQL to Apache Iceberg end to end.

    Authentication

    The Authentication mode field selects how Gluesync authenticates its requests to the catalog. The Client ID, username or AWS access key ID and Client secret, bearer token, password or AWS secret access key fields take a different value in each mode:

    Method Authentication mode Client ID, username or AWS access key ID Client secret, bearer token, password or AWS secret access key

    OAuth2 client credentials

    OAUTH2 (default)

    The client ID. Leave it empty for a catalog whose credential is a secret alone.

    The client secret.

    Bearer token

    BEARER_TOKEN

    Not used.

    The token, sent as it is. Gluesync does not renew it: when it expires or is revoked, replace it.

    Basic authentication

    BASIC

    The user name.

    The password.

    AWS Signature Version 4

    SIGV4

    The AWS access key ID. Leave it and the secret empty to use the default AWS credentials chain of the Core Hub process (environment variables, instance or pod role).

    The AWS secret access key.

    None

    NONE

    Not used.

    Not used.

    With OAUTH2, Gluesync requests a token with the client credentials grant and renews it before it expires. The token is requested from the catalog’s own token endpoint unless OAuth2 token endpoint names the one of your identity provider, and with the scope in OAuth2 scope when you set one (for example PRINCIPAL_ROLE:ALL on Apache Polaris).

    With SIGV4, every request to the catalog is signed for the region in SigV4 signing region, which is required, and the service in SigV4 signing name: glue, the default, for the AWS Glue Iceberg REST endpoint, s3tables for Amazon S3 Tables.

    Storage credentials

    Gluesync writes the Parquet data files and the delete files of a table to its location, on S3 or an S3-compatible store. The Storage credentials field selects the credentials it writes them with:

    Storage credentials What Gluesync uses

    VENDED_CREDENTIALS (default)

    The temporary credentials the catalog hands out for each table. Gluesync asks for them when it loads the table. The catalog must support credential vending.

    STATIC_KEYS

    The S3 access key ID and the S3 secret access key you enter. Both are required.

    DEFAULT_CHAIN

    The default AWS credentials chain of the Core Hub process: environment variables, the instance profile or the pod role.

    For an S3-compatible store, set S3 endpoint to its URL and, when it serves buckets under a path and not as host names, turn on S3 path-style access. S3 region is the region of the buckets; an S3-compatible store that has none is given us-east-1.

    Access the principal needs

    On the catalog, the principal needs to:

    • List the namespaces and the tables of the namespaces the entities are written to;

    • Load and commit the tables it writes;

    • Create namespaces and tables, only if Gluesync creates the target tables.

    On the object store, the credentials need to read, write and delete objects under the location of each table.

    Setup via Web UI

    • REST catalog URL (https://...) (host): the URL of the catalog, with its scheme and path, for example https://polaris.example.com/api/catalog. Without a scheme it is read as https://;

    • Port (port): default 443. Used only when the URL carries no port and it is not the default one of its scheme. On an http:// URL the default 443 is ignored: write the port in the URL when the catalog serves HTTP on it;

    • Authentication mode (authMode): OAUTH2 (default), BEARER_TOKEN, BASIC, SIGV4 or NONE. See Authentication for the values each mode takes. The form shows only the fields of the selected mode;

    • Client ID, username or AWS access key ID (username) and Client secret, bearer token, password or AWS secret access key (password): as described in Authentication;

    • Warehouse (name or location) (warehouse): optional. The warehouse the catalog is asked for, when it serves more than one;

    • With OAUTH2 only:

      • OAuth2 token endpoint (https://...) (oauth2ServerUri): optional. Empty uses the token endpoint of the catalog;

      • OAuth2 scope (oauth2Scope): optional;

    • With SIGV4 only:

      • SigV4 signing region (sigV4Region): the AWS region of the catalog endpoint. Required;

      • SigV4 signing name (sigV4SigningName): default glue. s3tables for Amazon S3 Tables;

    • Storage credentials (storageAccess): VENDED_CREDENTIALS (default), STATIC_KEYS or DEFAULT_CHAIN. See Storage credentials;

    • S3 endpoint (S3-compatible stores only) (s3Endpoint): optional. The URL of an S3-compatible store, for example https://minio.example.com:9000. Empty for Amazon S3;

    • S3 region (s3Region): optional;

    • S3 access key ID (s3AccessKeyId) and S3 secret access key (s3SecretAccessKey): with STATIC_KEYS only, and required then;

    • S3 path-style access (s3PathStyleAccess): default false;

    • Additional catalog properties (key=value, one per line) (additionalProperties): optional. Properties of the Iceberg REST catalog client that no field covers, one key=value per line, for example a request header as header.X-Tenant=acme. Empty lines and lines that start with # are skipped. They are applied last, so they override what the fields set. Do not put secrets here: this field is not masked when the connection is read back, so a property whose name says it carries one (token, credential, secret, password, api-key, access-key, private-key, authorization) is refused. Use the credentials fields above instead. The Control Plane shows this field on a single line, so it takes one property there; a connection created through the REST API takes several, one per line.

    The connection check authenticates to the catalog and lists its top-level namespaces. The storage credentials are first used when a table is written.

    Specific configuration

    • Disable truncate before snapshot (disableTruncateOnSnapshot): default false. See Snapshots.

    Per entity:

    • Target data file size in MB (targetFileSizeMb): default 128. A batch larger than this size is written as several data files.

    Schemas, tables and keys

    A Gluesync schema is an Iceberg namespace. A nested namespace is written with its levels joined by a dot, for example sales.emea.

    Tables of format version 2 and 3 that store Parquet or Avro files are written; a table set to write ORC files is refused. Gluesync creates tables in format version 2, or 3 when a column is a nanosecond timestamp.

    The key of an entity is the one the entity declares, otherwise the identifier fields of the table. Iceberg does not enforce a key: Gluesync uses it to find the row an update or a delete changes, so an entity needs one for its updates and deletes. Without a key, on a table that has no identifier fields, every inserted row is added and an update or a delete is refused.

    An entity with a key is checked at its first write, and before a snapshot empties the table, and is refused with a message that says what to change when:

    • The table is partitioned and a partition column is not part of the key. A row is updated and deleted within its partition;

    • The table is of format version 1, which has no row-level deletes;

    • A key column is a uuid or a fixed. Readers built on the Iceberg library do not apply a row-level delete on a key of those types to every row, so updates and deletes would leave rows behind. Use a string column for the key, which is what Gluesync creates for a UUID of the source, or a binary one. A uuid or fixed column outside the key is written as any other;

    • The partition spec of the table was changed and the table still holds data files written under the earlier one. The rows of those files cannot be updated or deleted under the new spec: rewrite the data files into the current spec (the rewrite_data_files procedure of Apache Spark, for example), then start the entity again. A snapshot that empties the table needs no rewrite.

    Writes

    Every batch is written as data files and delete files, added to the table by one atomic commit: a reader sees the whole batch or none of it.

    • Inserts and updates replace the row by its key, with merge-on-read row-level deletes: an equality delete on the key removes the row the table held, and the new row is written to a data file. Rows are matched on the key they had before the change, so an update that changes the key moves the row instead of inserting a second one;

    • Deletes are equality deletes on the key;

    • A row changed more than once in the same batch is resolved inside the batch, with position deletes or, on a format version 3 table, deletion vectors: the last change of a row is always the one left on the table;

    • Truncate: one commit that removes every row of the primary table of the entity.

    A batch replayed after a restart from the last confirmed transaction leaves the table as it was.

    Iceberg enforces no primary key, so an insert never fails on a duplicate: the insert conflict strategy has no effect on this target.

    The target writes whole rows. It needs the full row image from the source, and the write policies that leave a column out of a write, such as writing the changed columns only, are not available on this target. For the same reason, map every column of the table: a column the entity does not map is written as null in every row the entity inserts or updates, and Gluesync warns of it once in its log.

    One commit at a time is made to a table by an entity: the snapshot of an entity is not written by concurrent writers.

    Snapshots

    How a snapshot is written depends on its write method:

    • INSERT: the table of the entity is emptied first, unless Disable truncate before snapshot is set, and the rows are appended. No delete files are written, which is the fastest to load and to read;

    • UPSERT: nothing is emptied, and every row replaces the one with its key.

    A snapshot that resumes after a stop, one in which a write failed or a read of the source was retried, one read in partitions and one whose entity drops rows with a filter or a mapping function replace rows by key from then on whatever their write method, so a row is never left twice.

    When the target entity has a snapshot delete filter, only the rows it matches are removed before the snapshot, by their key, and the snapshot replaces rows by key. Every clause of the filter has to hold. A filter by regular expression, or on a binary, fixed, struct, list or map column, cannot be applied to an Iceberg table: the snapshot is refused with an error that names the column.

    For an entity mapped to several tables, the primary table is the one emptied, and the snapshot replaces rows by key.

    Tables Gluesync generates

    Iceberg has no DDL of its own. The statement the UI previews has a first line that names the table, followed by the definition of the table as JSON, in the form of the Iceberg specification:

    CREATE TABLE `sales`.`orders` USING iceberg
    {
        "schema": {
            "type": "struct",
            "schema-id": 0,
            "identifier-field-ids": [1],
            "fields": [
                {"id": 1, "name": "id", "required": true, "type": "long"},
                {"id": 2, "name": "customer", "required": false, "type": "string"},
                {"id": 3, "name": "amount", "required": false, "type": "decimal(12, 2)"}
            ]
        },
        "properties": {
            "format-version": "2",
            "write.delete.mode": "merge-on-read",
            "write.update.mode": "merge-on-read",
            "write.merge.mode": "merge-on-read",
            "gluesync.managed": "true"
        }
    }
    • The key columns become the identifier fields of the table. They are required, and a float or double key column is left out of them, as Iceberg does not accept it: its key is then kept by the entity only. Schema discovery reads the identifier fields back, so the key is found again when an entity is mapped onto the table;

    • The table is created in format version 2 (3 when it has a nanosecond timestamp column) with merge-on-read row-level operations, and the property gluesync.managed;

    • A table that already exists is left as it is. Through the REST API, a namespace that does not exist is created with the table. In the Control Plane, Target Namespace lists the namespaces of the catalog and is disabled while the catalog has none: create the namespace first, as in Replicate PostgreSQL to Apache Iceberg end to end.

    The Control Plane shows the statement read-only. To partition the table or set a table property, either create the table in the catalog before you map the entity (with every partition column in the key) and select it, or send an edited statement through the REST API (PUT /pipelines/{pipelineId}/config/entities/statements/create-table). To partition orders in four buckets of its key, add a partition-spec next to schema:

    "partition-spec": {"spec-id": 0, "fields": [{"name": "id_bucket", "transform": "bucket[4]", "source-id": 1, "field-id": 1000}]}

    Tables you create

    Any Iceberg table of the catalog can be a target. Namespaces, tables and columns are read from the catalog; a column is a key when it is an identifier field of the table, otherwise the key comes from the entity mapping.

    Columns are mapped explicitly: a column the change carries and the table lacks fails the write instead of being added, and a required column that gets no value fails the row.

    Table maintenance

    A table written with merge-on-read row-level deletes collects small data files and delete files as changes arrive, and every commit adds a snapshot. Gluesync does not compact tables or expire their snapshots. Run the table maintenance of Iceberg on a schedule: compaction (rewriting data files), snapshot expiration and orphan file removal, with the managed maintenance of your catalog or with the procedures of an engine such as Apache Spark or Trino.

    When a commit is refused, for instance on a conflict with another writer, Gluesync deletes the files it wrote for it. After any other failure, such as a lost connection or a catalog that cannot say whether the commit went through, the files are left in place, since they may be part of the table: orphan file removal collects the ones that are not.

    Data types

    Every value is converted to the type of its column. A value that does not fit, such as a number too large for an int or with more digits than the precision of a decimal, fails the row with a message that names the column. Extra decimal digits are rounded half up.

    Gluesync type Default Iceberg type Notes

    SHORT

    int

    Iceberg has no 16-bit integer.

    INT

    int

    LONG

    long

    FLOAT

    float

    DOUBLE

    double

    BIG_DECIMAL

    decimal(p, s)

    A decimal wider than the 38 digits Iceberg allows is created as a string, and written in plain notation, never scientific.

    BOOLEAN

    boolean

    STRING

    string

    Alternatives: uuid, from the text of the UUID, and struct, from a JSON object.

    BYTE_ARRAY

    binary

    Alternative: fixed. The value must have exactly the length of the column.

    LOCAL_DATE

    date

    LOCAL_TIME

    time

    OFFSET_TIME

    time

    Iceberg has no time with a zone: the UTC time of day is written. The same holds for any value with an offset written to a date, time or timestamp column: its UTC reading is stored.

    LOCAL_DATE_TIME

    timestamp

    Alternative: timestamp_ns. A table Gluesync generates with a nanosecond column is created at format version 3, the first that has the type.

    OFFSET_DATE_TIME

    timestamptz

    Alternative: timestamptz_ns, with the same rule on the format version. Stored in UTC.

    ARRAY

    list

    A generated table takes the element type of the source array when Iceberg holds it without loss (int, long, float, double, boolean), otherwise list<string>.

    MAP

    map<string, string>

    Setup via Rest APIs

    Here following an example of calling the Core Hub’s Rest API via curl to setup the connection for this Agent.

    Connect the agent

    curl --location --request PUT 'http://core-hub-ip-address/pipelines/{pipelineId}/agents/{agentId}/config/credentials' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: ••••••' \
    --data '{
            "hostCredentials": {
            "connectionName": "myAgentNickName",
            "host": "https://polaris.example.com/api/catalog",
            "port": 443,
            "username": "",
            "password": ""
          },
          "customHostCredentials": {
            "authMode": "OAUTH2",
            "warehouse": "lake",
            "oauth2ServerUri": "",
            "oauth2Scope": "PRINCIPAL_ROLE:ALL",
            "storageAccess": "VENDED_CREDENTIALS",
            "s3Endpoint": "",
            "s3Region": "",
            "s3PathStyleAccess": false,
            "additionalProperties": ""
          }
    }'

    authMode is OAUTH2, BEARER_TOKEN, BASIC, SIGV4 or NONE. With OAUTH2, username is the client ID and password the client secret; with BEARER_TOKEN, password is the token; with SIGV4, add sigV4Region and, for a service other than glue, sigV4SigningName. storageAccess is VENDED_CREDENTIALS, STATIC_KEYS, which also takes s3AccessKeyId and s3SecretAccessKey, or DEFAULT_CHAIN.

    Not covered in this release

    • Apache Iceberg as a source;

    • Tables on Azure Data Lake Storage or Google Cloud Storage;

    • Schema evolution;

    • Query Studio and data comparison on this agent;

    • Table maintenance (compaction, snapshot expiration), see Table maintenance.