Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"location":"file://data/persistent/map_stats/default.db/map_stats","table-uuid":"37480ce7-8f2b-4184-9371-52b052402404","last-updated-ms":1772697863019,"last-column-id":6,"schemas":[{"type":"struct","fields":[{"id":1,"name":"timestamp","type":"timestamptz","required":false},{"id":2,"name":"input","type":"string","required":false},{"id":3,"name":"output","type":"string","required":false},{"id":4,"name":"metadata","type":{"type":"map","key-id":5,"key":"string","value-id":6,"value":"string","value-required":false},"required":false}],"schema-id":0,"identifier-field-ids":[]}],"current-schema-id":0,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"field-id":1000,"transform":"day","name":"_day"}]}],"default-spec-id":0,"last-partition-id":1000,"properties":{},"snapshots":[],"snapshot-log":[],"metadata-log":[],"sort-orders":[{"order-id":0,"fields":[]}],"default-sort-order-id":0,"refs":{},"statistics":[],"format-version":2,"last-sequence-number":0}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"location":"file://data/persistent/map_stats/default.db/map_stats","table-uuid":"37480ce7-8f2b-4184-9371-52b052402404","last-updated-ms":1772697863587,"last-column-id":6,"schemas":[{"type":"struct","fields":[{"id":1,"name":"timestamp","type":"timestamptz","required":false},{"id":2,"name":"input","type":"string","required":false},{"id":3,"name":"output","type":"string","required":false},{"id":4,"name":"metadata","type":{"type":"map","key-id":5,"key":"string","value-id":6,"value":"string","value-required":false},"required":false}],"schema-id":0,"identifier-field-ids":[]}],"current-schema-id":0,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"field-id":1000,"transform":"day","name":"_day"}]}],"default-spec-id":0,"last-partition-id":1000,"properties":{},"current-snapshot-id":8792170059756986233,"snapshots":[{"snapshot-id":8792170059756986233,"sequence-number":1,"timestamp-ms":1772697863587,"manifest-list":"file://data/persistent/map_stats/default.db/map_stats/metadata/snap-8792170059756986233-0-8ed9efb3-5eb4-4225-a66a-2b6b46cb4d32.avro","summary":{"operation":"append","added-files-size":"2260","added-data-files":"1","added-records":"1","changed-partition-count":"1","total-data-files":"1","total-delete-files":"0","total-records":"1","total-files-size":"2260","total-position-deletes":"0","total-equality-deletes":"0"},"schema-id":0}],"snapshot-log":[{"snapshot-id":8792170059756986233,"timestamp-ms":1772697863587}],"metadata-log":[{"metadata-file":"file://data/persistent/map_stats/default.db/map_stats/metadata/00000-e5eddfa2-1468-4e06-bb1d-bb443e4dd618.metadata.json","timestamp-ms":1772697863019}],"sort-orders":[{"order-id":0,"fields":[]}],"default-sort-order-id":0,"refs":{"main":{"snapshot-id":8792170059756986233,"type":"branch"}},"statistics":[],"format-version":2,"last-sequence-number":1}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"location":"file://data/persistent/map_stats/default.db/map_stats","table-uuid":"37480ce7-8f2b-4184-9371-52b052402404","last-updated-ms":1772697863600,"last-column-id":6,"schemas":[{"type":"struct","fields":[{"id":1,"name":"timestamp","type":"timestamptz","required":false},{"id":2,"name":"input","type":"string","required":false},{"id":3,"name":"output","type":"string","required":false},{"id":4,"name":"metadata","type":{"type":"map","key-id":5,"key":"string","value-id":6,"value":"string","value-required":false},"required":false}],"schema-id":0,"identifier-field-ids":[]}],"current-schema-id":0,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"field-id":1000,"transform":"day","name":"_day"}]}],"default-spec-id":0,"last-partition-id":1000,"properties":{},"current-snapshot-id":554549470069664013,"snapshots":[{"snapshot-id":8792170059756986233,"sequence-number":1,"timestamp-ms":1772697863587,"manifest-list":"file://data/persistent/map_stats/default.db/map_stats/metadata/snap-8792170059756986233-0-8ed9efb3-5eb4-4225-a66a-2b6b46cb4d32.avro","summary":{"operation":"append","added-files-size":"2260","added-data-files":"1","added-records":"1","changed-partition-count":"1","total-data-files":"1","total-delete-files":"0","total-records":"1","total-files-size":"2260","total-position-deletes":"0","total-equality-deletes":"0"},"schema-id":0},{"snapshot-id":554549470069664013,"parent-snapshot-id":8792170059756986233,"sequence-number":2,"timestamp-ms":1772697863600,"manifest-list":"file://data/persistent/map_stats/default.db/map_stats/metadata/snap-554549470069664013-0-8574bca8-244f-4667-965a-03a41a3e4e0e.avro","summary":{"operation":"append","added-files-size":"2260","added-data-files":"1","added-records":"1","changed-partition-count":"1","total-data-files":"2","total-delete-files":"0","total-records":"2","total-files-size":"4520","total-position-deletes":"0","total-equality-deletes":"0"},"schema-id":0}],"snapshot-log":[{"snapshot-id":8792170059756986233,"timestamp-ms":1772697863587},{"snapshot-id":554549470069664013,"timestamp-ms":1772697863600}],"metadata-log":[{"metadata-file":"file://data/persistent/map_stats/default.db/map_stats/metadata/00000-e5eddfa2-1468-4e06-bb1d-bb443e4dd618.metadata.json","timestamp-ms":1772697863019},{"metadata-file":"file://data/persistent/map_stats/default.db/map_stats/metadata/00001-95f81ca3-d5e0-4b8c-8b1c-4530ccfd8684.metadata.json","timestamp-ms":1772697863587}],"sort-orders":[{"order-id":0,"fields":[]}],"default-sort-order-id":0,"refs":{"main":{"snapshot-id":554549470069664013,"type":"branch"}},"statistics":[],"format-version":2,"last-sequence-number":2}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added data/persistent/map_stats/pyiceberg_catalog.db
Binary file not shown.
92 changes: 92 additions & 0 deletions scripts/persistent/map_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from datetime import UTC, datetime
import os

import duckdb
import pyarrow as pa
from pyiceberg.catalog import load_catalog
from pyiceberg.partitioning import PartitionField, PartitionSpec
from pyiceberg.schema import Schema, assign_fresh_schema_ids
from pyiceberg.transforms import DayTransform
from pyiceberg.types import MapType, NestedField, StringType, TimestamptzType

# Persistent warehouse location
warehouse_path = "data/persistent/map_stats"
os.makedirs(warehouse_path, exist_ok=True)

catalog = load_catalog(
"default",
**{
"type": "sql",
"uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db",
"warehouse": f"file://{warehouse_path}",
},
)

# Create namespace if needed
try:
catalog.create_namespace("default")
except Exception:
pass

schema = Schema(
NestedField(field_id=1, name="timestamp", field_type=TimestamptzType()),
NestedField(field_id=2, name="input", field_type=StringType()),
NestedField(field_id=3, name="output", field_type=StringType()),
NestedField(
field_id=4,
name="metadata",
field_type=MapType(
key_id=5,
key_type=StringType(),
value_id=6,
value_type=StringType(),
value_required=False,
),
required=False,
),
)

schema = assign_fresh_schema_ids(schema)

table = catalog.create_table(
"default.map_stats",
schema,
partition_spec=PartitionSpec(
PartitionField(
source_id=schema.find_field("timestamp").field_id,
transform=DayTransform(),
field_id=1000,
name="_day",
)
),
)

# First append
table.append(
pa.Table.from_pylist(
[
{
"timestamp": datetime(2026, 1, 1, 0, 0, 0, tzinfo=UTC),
"input": "hello",
"output": "world",
"metadata": {"key": "value1"},
},
],
schema=schema.as_arrow(),
)
)

# Second append
table.append(
pa.Table.from_pylist(
[
{
"timestamp": datetime(2026, 1, 2, 0, 0, 0, tzinfo=UTC),
"input": "hello",
"output": "world",
"metadata": {"key": "value1"},
},
],
schema=schema.as_arrow(),
)
)
3 changes: 2 additions & 1 deletion src/iceberg_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct BoundExpressionReplacer : public LogicalOperatorVisitor {
if (expr.index != 0) {
return nullptr;
}
return make_uniq<BoundConstantExpression>(val);
auto &return_type = expr.return_type;
return make_uniq<BoundConstantExpression>(val.DefaultCastAs(return_type, true));
}

public:
Expand Down
34 changes: 34 additions & 0 deletions test/sql/local/missing_map_bounds.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# name: test/sql/local/missing_map_bounds.test
# description: Test ducklake updates
# group: [local]

require avro

require parquet

require iceberg

require httpfs

require core_functions

# Do not ignore 'HTTP' error messages!
set ignore_error_messages

statement ok
CALL enable_logging('HTTP');

statement ok
set logging_level='debug'

query IIII
from iceberg_scan('__WORKING_DIRECTORY__/data/persistent/map_stats/default.db/map_stats', version='00002-0e059d4b-e5e8-41af-a763-76cbf3a3d0bc', allow_moved_paths=true) order by all;
----
2026-01-01 00:00:00+00 hello world {key=value1}
2026-01-02 00:00:00+00 hello world {key=value1}


query IIII
from iceberg_scan('__WORKING_DIRECTORY__/data/persistent/map_stats/default.db/map_stats', version='00002-0e059d4b-e5e8-41af-a763-76cbf3a3d0bc', allow_moved_paths=true) where timestamp >= '2026-01-01' AND timestamp < '2026-01-02' AND metadata['key'] = 'value1' order by all;
----
2026-01-01 00:00:00+00 hello world {key=value1}
Loading