-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(expr): support any
type in function signatures
#12262
Conversation
Can there be more details added to the PR description, on the background of this refactor? I thought previously we supported
Or is this different? |
I'll complete the description tomorrow. Simply put, we don't support the After this PR, we will have one - array_agg(int16) -> list
- array_agg(int32) -> list
- array_agg(int64) -> list
...
- array_agg(list) -> list
- array_agg(struct) -> list
+ array_agg(any) -> list And we will get the input as a - fn array_agg<'a>(state: Option<ListValue>, value: Option<impl ScalarRef<'a>>) -> ListValue {
+ fn array_agg<'a>(state: Option<ListValue>, value: Option<ScalarRefImpl<'a>>) -> ListValue { |
3fe5841
to
398e361
Compare
83bd0b0
to
362cc3c
Compare
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
362cc3c
to
5760603
Compare
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
e95e7bd
to
31e7c5a
Compare
May I ask what's the benefit? 👀 |
Avoiding generating too much code and slowing down compilation? if it counts. 🤡 |
@@ -35,39 +35,33 @@ fn string_to_array_inner<'a>( | |||
} | |||
|
|||
// Use cases shown in `e2e_test/batch/functions/string_to_array.slt.part` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, seems docslt is a good choice😁
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM!
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #12262 +/- ##
==========================================
- Coverage 69.41% 69.25% -0.16%
==========================================
Files 1473 1471 -2
Lines 242568 242507 -61
==========================================
- Hits 168376 167959 -417
- Misses 74192 74548 +356
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 47 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we deprecate *
after supporting any
? 🤔
bytea Bytea BytesArray Box<[u8]> &[u8] _ | ||
jsonb Jsonb JsonbArray JsonbVal JsonbRef<'_> _ | ||
anyarray List ListArray ListValue ListRef<'_> _ | ||
struct Struct StructArray StructValue StructRef<'_> _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why struct
is not anystruct
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of struct
doesn't matter. It is only used internally. In public API, users need to write a full struct schema, like struct<a: int, ...>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do write struct
in some places 🤪
#[aggregate("min(struct) -> auto", state = "ref")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad memory. 🤪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way, anystruct
seems to be a reasonable name.
I don't think so. The relationship between |
🤡 Hmmm, if so, shouldn't we prefer |
Not always, and in some cases, using |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Previously we use
DataTypeName
for types in function signatures. However:any
type. For functions containingany
type, such asarray_agg(any) -> anyarray
, currently we enumerate all types and generate a function for each specific type. (this is done by expanding the wildcard*
in the macro)varchar[]
. Currently there is only aDataTypeName::List
for array type, which is actually equivalent toanyarray
. It doesn't have sufficient information, so we have to manually implement type inference for such functions.To solve these problems, this PR introduces a new type
SigDataType
to replaceDataTypeName
in signatures:In
#[function]
macro:list
is renamed toanyarray
.any
is added. Its corresponding Rust type isScalarImpl
orScalarRefImpl<'_>
.For example:
when the return type is either
any
oranyarray
, the macro can automatically generate a type inference function based on the signature. Here are some examples:mode(any) -> any
:return_type = args[0]
array_agg(any) -> anyarray
:return_type = List(args[0])
array_access(anyarray, int32) -> any
:return_type = args[0].as_list()
array_distinct(anyarray) -> anyarray
:return_type = args[0]
The rules are following postgres documents:
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.