# <img className="page-icon" src="/img/icons/iceberg.svg" alt="" /> Import: Iceberg

Creates a data contract from an [Apache Iceberg](https://iceberg.apache.org/) table schema.

## Import from a REST catalog

```bash
datacontract import iceberg \
  --catalog-url https://polaris.example.com/api/catalog \
  --catalog main --namespace sales --table orders \
  --output datacontract.yaml
```

The result includes a server ready for `datacontract test`. `--catalog` defaults to `default`; a qualified `--table sales.orders` also works without `--namespace`. See [testing Iceberg](../testing/iceberg.md) for authentication and [Amazon S3 Tables](../testing/s3-tables.md) for the AWS endpoint, SSO, and required warehouse ARN.

## Import from a schema file

A schema-file import does not add a server. Add one before testing live data.

{/* AUTOGENERATED EXAMPLE: do not edit by hand; regenerate with the update script. */}

Given this [`orders.json`](https://github.com/datacontract/datacontract-cli/blob/main/examples/imports/iceberg/orders.json):

```json
{
  "type": "struct",
  "fields": [
    { "id": 1, "name": "order_id", "type": "string", "required": true },
    { "id": 2, "name": "order_timestamp", "type": "timestamptz", "required": true },
    { "id": 3, "name": "customer_id", "type": "string", "required": true },
    { "id": 4, "name": "order_total", "type": "long", "required": true },
    { "id": 5, "name": "status", "type": "string", "required": true }
  ],
  "schema-id": 0,
  "identifier-field-ids": [1]
}
```

Run:

```bash
datacontract import iceberg --source orders.json
```

to produce the data contract:

```yaml
version: 1.0.0
kind: DataContract
apiVersion: v3.2.0
id: my-data-contract
name: My Data Contract
status: draft
schema:
- name: iceberg_table
  physicalType: table
  logicalType: object
  physicalName: iceberg_table
  properties:
  - name: order_id
    physicalType: string
    customProperties:
    - property: icebergFieldId
      value: 1
    primaryKey: true
    primaryKeyPosition: 1
    logicalType: string
    required: true
  - name: order_timestamp
    physicalType: timestamptz
    customProperties:
    - property: icebergFieldId
      value: 2
    logicalType: timestamp
    required: true
  - name: customer_id
    physicalType: string
    customProperties:
    - property: icebergFieldId
      value: 3
    logicalType: string
# …
```

{/* END AUTOGENERATED EXAMPLE */}

All options: **[`datacontract import iceberg`](../commands/import/iceberg.md)**.
