Skip to content

Commit d05f8c2

Browse files
hbarthelsclaude
andcommitted
Test synthetic key with a single unary keyless relation
Cover the case where a synthetic key feeds a single relation that has no value columns — i.e. the relation holds just the (synthetic) key. Adds the `relations_synthetic_key_unary` round-trip fixture and a matching parser unit test asserting synthetic_key is set, keys is empty, and the sole target has no value columns. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent fad79e1 commit d05f8c2

5 files changed

Lines changed: 95 additions & 0 deletions

File tree

‎sdks/python/tests/test_parser.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ def test_synthetic_key_marker():
127127
assert [c.name for c in relations.keys] == ["id"]
128128

129129

130+
def test_synthetic_key_with_unary_keyless_relation():
131+
# A synthetic key with a single relation that has no value columns: the
132+
# relation holds just the (synthetic) key.
133+
fragment = (
134+
'(fragment :f (csv_data (csv_locator (paths "x.csv")) (csv_config {}) '
135+
"(relations (keys synthetic) (relation :keys)) "
136+
'(asof "2025-01-01T00:00:00Z")))'
137+
)
138+
relations = _relations_of(fragment)
139+
assert relations.synthetic_key is True
140+
assert list(relations.keys) == []
141+
assert len(relations.plain.targets) == 1
142+
assert list(relations.plain.targets[0].values) == []
143+
144+
130145
def test_synthetic_key_rejects_unknown_marker():
131146
# Only the `synthetic` marker is accepted; anything else is a hard error.
132147
with pytest.raises(ParseError):
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
�
3+
�
4+
�
5+
�
6+

7+
f1e"ca
8+

9+
s3://bucket/keys.csv",*"2"J.Rutf-8"2025-06-01T00:00:00Z*
10+

11+
 #�yS�ӶDC�<'۳�� 
12+
 #�yS�ӶDC�<'۳��keys
13+
keys #�yS�ӶDC�<'۳��
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(transaction
2+
(epoch
3+
(writes
4+
(define
5+
(fragment :f1
6+
;; Generalized CSV loading with a synthetic (loader-generated) key and a single
7+
;; unary relation that carries no value columns — the relation holds just the key.
8+
(csv_data
9+
(csv_locator
10+
(paths "s3://bucket/keys.csv"))
11+
(csv_config {})
12+
(relations
13+
(keys synthetic)
14+
(relation :keys))
15+
(asof "2025-06-01T00:00:00Z")))))
16+
17+
(reads
18+
(output :keys :keys))))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(transaction
2+
(configure { :ivm.maintenance_level "off" :semantics_version 0})
3+
(epoch
4+
(writes
5+
(define
6+
(fragment
7+
:f1
8+
(csv_data
9+
(csv_locator (paths "s3://bucket/keys.csv"))
10+
(csv_config
11+
{
12+
:csv_compression ""
13+
:csv_decimal_separator "."
14+
:csv_delimiter ","
15+
:csv_encoding "utf-8"
16+
:csv_escapechar "\""
17+
:csv_header_row 1i32
18+
:csv_quotechar "\""
19+
:csv_skip 0})
20+
(relations (keys synthetic) (relation :keys))
21+
(asof "2025-06-01T00:00:00Z")))))
22+
(reads (output :keys :keys))))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(transaction
2+
(configure { :ivm.maintenance_level "off" :semantics_version 0})
3+
(epoch
4+
(writes
5+
(define
6+
(fragment
7+
:f1
8+
(csv_data
9+
(csv_locator (paths "s3://bucket/keys.csv"))
10+
(csv_config
11+
{
12+
:csv_compression ""
13+
:csv_decimal_separator "."
14+
:csv_delimiter ","
15+
:csv_encoding "utf-8"
16+
:csv_escapechar "\""
17+
:csv_header_row 1i32
18+
:csv_quotechar "\""
19+
:csv_skip 0})
20+
(relations (keys synthetic) (relation 0xd382b3db273cff4344b6d39d5379c923))
21+
(asof "2025-06-01T00:00:00Z")))))
22+
(reads (output :keys 0xd382b3db273cff4344b6d39d5379c923))))
23+
24+
;; Debug information
25+
;; -----------------------
26+
;; Original names
27+
;; ID `0xd382b3db273cff4344b6d39d5379c923` -> `keys`

0 commit comments

Comments
 (0)