npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@icetype/iceberg

v0.3.0

Published

IceType to Apache Iceberg metadata and Parquet schema generation

Downloads

515

Readme

@icetype/iceberg

IceType to Apache Iceberg metadata and Parquet schema generation. This package transforms IceType schemas into Iceberg table metadata and Parquet schemas for data lake applications.

Installation

npm install @icetype/iceberg
# or
pnpm add @icetype/iceberg

Usage

import { parseSchema } from '@icetype/core';
import {
  generateIcebergMetadata,
  generateParquetSchema,
  IcebergAdapter,
} from '@icetype/iceberg';

// Parse an IceType schema
const schema = parseSchema({
  $type: 'User',
  $partitionBy: ['tenantId'],
  id: 'uuid!',
  email: 'string#',
  name: 'string',
  tenantId: 'string!',
  createdAt: 'timestamp!',
});

// Generate Iceberg table metadata
const icebergMetadata = generateIcebergMetadata(
  schema,
  's3://my-bucket/tables/users'
);

// Generate Parquet schema
const parquetSchema = generateParquetSchema(schema);

// Use the adapter for full control
const adapter = new IcebergAdapter();
const metadata = adapter.transform(schema, {
  location: 's3://my-bucket/tables/users',
  properties: {
    'write.format.default': 'parquet',
  },
});

API

Iceberg Functions

| Export | Description | |--------|-------------| | generateIcebergMetadata(schema, location) | Generate Iceberg table metadata | | createIcebergMetadataGenerator() | Create a metadata generator instance | | IcebergMetadataGenerator | Class for Iceberg metadata generation | | IcebergAdapter | Adapter class for registry integration | | createIcebergAdapter() | Factory function for adapter |

Parquet Functions

| Export | Description | |--------|-------------| | generateParquetSchema(schema) | Generate Parquet schema from IceType | | generateParquetSchemaString(schema) | Generate Parquet schema as JSON string | | createParquetSchemaGenerator() | Create a Parquet schema generator | | ParquetSchemaGenerator | Class for Parquet schema generation | | ParquetAdapter | Adapter class for Parquet generation | | documentToParquetRow(doc, schema) | Convert a document to Parquet row format |

Migration Functions

| Export | Description | |--------|-------------| | generateIcebergSchemaUpdate(diff) | Generate Iceberg schema evolution operations | | IcebergMigrationGenerator | Class for schema evolution | | createIcebergMigrationGenerator() | Factory function for migration generator |

Types

| Type | Description | |------|-------------| | IcebergTableMetadata | Full Iceberg table metadata structure | | IcebergSchema | Iceberg schema definition | | IcebergPartitionSpec | Partition specification | | IcebergSortOrder | Sort order specification | | ParquetSchema | Parquet schema definition | | ParquetField | Parquet field definition |

Examples

Basic Iceberg Metadata Generation

import { parseSchema } from '@icetype/core';
import { generateIcebergMetadata } from '@icetype/iceberg';

const schema = parseSchema({
  $type: 'Event',
  $partitionBy: ['eventDate'],
  id: 'uuid!',
  eventType: 'string!',
  eventDate: 'date!',
  payload: 'json',
});

const metadata = generateIcebergMetadata(
  schema,
  's3://data-lake/events'
);

console.log(JSON.stringify(metadata, null, 2));
// {
//   "format-version": 2,
//   "table-uuid": "...",
//   "location": "s3://data-lake/events",
//   "schema": { ... },
//   "partition-spec": [ { "field-id": 1000, "name": "eventDate", ... } ],
//   ...
// }

Parquet Schema Generation

import { parseSchema } from '@icetype/core';
import { generateParquetSchema, generateParquetSchemaString } from '@icetype/iceberg';

const schema = parseSchema({
  $type: 'Product',
  id: 'uuid!',
  name: 'string!',
  price: 'decimal(10,2)!',
  tags: 'string[]',
  metadata: 'json?',
});

// Get schema object
const parquetSchema = generateParquetSchema(schema);

// Get as JSON string
const schemaJson = generateParquetSchemaString(schema);

Using the Adapter with Registry

import { createAdapterRegistry } from '@icetype/adapters';
import { IcebergAdapter, ParquetAdapter } from '@icetype/iceberg';

const registry = createAdapterRegistry();
registry.register(new IcebergAdapter());
registry.register(new ParquetAdapter());

// Use Iceberg adapter
const icebergAdapter = registry.get('iceberg');
const metadata = icebergAdapter?.transform(schema, {
  location: 's3://bucket/tables/users',
});
const json = icebergAdapter?.serialize(metadata);

// Use Parquet adapter
const parquetAdapter = registry.get('parquet');
const parquetSchema = parquetAdapter?.transform(schema);

Schema Evolution

import { diffSchemas, parseSchema } from '@icetype/core';
import { generateIcebergSchemaUpdate } from '@icetype/iceberg';

const oldSchema = parseSchema({
  $type: 'User',
  id: 'uuid!',
  name: 'string!',
});

const newSchema = parseSchema({
  $type: 'User',
  id: 'uuid!',
  name: 'string!',
  email: 'string!',
  createdAt: 'timestamp!',
});

const diff = diffSchemas(oldSchema, newSchema);
const schemaUpdate = generateIcebergSchemaUpdate(diff);

console.log(schemaUpdate.operations);
// [
//   { type: 'add-column', name: 'email', type: 'string', required: true },
//   { type: 'add-column', name: 'createdAt', type: 'timestamptz', required: true }
// ]

Projection Schema Generation

import { parseSchema } from '@icetype/core';
import { generateProjectionSchema } from '@icetype/iceberg';

// Define a schema with projection
const schema = parseSchema({
  $type: 'UserAnalytics',
  $projection: {
    source: 'User',
    fields: ['id', 'email', 'createdAt'],
  },
  id: 'uuid!',
  email: 'string!',
  createdAt: 'timestamp!',
  totalOrders: 'int!',  // Computed field
});

const projection = generateProjectionSchema(schema);

Convert Documents to Parquet Rows

import { documentToParquetRow } from '@icetype/iceberg';

const doc = {
  id: '123e4567-e89b-12d3-a456-426614174000',
  name: 'John Doe',
  age: 30,
  tags: ['developer', 'typescript'],
};

const row = documentToParquetRow(doc, schema);
// Converts to Parquet-compatible format with proper type handling

Type Mappings

| IceType | Iceberg Type | Parquet Type | |---------|-------------|--------------| | string | string | BYTE_ARRAY (UTF8) | | int | int | INT32 | | long | long | INT64 | | float | float | FLOAT | | double | double | DOUBLE | | boolean | boolean | BOOLEAN | | uuid | uuid | FIXED_LEN_BYTE_ARRAY[16] | | timestamp | timestamptz | INT64 (TIMESTAMP_MICROS) | | date | date | INT32 (DATE) | | binary | binary | BYTE_ARRAY | | decimal(p,s) | decimal(p,s) | FIXED_LEN_BYTE_ARRAY | | json | string | BYTE_ARRAY (JSON) |

Documentation

For full documentation, visit the IceType Documentation.

Related Packages

License

MIT