Skip to content

Commit d50e536

Browse files
feat(table_changes): return actual row data from Parquet files
1 parent 3cb8902 commit d50e536

6 files changed

Lines changed: 591 additions & 90 deletions

File tree

src/metadata_provider.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ pub const SQL_TABLE_EXISTS: &str = "SELECT EXISTS(
7070
// Queries for table_changes (CDC) - files added/removed between snapshots
7171

7272
pub const SQL_GET_DATA_FILES_ADDED_BETWEEN_SNAPSHOTS: &str = "
73-
SELECT data.begin_snapshot
73+
SELECT
74+
data.begin_snapshot,
75+
data.path,
76+
data.path_is_relative,
77+
data.file_size_bytes,
78+
data.footer_size
7479
FROM ducklake_data_file AS data
7580
WHERE data.table_id = ?
7681
AND data.begin_snapshot > ?
@@ -293,6 +298,10 @@ impl DuckLakeTableFile {
293298
#[derive(Debug, Clone)]
294299
pub struct DataFileChange {
295300
pub begin_snapshot: i64,
301+
pub path: String,
302+
pub path_is_relative: bool,
303+
pub file_size_bytes: i64,
304+
pub footer_size: Option<i64>,
296305
}
297306

298307
#[derive(Debug, Clone)]

src/metadata_provider_duckdb.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ impl MetadataProvider for DuckdbMetadataProvider {
394394
.query_map(params![table_id, start_snapshot, end_snapshot], |row| {
395395
Ok(DataFileChange {
396396
begin_snapshot: row.get(0)?,
397+
path: row.get(1)?,
398+
path_is_relative: row.get(2)?,
399+
file_size_bytes: row.get(3)?,
400+
footer_size: row.get(4)?,
397401
})
398402
})?
399403
.collect::<Result<Vec<_>, _>>()?;

src/metadata_provider_postgres.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,12 @@ impl MetadataProvider for PostgresMetadataProvider {
495495
) -> Result<Vec<DataFileChange>> {
496496
block_on(async {
497497
let rows = sqlx::query(
498-
"SELECT data.begin_snapshot
498+
"SELECT
499+
data.begin_snapshot,
500+
data.path,
501+
data.path_is_relative,
502+
data.file_size_bytes,
503+
data.footer_size
499504
FROM ducklake_data_file AS data
500505
WHERE data.table_id = $1
501506
AND data.begin_snapshot > $2
@@ -512,6 +517,10 @@ impl MetadataProvider for PostgresMetadataProvider {
512517
.map(|row| {
513518
Ok(DataFileChange {
514519
begin_snapshot: row.try_get(0)?,
520+
path: row.try_get(1)?,
521+
path_is_relative: row.try_get(2)?,
522+
file_size_bytes: row.try_get(3)?,
523+
footer_size: row.try_get(4)?,
515524
})
516525
})
517526
.collect()

0 commit comments

Comments
 (0)