Skip to content

Commit f7b00a3

Browse files
davidwzhaoclaude
andauthored
Add option for ExportCSVConfig to target txn outputs (#262)
* Add transaction output name to the ExportCSVConfig action * Add transaction_output_name alternative to export_csv_config_v2 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix Call.target_type() for variadic builtin.tuple builtin.tuple is registered as variadic (arity -1), so make_builtin gives it an empty param list and the generic type-variable matching can't resolve the return type T. Add a special case that infers TupleType directly from the argument types, matching what _infer_type already does in the parser. Without this, IfElse nodes wrapping tuple constructs were typed as interface{} in Go, causing a compile error when the function's declared return type is []interface{}. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Regenerate parsers, printers, and test snapshots Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add ExportCSVColumns/Source equality and transaction_output_name to ExportCSVConfig ExportCSVColumns had no custom == so structural comparison fell back to identity, breaking ExportCSVSource comparisons. Add equality for ExportCSVColumns first, then ExportCSVSource, then wire csv_source, csv_config, and the new transaction_output_name field into ExportCSVConfig ==, hash, and isequal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Regenerate parsers and printers --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a0419a commit f7b00a3

20 files changed

Lines changed: 14785 additions & 14370 deletions

File tree

meta/src/meta/grammar.y

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
%nonterm export_csv_column transactions.ExportCSVColumn
124124
%nonterm export_csv_columns_list Sequence[transactions.ExportCSVColumn]
125125
%nonterm export_csv_config transactions.ExportCSVConfig
126+
%nonterm export_csv_output_location Tuple[String, String]
126127
%nonterm export_csv_path String
127128
%nonterm export_csv_source transactions.ExportCSVSource
128129
%nonterm export_iceberg_config transactions.ExportIcebergConfig
@@ -1384,10 +1385,10 @@ export
13841385
$3: transactions.ExportIcebergConfig = $$.iceberg_config
13851386

13861387
export_csv_config
1387-
: "(" "export_csv_config_v2" export_csv_path export_csv_source csv_config ")"
1388-
construct: $$ = construct_export_csv_config_with_source($3, $4, $5)
1388+
: "(" "export_csv_config_v2" export_csv_output_location export_csv_source csv_config ")"
1389+
construct: $$ = construct_export_csv_config_with_location($3, $4, $5)
13891390
deconstruct if builtin.length($$.data_columns) == 0:
1390-
$3: String = $$.path
1391+
$3: Tuple[String, String] = deconstruct_export_csv_output_location($$)
13911392
$4: transactions.ExportCSVSource = $$.csv_source
13921393
$5: logic.CSVConfig = $$.csv_config
13931394
| "(" "export_csv_config" export_csv_path export_csv_columns_list config_dict ")"
@@ -1397,6 +1398,16 @@ export_csv_config
13971398
$4: Sequence[transactions.ExportCSVColumn] = $$.data_columns
13981399
$5: Sequence[Tuple[String, logic.Value]] = deconstruct_export_csv_config($$)
13991400

1401+
export_csv_output_location
1402+
: "(" "path" STRING ")"
1403+
construct: $$ = builtin.tuple($3, "")
1404+
deconstruct if $$[0] != "":
1405+
$3: String = $$[0]
1406+
| "(" "transaction_output_name" name ")"
1407+
construct: $$ = builtin.tuple("", $3)
1408+
deconstruct if $$[1] != "":
1409+
$3: String = $$[1]
1410+
14001411
export_csv_path
14011412
: "(" "path" STRING ")"
14021413

@@ -1719,13 +1730,17 @@ def construct_export_csv_config(
17191730
syntax_escapechar=builtin.some(syntax_escapechar),
17201731
)
17211732

1722-
def construct_export_csv_config_with_source(
1723-
path: String,
1733+
def deconstruct_export_csv_output_location(msg: transactions.ExportCSVConfig) -> Tuple[String, String]:
1734+
return (msg.path, msg.transaction_output_name)
1735+
1736+
def construct_export_csv_config_with_location(
1737+
location: Tuple[String, String],
17241738
csv_source: transactions.ExportCSVSource,
17251739
csv_config: logic.CSVConfig,
17261740
) -> transactions.ExportCSVConfig:
17271741
return transactions.ExportCSVConfig(
1728-
path=path,
1742+
path=location[0],
1743+
transaction_output_name=location[1],
17291744
csv_source=csv_source,
17301745
csv_config=csv_config,
17311746
)

meta/src/meta/target.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ def __post_init__(self):
345345
def target_type(self) -> "TargetType":
346346
if isinstance(self.func, (ParseNonterminal, PrintNonterminal)):
347347
return self.func.target_type()
348+
# builtin.tuple is variadic; infer TupleType from the argument types directly.
349+
if isinstance(self.func, Builtin) and self.func.name == "tuple":
350+
return TupleType(tuple(a.target_type() for a in self.args))
348351
func_type = self.func.target_type()
349352
if isinstance(func_type, FunctionType):
350353
# Match parameter types against argument types to build type variable mapping

proto/relationalai/lqp/v1/transactions.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ message Snapshot {
8585
//
8686

8787
message ExportCSVConfig {
88+
// The following two fields should be in a `oneof`, but compatibility makes that tricky.
89+
// The `path` option should be used if the client needs to output a CSV file to a
90+
// specific location.
91+
// The `transaction_output_name` should be used if the client wants the CSV file to be
92+
// returned as part of the transaction results.
8893
string path = 1;
94+
string transaction_output_name = 12;
8995

9096
ExportCSVSource csv_source = 10;
9197
CSVConfig csv_config = 11;

sdks/go/src/lqp/v1/transactions.pb.go

Lines changed: 181 additions & 164 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)