Skip to content

Commit bcaef03

Browse files
committed
Rename IcebergMetadata to TableMetadata
1 parent b8258a0 commit bcaef03

File tree

4 files changed

+51
-25
lines changed

4 files changed

+51
-25
lines changed

src/iceberg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ export { avroData } from './avro.data.js'
1313
* Reads data from the Iceberg table with optional row-level delete processing.
1414
* Row indices are zero-based and rowEnd is exclusive.
1515
*
16-
* @import {IcebergMetadata, Schema} from '../src/types.js'
16+
* @import {TableMetadata, Schema} from '../src/types.js'
1717
* @param {object} options
1818
* @param {string} options.tableUrl - Base S3 URL of the table.
1919
* @param {number} [options.rowStart] - The starting global row index to fetch (inclusive).
2020
* @param {number} [options.rowEnd] - The ending global row index to fetch (exclusive).
2121
* @param {string} [options.metadataFileName] - Name of the Iceberg metadata file.
22-
* @param {IcebergMetadata} [options.metadata] - Pre-fetched Iceberg metadata.
22+
* @param {TableMetadata} [options.metadata] - Pre-fetched Iceberg metadata.
2323
* @param {RequestInit} [options.requestInit] - Optional fetch request initialization.
2424
* @returns {Promise<Array<Record<string, any>>>} Array of data records.
2525
*/

src/iceberg.manifest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { fetchAvroRecords } from './iceberg.fetch.js'
33
/**
44
* Returns manifest entries for the current snapshot.
55
*
6-
* @import {IcebergMetadata, Manifest, ManifestEntry} from '../src/types.js'
6+
* @import {TableMetadata, Manifest, ManifestEntry} from '../src/types.js'
77
* @typedef {{ url: string, entries: ManifestEntry[] }[]} ManifestList
8-
* @param {IcebergMetadata} metadata
8+
* @param {TableMetadata} metadata
99
* @param {RequestInit} [requestInit]
1010
* @returns {Promise<ManifestList>}
1111
*/

src/iceberg.metadata.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ export function icebergListVersions({ tableUrl, requestInit }) {
8282
* Fetches the iceberg table metadata.
8383
* If metadataFileName is not provided, uses icebergLatestVersion to get the version hint.
8484
*
85-
* @import {IcebergMetadata} from '../src/types.js'
85+
* @import {TableMetadata} from '../src/types.js'
8686
* @param {object} options
8787
* @param {string} options.tableUrl - Base URL of the table (e.g. "s3://my-bucket/path/to/table")
8888
* @param {string} [options.metadataFileName] - Name of the metadata JSON file
8989
* @param {RequestInit} [options.requestInit] - Optional fetch request initialization
90-
* @returns {Promise<IcebergMetadata>} The table metadata as a JSON object
90+
* @returns {Promise<TableMetadata>} The table metadata as a JSON object
9191
*/
9292
export async function icebergMetadata({ tableUrl, metadataFileName, requestInit }) {
9393
if (!metadataFileName) {

src/types.d.ts

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
export interface IcebergMetadata {
2+
export interface TableMetadata {
33
'format-version': number
44
'table-uuid': string
55
location: string
@@ -11,31 +11,34 @@ export interface IcebergMetadata {
1111
'default-spec-id': number
1212
'partition-specs': PartitionSpec[]
1313
'last-partition-id': number
14-
'default-sort-order-id': number
15-
'sort-orders': SortOrder[]
16-
properties: object
14+
properties: Record<string, string>
1715
'current-snapshot-id': number
18-
refs: object
1916
snapshots: Snapshot[]
20-
statistics: TableStatistics[]
2117
'snapshot-log': SnapshotLog[]
2218
'metadata-log': MetadataLog[]
19+
'sort-orders': SortOrder[]
20+
'default-sort-order-id': number
21+
refs: object
22+
statistics: TableStatistics[]
23+
'partition-statistics'?: PartitionStatistics[]
24+
'next-row-id'?: bigint
2325
}
2426

2527
export interface Schema {
26-
type: string
28+
type: 'struct'
2729
'schema-id': number
30+
'identifier-field-ids'?: number[]
2831
fields: Field[]
2932
}
3033

3134
interface Field {
3235
id: number
3336
name: string
3437
required: boolean
35-
type: string
38+
type: string // TODO
3639
doc?: string
37-
'initial-default': string
38-
'write-default': string
40+
'initial-default': any
41+
'write-default': any
3942
}
4043

4144
export interface PartitionSpec {
@@ -56,20 +59,34 @@ export type PartitionTransform =
5659
'year' |
5760
'month' |
5861
'day' |
59-
'hour'
62+
'hour' |
63+
'void'
64+
interface PartitionStatistics {
65+
'snapshot-id': bigint
66+
'statistics-path': string
67+
'file-size-in-bytes': bigint
68+
}
6069

6170
interface SortOrder {
6271
'order-id': number
63-
'fields': unknown[]
72+
'fields': SortField[]
73+
}
74+
interface SortField {
75+
transform: string
76+
'source-id'?: number
77+
'source-ids'?: number[] // V3
78+
'direction': 'asc' | 'desc'
79+
'null-order': 'nulls-first' | 'nulls-last'
6480
}
6581

6682
export interface Snapshot {
67-
'sequence-number': number
6883
'snapshot-id': number
84+
'parent-snapshot-id'?: number
85+
'sequence-number': number
6986
'timestamp-ms': number
7087
summary: {
7188
operation: string
72-
'spark.app.id': string
89+
// 'spark.app.id'?: string
7390
'added-data-files': string
7491
'added-records': string
7592
'added-files-size': string
@@ -111,13 +128,15 @@ export interface Manifest {
111128
sequence_number?: bigint
112129
min_sequence_number?: bigint
113130
added_snapshot_id: bigint
114-
added_data_files_count: number
115-
existing_data_files_count: number
116-
deleted_data_files_count: number
131+
added_files_count: number
132+
existing_files_count: number
133+
deleted_files_count: number
117134
added_rows_count: bigint
118135
existing_rows_count: bigint
119136
deleted_rows_count: bigint
120137
partitions?: FieldSummary[]
138+
// key_metadata?: unknown
139+
first_row_id?: bigint
121140
}
122141

123142
export interface ManifestEntry {
@@ -130,18 +149,25 @@ export interface ManifestEntry {
130149

131150
interface FieldSummary {
132151
'contains-null': boolean
152+
'contains-nan'?: boolean
153+
'lower-bound'?: unknown
154+
'upper-bound'?: unknown
133155
}
134156

135157
export interface DataFile {
136158
content: 0 | 1 | 2 // 0=data, 1=position_delete, 2=equality_delete
137159
file_path: string
138160
file_format: string
139-
partition: Record<number, PartitionSpec> // indexed by field id
161+
partition: Record<number, unknown> // indexed by field id
140162
record_count: bigint
141163
file_size_in_bytes: bigint
142164
split_offsets: bigint[]
143165
equality_ids?: number[]
144-
sort_order_id: number
166+
sort_order_id?: number
167+
first_row_id?: bigint
168+
referenced_data_file?: string
169+
content_offset?: bigint
170+
content_size_in_bytes?: bigint
145171
}
146172

147173
export interface FilePositionDelete {

0 commit comments

Comments
 (0)