Skip to content

Commit 09c97e5

Browse files
committed
Proc macro to derive unary/binary function definitions
Similar to the `sqlfunc!` macro, this proc macro derives the helper traits for unary and binary functions. Signed-off-by: Moritz Hoffmann <mh@materialize.com>
1 parent cf7f266 commit 09c97e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2948
-24
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
[workspace]
22
members = [
3+
"misc/bazel/cargo-gazelle",
34
"src/adapter",
45
"src/adapter-types",
56
"src/alloc",
67
"src/alloc-default",
78
"src/arrow-util",
89
"src/audit-log",
910
"src/avro",
10-
"src/aws-util",
1111
"src/aws-secrets-controller",
12+
"src/aws-util",
1213
"src/balancerd",
1314
"src/build-info",
1415
"src/build-tools",
15-
"src/ccsr",
1616
"src/catalog",
1717
"src/catalog-debug",
1818
"src/catalog-protos",
19+
"src/ccsr",
1920
"src/cloud-api",
2021
"src/cloud-provider",
22+
"src/cloud-resources",
2123
"src/cluster",
22-
"src/clusterd",
2324
"src/cluster-client",
25+
"src/clusterd",
2426
"src/compute",
2527
"src/compute-client",
2628
"src/compute-types",
@@ -32,6 +34,8 @@ members = [
3234
"src/dyncfgs",
3335
"src/environmentd",
3436
"src/expr",
37+
"src/expr-derive",
38+
"src/expr-derive-impl",
3539
"src/expr-parser",
3640
"src/expr-test-util",
3741
"src/fivetran-destination",
@@ -44,13 +48,13 @@ members = [
4448
"src/license-keys",
4549
"src/lowertest",
4650
"src/lowertest-derive",
51+
"src/lsp-server",
52+
"src/materialized",
4753
"src/materialized",
4854
"src/metabase",
55+
"src/metrics",
4956
"src/mysql-util",
5057
"src/mz",
51-
"src/lsp-server",
52-
"src/materialized",
53-
"src/metrics",
5458
"src/npm",
5559
"src/orchestrator",
5660
"src/orchestrator-kubernetes",
@@ -64,7 +68,6 @@ members = [
6468
"src/persist-cli",
6569
"src/persist-client",
6670
"src/persist-proc",
67-
"src/txn-wal",
6871
"src/persist-types",
6972
"src/pgcopy",
7073
"src/pgrepr",
@@ -78,6 +81,7 @@ members = [
7881
"src/prof",
7982
"src/prof-http",
8083
"src/proto",
84+
"src/regexp",
8185
"src/repr",
8286
"src/repr-test-util",
8387
"src/rocksdb",
@@ -88,13 +92,13 @@ members = [
8892
"src/self-managed-debug",
8993
"src/server-core",
9094
"src/service",
91-
"src/ssh-util",
9295
"src/sql",
9396
"src/sql-lexer",
9497
"src/sql-parser",
9598
"src/sql-pretty",
9699
"src/sql-server-util",
97100
"src/sqllogictest",
101+
"src/ssh-util",
98102
"src/storage",
99103
"src/storage-client",
100104
"src/storage-controller",
@@ -106,13 +110,11 @@ members = [
106110
"src/tls-util",
107111
"src/tracing",
108112
"src/transform",
109-
"src/cloud-resources",
113+
"src/txn-wal",
110114
"src/walkabout",
111115
"src/workspace-hack",
112116
"test/metabase/smoketest",
113117
"test/test-util",
114-
"src/regexp",
115-
"misc/bazel/cargo-gazelle",
116118
]
117119

118120
# We make all members of the workspace default members, *except* for a few
@@ -155,6 +157,8 @@ default-members = [
155157
"src/dyncfgs",
156158
"src/environmentd",
157159
"src/expr",
160+
"src/expr-derive",
161+
"src/expr-derive-impl",
158162
"src/expr-parser",
159163
"src/expr-test-util",
160164
"src/frontegg-auth",

WORKSPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ crates_repository(
611611
"//:src/dyncfg-launchdarkly/Cargo.toml",
612612
"//:src/dyncfgs/Cargo.toml",
613613
"//:src/environmentd/Cargo.toml",
614+
"//:src/expr-derive/Cargo.toml",
615+
"//:src/expr-derive-impl/Cargo.toml",
614616
"//:src/expr-parser/Cargo.toml",
615617
"//:src/expr-test-util/Cargo.toml",
616618
"//:src/expr/Cargo.toml",

ci/test/lint-main/checks/check-copyright.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ copyright_files=$(grep -vE \
6060
-e '^src/catalog/tests/snapshots/.*\.snap' \
6161
-e '^src/catalog/src/durable/upgrade/snapshots/.*' \
6262
-e '^src/catalog/src/durable/upgrade/persist/snapshots/.*\.snap' \
63+
-e '^src/expr-derive-impl/src/snapshots.*' \
64+
-e '^src/expr/src/scalar/func/snapshots/.*' \
65+
-e '^src/expr/src/scalar/snapshots/.*' \
6366
-e '^src/license-keys/src/license_keys/.*\.pub' \
6467
-e '^src/storage-types/src/snapshots/.*' \
6568
-e '^src/repr/src/adt/snapshots/.*' \

src/expr-derive-impl/BUILD.bazel

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Code generated by cargo-gazelle DO NOT EDIT
2+
3+
# Copyright Materialize, Inc. and contributors. All rights reserved.
4+
#
5+
# Use of this software is governed by the Business Source License
6+
# included in the LICENSE file at the root of this repository.
7+
#
8+
# As of the Change Date specified in that file, in accordance with
9+
# the Business Source License, use of this software will be governed
10+
# by the Apache License, Version 2.0.
11+
12+
load("@crates_io//:defs.bzl", "aliases", "all_crate_deps")
13+
load("@rules_rust//cargo:defs.bzl", "extract_cargo_lints")
14+
load("@rules_rust//rust:defs.bzl", "rust_doc_test", "rust_library", "rust_test")
15+
16+
package(default_visibility = ["//visibility:public"])
17+
18+
rust_library(
19+
name = "mz_expr_derive_impl",
20+
srcs = glob(["src/**/*.rs"]),
21+
aliases = aliases(
22+
normal = True,
23+
proc_macro = True,
24+
),
25+
compile_data = [],
26+
crate_features = [
27+
"insta",
28+
"prettyplease",
29+
"test",
30+
],
31+
data = [],
32+
lint_config = ":lints",
33+
proc_macro_deps = [] + all_crate_deps(proc_macro = True),
34+
rustc_env = {},
35+
rustc_flags = [],
36+
version = "0.0.0",
37+
deps = [] + all_crate_deps(normal = True),
38+
)
39+
40+
alias(
41+
name = "expr-derive-impl",
42+
actual = "mz_expr_derive_impl",
43+
)
44+
45+
rust_test(
46+
name = "mz_expr_derive_impl_lib_tests",
47+
size = "medium",
48+
aliases = aliases(
49+
normal = True,
50+
normal_dev = True,
51+
proc_macro = True,
52+
proc_macro_dev = True,
53+
),
54+
compile_data = [],
55+
crate = ":mz_expr_derive_impl",
56+
crate_features = [
57+
"insta",
58+
"prettyplease",
59+
"test",
60+
],
61+
data = [],
62+
env = {},
63+
lint_config = ":lints",
64+
proc_macro_deps = [] + all_crate_deps(
65+
proc_macro = True,
66+
proc_macro_dev = True,
67+
),
68+
rustc_env = {},
69+
rustc_flags = [],
70+
version = "0.0.0",
71+
deps = ["//src/ore:mz_ore"] + all_crate_deps(
72+
normal = True,
73+
normal_dev = True,
74+
),
75+
)
76+
77+
rust_doc_test(
78+
name = "mz_expr_derive_impl_doc_test",
79+
crate = ":mz_expr_derive_impl",
80+
deps = ["//src/ore:mz_ore"] + all_crate_deps(
81+
normal = True,
82+
normal_dev = True,
83+
),
84+
)
85+
86+
extract_cargo_lints(
87+
name = "lints",
88+
manifest = "Cargo.toml",
89+
workspace = "@//:Cargo.toml",
90+
)

src/expr-derive-impl/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "mz-expr-derive-impl"
3+
description = "Implementations of derives for the core expression language for Materialize."
4+
version = "0.0.0"
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
publish = false
8+
9+
[lints]
10+
workspace = true
11+
12+
[dependencies]
13+
darling = "0.20.11"
14+
insta = { version = "1.42", optional = true, features = ["serde"] }
15+
prettyplease = { version = "0.2", optional = true }
16+
proc-macro2 = "1.0"
17+
quote = "1.0"
18+
syn = { version = "2.0", features = ["extra-traits"] }
19+
workspace-hack = { version = "0.0.0", path = "../workspace-hack", optional = true }
20+
21+
[dev-dependencies]
22+
insta = { version = "1.42", features = ["serde"] }
23+
mz-ore = { path = "../ore", features = ["test"] }
24+
prettyplease = "0.2"
25+
26+
[package.metadata.cargo-udeps.ignore]
27+
normal = ["workspace-hack"]
28+
29+
[features]
30+
default = ["workspace-hack"]
31+
test = ["prettyplease", "insta"]

0 commit comments

Comments
 (0)