Skip to content

Commit 7d2bf13

Browse files
committed
Merge remote-tracking branch 'origin/main' into nn-meta-sha256
2 parents 0870d05 + 5169dff commit 7d2bf13

39 files changed

Lines changed: 13072 additions & 10768 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ package to PyPI. To release a new version:
8282
automatically determined by the release tag in GitHub.
8383
3. Get approval and merge into `main`.
8484
4. Create a new GitHub release from `main` with a tag matching the version (e.g.
85-
`gh release create v0.3.0 --title "v0.3.0" --generate-notes`). The release must be
85+
`gh release create v0.4.0 --title "v0.4.0" --generate-notes`). The release must be
8686
created after merging the version bump, since the workflow checks out the default branch.
8787
5. Tag the release for the Go submodule. Go requires a separate tag with the subdirectory
8888
prefix for modules that live outside the repository root:
8989
```bash
90-
git tag sdks/go/v0.3.0 v0.3.0
91-
git push origin sdks/go/v0.3.0
90+
git tag sdks/go/v0.4.0 v0.4.0
91+
git push origin sdks/go/v0.4.0
9292
```
9393
Without this tag, `go get` will not be able to resolve the module at the released version.
9494

meta/src/meta/grammar.y

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@
9999
%nonterm exists logic.Exists
100100
%nonterm export transactions.Export
101101
%nonterm export_csv_column transactions.ExportCSVColumn
102-
%nonterm export_csv_columns Sequence[transactions.ExportCSVColumn]
102+
%nonterm export_csv_columns_list Sequence[transactions.ExportCSVColumn]
103103
%nonterm export_csv_config transactions.ExportCSVConfig
104104
%nonterm export_csv_path String
105+
%nonterm export_csv_source transactions.ExportCSVSource
105106
%nonterm false logic.Disjunction
106107
%nonterm ffi logic.FFI
107108
%nonterm ffi_args Sequence[logic.Abstraction]
@@ -178,6 +179,7 @@
178179
%validator_ignore_completeness DecimalValue
179180
%validator_ignore_completeness BeTreeLocator
180181
%validator_ignore_completeness BeTreeConfig
182+
%validator_ignore_completeness ExportCSVColumns
181183

182184
%%
183185

@@ -1079,17 +1081,23 @@ export
10791081
deconstruct: $3: transactions.ExportCSVConfig = $$.csv_config
10801082

10811083
export_csv_config
1082-
: "(" "export_csv_config" export_csv_path export_csv_columns config_dict ")"
1083-
construct: $$ = export_csv_config($3, $4, $5)
1084-
deconstruct:
1084+
: "(" "export_csv_config_v2" export_csv_path export_csv_source csv_config ")"
1085+
construct: $$ = construct_export_csv_config_with_source($3, $4, $5)
1086+
deconstruct if builtin.length($$.data_columns) == 0:
1087+
$3: String = $$.path
1088+
$4: transactions.ExportCSVSource = $$.csv_source
1089+
$5: logic.CSVConfig = $$.csv_config
1090+
| "(" "export_csv_config" export_csv_path export_csv_columns_list config_dict ")"
1091+
construct: $$ = construct_export_csv_config($3, $4, $5)
1092+
deconstruct if builtin.length($$.data_columns) != 0:
10851093
$3: String = $$.path
10861094
$4: Sequence[transactions.ExportCSVColumn] = $$.data_columns
10871095
$5: Sequence[Tuple[String, logic.Value]] = deconstruct_export_csv_config($$)
10881096

10891097
export_csv_path
10901098
: "(" "path" STRING ")"
10911099

1092-
export_csv_columns
1100+
export_csv_columns_list
10931101
: "(" "columns" export_csv_column* ")"
10941102

10951103
export_csv_column
@@ -1099,6 +1107,16 @@ export_csv_column
10991107
$3: String = $$.column_name
11001108
$4: logic.RelationId = $$.column_data
11011109

1110+
export_csv_source
1111+
: "(" "gnf_columns" export_csv_column* ")"
1112+
construct: $$ = transactions.ExportCSVSource(gnf_columns=transactions.ExportCSVColumns(columns=$3))
1113+
deconstruct if builtin.has_proto_field($$, 'gnf_columns'):
1114+
$3: Sequence[transactions.ExportCSVColumn] = $$.gnf_columns.columns
1115+
| "(" "table_def" relation_id ")"
1116+
construct: $$ = transactions.ExportCSVSource(table_def=$3)
1117+
deconstruct if builtin.has_proto_field($$, 'table_def'):
1118+
$3: logic.RelationId = $$.table_def
1119+
11021120

11031121
%%
11041122

@@ -1198,6 +1216,7 @@ def construct_csv_config(config_dict: Sequence[Tuple[String, logic.Value]]) -> l
11981216
decimal_separator: str = _extract_value_string(builtin.dict_get(config, "csv_decimal_separator"), ".")
11991217
encoding: str = _extract_value_string(builtin.dict_get(config, "csv_encoding"), "utf-8")
12001218
compression: str = _extract_value_string(builtin.dict_get(config, "csv_compression"), "auto")
1219+
partition_size_mb: int = _extract_value_int64(builtin.dict_get(config, "csv_partition_size_mb"), 0)
12011220
return logic.CSVConfig(
12021221
header_row=header_row,
12031222
skip=skip,
@@ -1210,6 +1229,7 @@ def construct_csv_config(config_dict: Sequence[Tuple[String, logic.Value]]) -> l
12101229
decimal_separator=decimal_separator,
12111230
encoding=encoding,
12121231
compression=compression,
1232+
partition_size_mb=partition_size_mb,
12131233
)
12141234

12151235

@@ -1275,8 +1295,7 @@ def construct_configure(config_dict: Sequence[Tuple[String, logic.Value]]) -> tr
12751295
ivm_config=ivm_config,
12761296
)
12771297

1278-
1279-
def export_csv_config(
1298+
def construct_export_csv_config(
12801299
path: String,
12811300
columns: Sequence[transactions.ExportCSVColumn],
12821301
config_dict: Sequence[Tuple[String, logic.Value]],
@@ -1301,6 +1320,17 @@ def export_csv_config(
13011320
syntax_escapechar=builtin.some(syntax_escapechar),
13021321
)
13031322

1323+
def construct_export_csv_config_with_source(
1324+
path: String,
1325+
csv_source: transactions.ExportCSVSource,
1326+
csv_config: logic.CSVConfig,
1327+
) -> transactions.ExportCSVConfig:
1328+
return transactions.ExportCSVConfig(
1329+
path=path,
1330+
csv_source=csv_source,
1331+
csv_config=csv_config,
1332+
)
1333+
13041334

13051335
def _make_value_int32(v: Int32) -> logic.Value:
13061336
return logic.Value(int_value=builtin.int32_to_int64(v))
@@ -1362,6 +1392,8 @@ def deconstruct_csv_config(msg: logic.CSVConfig) -> List[Tuple[String, logic.Val
13621392
builtin.list_push(result, builtin.tuple("csv_decimal_separator", _make_value_string(msg.decimal_separator)))
13631393
builtin.list_push(result, builtin.tuple("csv_encoding", _make_value_string(msg.encoding)))
13641394
builtin.list_push(result, builtin.tuple("csv_compression", _make_value_string(msg.compression)))
1395+
if msg.partition_size_mb != 0:
1396+
builtin.list_push(result, builtin.tuple("csv_partition_size_mb", _make_value_int64(msg.partition_size_mb)))
13651397
return builtin.list_sort(result)
13661398

13671399

meta/src/meta/templates/parser.go.template

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ func toPascalCase(s string) string {{
496496
// --- Parse functions ---
497497
{parse_nonterminal_defns}
498498

499-
// Parse parses the input string and returns the result
500-
func Parse(input string) (result *pb.Transaction, err error) {{
499+
// ParseTransaction parses the input string and returns a Transaction
500+
func ParseTransaction(input string) (result *pb.Transaction, err error) {{
501501
defer func() {{
502502
if r := recover(); r != nil {{
503503
if pe, ok := r.(ParseError); ok {{
@@ -521,3 +521,34 @@ func Parse(input string) (result *pb.Transaction, err error) {{
521521
}}
522522
return result, nil
523523
}}
524+
525+
// ParseFragment parses the input string and returns a Fragment
526+
func ParseFragment(input string) (result *pb.Fragment, err error) {{
527+
defer func() {{
528+
if r := recover(); r != nil {{
529+
if pe, ok := r.(ParseError); ok {{
530+
err = pe
531+
return
532+
}}
533+
panic(r)
534+
}}
535+
}}()
536+
537+
lexer := NewLexer(input)
538+
parser := NewParser(lexer.tokens)
539+
result = parser.parse_fragment()
540+
541+
// Check for unconsumed tokens (except EOF)
542+
if parser.pos < len(parser.tokens) {{
543+
remainingToken := parser.lookahead(0)
544+
if remainingToken.Type != "$" {{
545+
return nil, ParseError{{msg: fmt.Sprintf("Unexpected token at end of input: %v", remainingToken)}}
546+
}}
547+
}}
548+
return result, nil
549+
}}
550+
551+
// Parse parses the input string and returns a Transaction
552+
func Parse(input string) (result *pb.Transaction, err error) {{
553+
return ParseTransaction(input)
554+
}}

meta/src/meta/templates/parser.jl.template

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ end
280280
# --- Parse functions ---
281281
{parse_nonterminal_defns}
282282

283-
function parse(input::String)
283+
function parse_transaction(input::String)
284284
lexer = Lexer(input)
285285
parser = ParserState(lexer.tokens)
286286
result = parse_{start_name}(parser)
@@ -294,8 +294,26 @@ function parse(input::String)
294294
return result
295295
end
296296

297-
# Export main parse function and error type
298-
export parse, ParseError
297+
function parse_fragment(input::String)
298+
lexer = Lexer(input)
299+
parser = ParserState(lexer.tokens)
300+
result = parse_fragment(parser)
301+
# Check for unconsumed tokens (except EOF)
302+
if parser.pos <= length(parser.tokens)
303+
remaining_token = lookahead(parser, 0)
304+
if remaining_token.type != "\$"
305+
throw(ParseError("Unexpected token at end of input: $remaining_token"))
306+
end
307+
end
308+
return result
309+
end
310+
311+
function parse(input::String)
312+
return parse_transaction(input)
313+
end
314+
315+
# Export main parse functions and error type
316+
export parse, parse_transaction, parse_fragment, ParseError
299317
# Export scanner functions for testing
300318
export scan_string, scan_int, scan_float, scan_int128, scan_uint128, scan_decimal
301319
# Export Lexer for testing

meta/src/meta/templates/parser.py.template

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ class Parser:
273273
# --- Parse methods ---
274274
{parse_nonterminal_defns}
275275

276-
def parse(input_str: str) -> Any:
277-
"""Parse input string and return parse tree."""
276+
def parse_transaction(input_str: str) -> Any:
277+
"""Parse input string and return a Transaction."""
278278
lexer = Lexer(input_str)
279279
parser = Parser(lexer.tokens)
280280
result = parser.parse_{start_name}()
@@ -284,3 +284,21 @@ def parse(input_str: str) -> Any:
284284
if remaining_token.type != "$":
285285
raise ParseError(f"Unexpected token at end of input: {{remaining_token}}")
286286
return result
287+
288+
289+
def parse_fragment(input_str: str) -> Any:
290+
"""Parse input string and return a Fragment."""
291+
lexer = Lexer(input_str)
292+
parser = Parser(lexer.tokens)
293+
result = parser.parse_fragment()
294+
# Check for unconsumed tokens (except EOF)
295+
if parser.pos < len(parser.tokens):
296+
remaining_token = parser.lookahead(0)
297+
if remaining_token.type != "$":
298+
raise ParseError(f"Unexpected token at end of input: {{remaining_token}}")
299+
return result
300+
301+
302+
def parse(input_str: str) -> Any:
303+
"""Parse input string and return a Transaction."""
304+
return parse_transaction(input_str)

proto/relationalai/lqp/v1/logic.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ message CSVConfig {
309309

310310
// Compression
311311
string compression = 11; // "none", "gzip", "zstd", "auto" (default: "auto")
312+
313+
// Partitioning (for export)
314+
int64 partition_size_mb = 12;
312315
}
313316

314317
message GNFColumn {

proto/relationalai/lqp/v1/transactions.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ message Snapshot {
8282

8383
message ExportCSVConfig {
8484
string path = 1;
85+
86+
ExportCSVSource csv_source = 10;
87+
CSVConfig csv_config = 11;
88+
89+
// Below are all deprecated in favour of the `csv_config` above.
8590
repeated ExportCSVColumn data_columns = 2;
8691

8792
optional int64 partition_size = 3;
@@ -100,6 +105,17 @@ message ExportCSVColumn {
100105
RelationId column_data = 2;
101106
}
102107

108+
message ExportCSVColumns {
109+
repeated ExportCSVColumn columns = 1;
110+
}
111+
112+
message ExportCSVSource {
113+
oneof csv_source {
114+
ExportCSVColumns gnf_columns = 1;
115+
RelationId table_def = 2;
116+
}
117+
}
118+
103119
//
104120
// Read operations
105121
//

0 commit comments

Comments
 (0)