Skip to content

Commit 0da1995

Browse files
committed
Merge branch 'main' of github.com:RelationalAI/logical-query-protocol into vs-iceberg-base-relations
2 parents f5f461c + fc217ea commit 0da1995

26 files changed

Lines changed: 12374 additions & 11631 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ force-protobuf:
109109
mkdir -p $(GO_PROTO_DIR)
110110
cp gen/go/relationalai/lqp/v1/*.pb.go $(GO_PROTO_DIR)/
111111
rm -rf gen/python gen/go
112-
cd sdks/julia && julia --project=LogicalQueryProtocol.jl generate_proto.jl
112+
cd sdks/julia && julia --startup-file=no --project=LogicalQueryProtocol.jl generate_proto.jl
113113

114114
$(PY_PROTO_GENERATED) $(GO_PROTO_GENERATED): $(PROTO_FILES)
115115
buf lint
@@ -130,7 +130,7 @@ $(PY_PROTO_GENERATED) $(GO_PROTO_GENERATED): $(PROTO_FILES)
130130
$(JL_PROTO_GENERATED): $(PROTO_FILES)
131131
buf lint
132132
buf breaking --against ".git#branch=main,subdir=proto"
133-
cd sdks/julia && julia --project=LogicalQueryProtocol.jl generate_proto.jl
133+
cd sdks/julia && julia --startup-file=no --project=LogicalQueryProtocol.jl generate_proto.jl
134134

135135
# ---------- parser generation ----------
136136

@@ -203,7 +203,7 @@ update-snapshots: $(PY_PARSER) $(PY_PROTO_GENERATED)
203203
cd sdks/python && uv run python -m pytest --snapshot-update
204204

205205
test-julia: $(JL_PARSER) $(JL_PROTO_GENERATED)
206-
cd sdks/julia && julia --project=LogicalQueryProtocol.jl -e 'using Pkg; Pkg.test()'
206+
cd sdks/julia && julia --startup-file=no --project=LogicalQueryProtocol.jl -e 'using Pkg; Pkg.test()'
207207

208208
test-go: $(GO_PARSER) $(GO_PROTO_GENERATED)
209209
cd sdks/go && go test ./test/...

meta/src/meta/codegen_go.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def none_generator(
195195
terminal_field_map = {
196196
"INT": "i64",
197197
"INT32": "i32",
198+
"UINT32": "u32",
198199
"FLOAT": "f64",
199200
"FLOAT32": "f32",
200201
"STRING": "str",
@@ -939,6 +940,7 @@ def format_literal_token_spec(self, escaped_literal: str) -> str:
939940
"STRING": ("scanString", "kindString", "str"),
940941
"INT": ("scanInt", "kindInt64", "i64"),
941942
"INT32": ("scanInt32", "kindInt32", "i32"),
943+
"UINT32": ("scanUint32", "kindUint32", "u32"),
942944
"FLOAT": ("scanFloat", "kindFloat64", "f64"),
943945
"FLOAT32": ("scanFloat32", "kindFloat32", "f32"),
944946
"UINT128": ("scanUint128", "kindUint128", "uint128"),

meta/src/meta/codegen_templates.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class BuiltinTemplate:
4343
"length": BuiltinTemplate("len({0})"),
4444
"unwrap_option_or": BuiltinTemplate("({0} if {0} is not None else {1})"),
4545
"int64_to_int32": BuiltinTemplate("int({0})"),
46+
"int64_to_uint32": BuiltinTemplate("int({0})"),
4647
"float64_to_float32": BuiltinTemplate("float({0})"),
4748
"to_ptr_int64": BuiltinTemplate("{0}"), # Python doesn't need pointers
4849
"to_ptr_string": BuiltinTemplate("{0}"),
@@ -85,6 +86,7 @@ class BuiltinTemplate:
8586
"try_flat_io": BuiltinTemplate("self._try_flat({0}, {1})"),
8687
"format_int64": BuiltinTemplate("str({0})"),
8788
"format_int32": BuiltinTemplate("(str({0}) + 'i32')"),
89+
"format_uint32": BuiltinTemplate("(str({0}) + 'u32')"),
8890
"format_float32": BuiltinTemplate("(self.format_float32_value({0}) + 'f32')"),
8991
"format_float64": BuiltinTemplate("str({0})"),
9092
"format_string": BuiltinTemplate("self.format_string_value({0})"),
@@ -97,6 +99,7 @@ class BuiltinTemplate:
9799
"to_string": BuiltinTemplate("str({0})"),
98100
# Type conversions used by pretty printer
99101
"int32_to_int64": BuiltinTemplate("int({0})"),
102+
"uint32_to_int64": BuiltinTemplate("int({0})"),
100103
"float32_to_float64": BuiltinTemplate("float({0})"),
101104
"is_empty": BuiltinTemplate("len({0}) == 0"),
102105
"decode_string": BuiltinTemplate("{0}.decode('utf-8')"),
@@ -140,6 +143,7 @@ class BuiltinTemplate:
140143
"length": BuiltinTemplate("length({0})"),
141144
"unwrap_option_or": BuiltinTemplate("(!isnothing({0}) ? {0} : {1})"),
142145
"int64_to_int32": BuiltinTemplate("Int32({0})"),
146+
"int64_to_uint32": BuiltinTemplate("UInt32({0})"),
143147
"float64_to_float32": BuiltinTemplate("Float32({0})"),
144148
"to_ptr_int64": BuiltinTemplate("{0}"), # Julia doesn't need pointers
145149
"to_ptr_string": BuiltinTemplate("{0}"),
@@ -178,6 +182,7 @@ class BuiltinTemplate:
178182
"try_flat_io": BuiltinTemplate("try_flat(pp, {0}, {1})"),
179183
"format_int64": BuiltinTemplate("format_int(pp, {0})"),
180184
"format_int32": BuiltinTemplate('(string(Int64({0})) * "i32")'),
185+
"format_uint32": BuiltinTemplate('(string(Int64({0})) * "u32")'),
181186
"format_float32": BuiltinTemplate('(lowercase(string({0})) * "f32")'),
182187
"format_float64": BuiltinTemplate("format_float(pp, {0})"),
183188
"format_string": BuiltinTemplate("format_string(pp, {0})"),
@@ -190,6 +195,7 @@ class BuiltinTemplate:
190195
"to_string": BuiltinTemplate("string({0})"),
191196
# Type conversions used by pretty printer
192197
"int32_to_int64": BuiltinTemplate("Int64({0})"),
198+
"uint32_to_int64": BuiltinTemplate("Int64({0})"),
193199
"float32_to_float64": BuiltinTemplate("Float64({0})"),
194200
"is_empty": BuiltinTemplate("isempty({0})"),
195201
"decode_string": BuiltinTemplate("String(copy({0}))"),
@@ -236,6 +242,7 @@ class BuiltinTemplate:
236242
# unwrap_option_or is handled specially in codegen_go.py due to Go's lack of ternary
237243
"unwrap_option_or": BuiltinTemplate("{0}"), # Placeholder - overridden in codegen
238244
"int64_to_int32": BuiltinTemplate("int32({0})"),
245+
"int64_to_uint32": BuiltinTemplate("uint32({0})"),
239246
"float64_to_float32": BuiltinTemplate("float32({0})"),
240247
"to_ptr_int64": BuiltinTemplate("ptrInt64({0})"),
241248
"to_ptr_string": BuiltinTemplate("ptrString({0})"),
@@ -273,6 +280,7 @@ class BuiltinTemplate:
273280
"try_flat_io": BuiltinTemplate("p.tryFlat({0}, func() {{ {1}({0}) }})"),
274281
"format_int64": BuiltinTemplate('fmt.Sprintf("%d", {0})'),
275282
"format_int32": BuiltinTemplate('fmt.Sprintf("%di32", {0})'),
283+
"format_uint32": BuiltinTemplate('fmt.Sprintf("%du32", {0})'),
276284
"format_float32": BuiltinTemplate(
277285
"fmt.Sprintf(\"%sf32\", strconv.FormatFloat(float64({0}), 'g', -1, 32))"
278286
),
@@ -287,6 +295,7 @@ class BuiltinTemplate:
287295
"to_string": BuiltinTemplate('fmt.Sprintf("%v", {0})'),
288296
# Type conversions used by pretty printer
289297
"int32_to_int64": BuiltinTemplate("int64({0})"),
298+
"uint32_to_int64": BuiltinTemplate("int64({0})"),
290299
"float32_to_float64": BuiltinTemplate("float64({0})"),
291300
"is_empty": BuiltinTemplate("len({0}) == 0"),
292301
"decode_string": BuiltinTemplate("string({0})"),

meta/src/meta/extra_pretty_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"string": "format_string",
5858
"int32": "format_int32",
5959
"int64": "format_int64",
60-
"uint32": "format_int64",
60+
"uint32": "format_uint32",
6161
"uint64": "format_int64",
6262
"fixed64": "format_int64",
6363
"float": "format_float32",

meta/src/meta/grammar.y

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
%token FLOAT32 Float32 r'[-]?\d+\.\d+f32'
4141
%token INT Int64 r'[-]?\d+'
4242
%token INT32 Int32 r'[-]?\d+i32'
43+
%token UINT32 UInt32 r'\d+u32'
4344
%token INT128 logic.Int128Value r'[-]?\d+i128'
4445
%token STRING String r'"(?:[^"\\]|\\.)*"'
4546
%token SYMBOL String r'[a-zA-Z_][a-zA-Z0-9_./#-]*'
@@ -121,6 +122,7 @@
121122
%nonterm instruction logic.Instruction
122123
%nonterm int_type logic.IntType
123124
%nonterm int32_type logic.Int32Type
125+
%nonterm uint32_type logic.UInt32Type
124126
%nonterm int128_type logic.Int128Type
125127
%nonterm loop logic.Loop
126128
%nonterm lt logic.Primitive
@@ -257,6 +259,10 @@ value
257259
construct: $$ = logic.Value(float32_value=$1)
258260
deconstruct if builtin.has_proto_field($$, 'float32_value'):
259261
$1: Float32 = $$.float32_value
262+
| UINT32
263+
construct: $$ = logic.Value(uint32_value=$1)
264+
deconstruct if builtin.has_proto_field($$, 'uint32_value'):
265+
$1: UInt32 = $$.uint32_value
260266

261267
date
262268
: "(" "date" INT INT INT ")"
@@ -455,6 +461,10 @@ type
455461
construct: $$ = logic.Type(float32_type=$1)
456462
deconstruct if builtin.has_proto_field($$, 'float32_type'):
457463
$1: logic.Float32Type = $$.float32_type
464+
| uint32_type
465+
construct: $$ = logic.Type(uint32_type=$1)
466+
deconstruct if builtin.has_proto_field($$, 'uint32_type'):
467+
$1: logic.UInt32Type = $$.uint32_type
458468

459469
unspecified_type
460470
: "UNKNOWN"
@@ -507,6 +517,10 @@ float32_type
507517
: "FLOAT32"
508518
construct: $$ = logic.Float32Type()
509519

520+
uint32_type
521+
: "UINT32"
522+
construct: $$ = logic.UInt32Type()
523+
510524
boolean_type
511525
: "BOOLEAN"
512526
construct: $$ = logic.BooleanType()

meta/src/meta/pretty_gen.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,8 @@ def _format_terminal(terminal: NamedTerminal, value_var: Var) -> TargetExpr:
677677
return Call(make_builtin("format_int64"), [value_var])
678678
elif terminal.name == "INT32":
679679
return Call(make_builtin("format_int32"), [value_var])
680+
elif terminal.name == "UINT32":
681+
return Call(make_builtin("format_uint32"), [value_var])
680682
elif terminal.name == "INT128":
681683
return Call(make_builtin("format_int128"), [value_var])
682684
elif terminal.name == "FLOAT":

meta/src/meta/target_builtins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# Type aliases for convenience
3030
ANY = VarType("Any")
3131
INT32 = BaseType("Int32")
32+
UINT32 = BaseType("UInt32")
3233
INT64 = BaseType("Int64")
3334
FLOAT32 = BaseType("Float32")
3435
FLOAT64 = BaseType("Float64")
@@ -159,6 +160,8 @@ def is_builtin(name: str) -> bool:
159160
# === Type conversions ===
160161
register_builtin("int64_to_int32", [INT64], INT32)
161162
register_builtin("int32_to_int64", [INT32], INT64)
163+
register_builtin("int64_to_uint32", [INT64], UINT32)
164+
register_builtin("uint32_to_int64", [UINT32], INT64)
162165
register_builtin("float64_to_float32", [FLOAT64], FLOAT32)
163166
register_builtin("float32_to_float64", [FLOAT32], FLOAT64)
164167
register_builtin("decode_string", [BYTES], STRING)
@@ -237,6 +240,7 @@ def is_builtin(name: str) -> bool:
237240
# === Formatting for terminal types ===
238241
register_builtin("format_int64", [INT64], STRING)
239242
register_builtin("format_int32", [INT32], STRING)
243+
register_builtin("format_uint32", [UINT32], STRING)
240244
register_builtin("format_float32", [FLOAT32], STRING)
241245
register_builtin("format_float64", [FLOAT64], STRING)
242246
register_builtin("format_string", [STRING], STRING)
@@ -333,6 +337,7 @@ def make_builtin_with_type(name: str, func_type: FunctionType) -> Builtin:
333337
"ANY",
334338
"INT64",
335339
"INT32",
340+
"UINT32",
336341
"FLOAT32",
337342
"FLOAT64",
338343
"STRING",

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const (
6262
kindString tokenKind = iota
6363
kindInt64
6464
kindInt32
65+
kindUint32
6566
kindFloat64
6667
kindFloat32
6768
kindUint128
@@ -75,6 +76,7 @@ type TokenValue struct {{
7576
str string
7677
i64 int64
7778
i32 int32
79+
u32 uint32
7880
f64 float64
7981
f32 float32
8082
uint128 *pb.UInt128Value
@@ -88,6 +90,8 @@ func (tv TokenValue) String() string {{
8890
return strconv.FormatInt(tv.i64, 10)
8991
case kindInt32:
9092
return fmt.Sprintf("%di32", tv.i32)
93+
case kindUint32:
94+
return fmt.Sprintf("%du32", tv.u32)
9195
case kindFloat64:
9296
return strconv.FormatFloat(tv.f64, 'g', -1, 64)
9397
case kindFloat32:
@@ -242,6 +246,15 @@ func scanInt32(s string) int32 {{
242246
return int32(n)
243247
}}
244248

249+
func scanUint32(s string) uint32 {{
250+
numStr := s[:len(s)-3] // Remove "u32" suffix
251+
n, err := strconv.ParseUint(numStr, 10, 32)
252+
if err != nil {{
253+
panic(ParseError{{msg: fmt.Sprintf("Invalid uint32: %s", s)}})
254+
}}
255+
return uint32(n)
256+
}}
257+
245258
func scanFloat32(s string) float32 {{
246259
numStr := s[:len(s)-3] // Remove "f32" suffix
247260
f, err := strconv.ParseFloat(numStr, 32)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ scan_int(n::String) = Base.parse(Int64, n)
8383

8484
scan_int32(n::String) = Base.parse(Int32, n[1:end-3]) # Remove "i32" suffix
8585

86+
scan_uint32(n::String) = Base.parse(UInt32, n[1:end-3]) # Remove "u32" suffix
87+
8688
scan_float32(f::String) = Base.parse(Float32, f[1:end-3]) # Remove "f32" suffix
8789

8890
function scan_float(f::String)
@@ -376,7 +378,7 @@ end
376378
# Export main parse functions and error type
377379
export parse, parse_transaction, parse_fragment, ParseError
378380
# Export scanner functions for testing
379-
export scan_string, scan_int, scan_int32, scan_float, scan_float32, scan_int128, scan_uint128, scan_decimal
381+
export scan_string, scan_int, scan_int32, scan_uint32, scan_float, scan_float32, scan_int128, scan_uint128, scan_decimal
380382
# Export Lexer and provenance types for testing
381383
export Lexer, Location, Span
382384

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ class Lexer:
160160
raise ParseError(f"Int32 literal out of range: {{n}}")
161161
return val
162162

163+
@staticmethod
164+
def scan_uint32(n: str) -> int:
165+
"""Parse UINT32 token."""
166+
n = n[:-3] # Remove "u32" suffix
167+
val = int(n)
168+
if val < 0 or val >= (1 << 32):
169+
raise ParseError(f"UInt32 literal out of range: {{n}}")
170+
return val
171+
163172
@staticmethod
164173
def scan_float32(f: str) -> float:
165174
"""Parse FLOAT32 token."""

0 commit comments

Comments
 (0)