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
22 changes: 17 additions & 5 deletions meta/src/meta/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
%nonterm gnf_column_path Sequence[String]
%nonterm gnf_columns Sequence[logic.GNFColumn]
%nonterm named_column logic.NamedColumn
%nonterm relation_keys Sequence[logic.NamedColumn]
%nonterm relation_keys Tuple[Sequence[logic.NamedColumn], Boolean]
%nonterm target_relation logic.TargetRelation
%nonterm non_cdc_relations Sequence[logic.TargetRelation]
%nonterm cdc_inserts Sequence[logic.TargetRelation]
Expand Down Expand Up @@ -1134,6 +1134,12 @@ named_column

relation_keys
: "(" "keys" named_column* ")"
construct: $$ = builtin.tuple($3, False)
deconstruct if not $$[1]:
$3: Sequence[logic.NamedColumn] = $$[0]
| "(" "keys" "synthetic" ")"
construct: $$ = builtin.tuple(list[logic.NamedColumn](), True)
deconstruct if $$[1]:

target_relation
: "(" "relation" relation_id named_column* ")"
Expand Down Expand Up @@ -1166,7 +1172,7 @@ target_relations
: "(" "relations" relation_keys relation_body ")"
construct: $$ = construct_relations($3, $4)
deconstruct:
$3: Sequence[logic.NamedColumn] = $$.keys
$3: Tuple[Sequence[logic.NamedColumn], Boolean] = deconstruct_relation_keys($$)
$4: logic.TargetRelations = $$

csv_locator_paths
Expand Down Expand Up @@ -1558,13 +1564,19 @@ def construct_cdc_relations(
)


def deconstruct_relation_keys(
msg: logic.TargetRelations,
) -> Tuple[Sequence[logic.NamedColumn], Boolean]:
return builtin.tuple(msg.keys, msg.synthetic_key)


def construct_relations(
keys: Sequence[logic.NamedColumn],
keys: Tuple[Sequence[logic.NamedColumn], Boolean],
body: logic.TargetRelations,
) -> logic.TargetRelations:
if builtin.has_proto_field(body, "plain"):
return logic.TargetRelations(keys=keys, plain=body.plain)
return logic.TargetRelations(keys=keys, cdc=body.cdc)
return logic.TargetRelations(keys=keys[0], synthetic_key=keys[1], plain=body.plain)
return logic.TargetRelations(keys=keys[0], synthetic_key=keys[1], cdc=body.cdc)


def construct_csv_data(
Expand Down
5 changes: 4 additions & 1 deletion proto/relationalai/lqp/v1/logic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,14 @@ message CDCTargets {
// Generalized loading: shared key columns plus the target relations, loaded either as a
// plain snapshot or as CDC insert/delete deltas. The two modes are mutually exclusive.
message TargetRelations {
repeated NamedColumn keys = 1; // Shared key columns
repeated NamedColumn keys = 1; // Shared key columns; must be empty when synthetic_key is set
oneof body {
PlainTargets plain = 2;
CDCTargets cdc = 3;
}
// If true, the shared key is synthesized by the loader (e.g. a generated row key)
// instead of being drawn from CSV columns. Mutually exclusive with `keys`.
bool synthetic_key = 4;
}

message CSVData {
Expand Down
567 changes: 290 additions & 277 deletions sdks/go/src/lqp/v1/logic.pb.go

Large diffs are not rendered by default.

Loading
Loading