Skip to content

Commit 0504214

Browse files
committed
Update snapshots
Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent 63c61e9 commit 0504214

File tree

121 files changed

+3596
-327
lines changed

Some content is hidden

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

121 files changed

+3596
-327
lines changed

src/expr/src/scalar/snapshots/mz_expr__scalar__func__age_timestamp.snap

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: src/expr/src/scalar/func.rs
3-
expression: "#[sqlfunc(\n is_monotone = (true, true),\n output_type = Interval,\n is_infix_op = false,\n sqlname = \"age\",\n propagates_nulls = true\n)]\nfn age_timestamp<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let a_ts = a.unwrap_timestamp();\n let b_ts = b.unwrap_timestamp();\n let age = a_ts.age(&b_ts)?;\n Ok(Datum::from(age))\n}\n"
3+
expression: "#[sqlfunc(\n is_monotone = \"(true, true)\",\n output_type = \"Interval\",\n sqlname = \"age\",\n propagates_nulls = true\n)]\nfn age_timestamp<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let a_ts = a.unwrap_timestamp();\n let b_ts = b.unwrap_timestamp();\n let age = a_ts.age(&b_ts)?;\n Ok(Datum::from(age))\n}\n"
44
---
55
#[derive(
66
proptest_derive::Arbitrary,
@@ -49,9 +49,6 @@ impl<'a> crate::func::binary::EagerBinaryFunc<'a> for AgeTimestamp {
4949
fn introduces_nulls(&self) -> bool {
5050
<Interval as ::mz_repr::DatumType<'_, ()>>::nullable()
5151
}
52-
fn is_infix_op(&self) -> bool {
53-
false
54-
}
5552
fn is_monotone(&self) -> (bool, bool) {
5653
(true, true)
5754
}

src/expr/src/scalar/snapshots/mz_expr__scalar__func__age_timestamptz.snap

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: src/expr/src/scalar/func.rs
3-
expression: "#[sqlfunc(\n is_monotone = (true, true),\n output_type = Interval,\n is_infix_op = false,\n sqlname = \"age\",\n propagates_nulls = true\n)]\nfn age_timestamptz<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let a_ts = a.unwrap_timestamptz();\n let b_ts = b.unwrap_timestamptz();\n let age = a_ts.age(&b_ts)?;\n Ok(Datum::from(age))\n}\n"
3+
expression: "#[sqlfunc(\n is_monotone = \"(true, true)\",\n output_type = \"Interval\",\n sqlname = \"age\",\n propagates_nulls = true\n)]\nfn age_timestamptz<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let a_ts = a.unwrap_timestamptz();\n let b_ts = b.unwrap_timestamptz();\n let age = a_ts.age(&b_ts)?;\n Ok(Datum::from(age))\n}\n"
44
---
55
#[derive(
66
proptest_derive::Arbitrary,
@@ -49,9 +49,6 @@ impl<'a> crate::func::binary::EagerBinaryFunc<'a> for AgeTimestamptz {
4949
fn introduces_nulls(&self) -> bool {
5050
<Interval as ::mz_repr::DatumType<'_, ()>>::nullable()
5151
}
52-
fn is_infix_op(&self) -> bool {
53-
false
54-
}
5552
fn is_monotone(&self) -> (bool, bool) {
5653
(true, true)
5754
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
source: src/expr/src/scalar/func.rs
3+
expression: "#[sqlfunc(\n output_type_expr = \"input_type_a.scalar_type.without_modifiers().nullable(true)\",\n is_infix_op = true,\n sqlname = \"||\",\n propagates_nulls = false,\n introduces_nulls = false\n)]\nfn array_array_concat<'a>(\n a: Datum<'a>,\n b: Datum<'a>,\n temp_storage: &'a RowArena,\n) -> Result<Datum<'a>, EvalError> {\n if a.is_null() {\n return Ok(b);\n } else if b.is_null() {\n return Ok(a);\n }\n let a_array = a.unwrap_array();\n let b_array = b.unwrap_array();\n let a_dims: Vec<ArrayDimension> = a_array.dims().into_iter().collect();\n let b_dims: Vec<ArrayDimension> = b_array.dims().into_iter().collect();\n let a_ndims = a_dims.len();\n let b_ndims = b_dims.len();\n if a_ndims == 0 {\n return Ok(b);\n } else if b_ndims == 0 {\n return Ok(a);\n }\n #[allow(clippy::as_conversions)]\n if (a_ndims as isize - b_ndims as isize).abs() > 1 {\n return Err(EvalError::IncompatibleArrayDimensions {\n dims: Some((a_ndims, b_ndims)),\n });\n }\n let mut dims;\n match a_ndims.cmp(&b_ndims) {\n Ordering::Equal => {\n if &a_dims[1..] != &b_dims[1..] {\n return Err(EvalError::IncompatibleArrayDimensions {\n dims: None,\n });\n }\n dims = vec![\n ArrayDimension { lower_bound : a_dims[0].lower_bound, length : a_dims[0]\n .length + b_dims[0].length, }\n ];\n dims.extend(&a_dims[1..]);\n }\n Ordering::Less => {\n if &a_dims[..] != &b_dims[1..] {\n return Err(EvalError::IncompatibleArrayDimensions {\n dims: None,\n });\n }\n dims = vec![\n ArrayDimension { lower_bound : b_dims[0].lower_bound, length : b_dims[0]\n .length + 1, }\n ];\n dims.extend(a_dims);\n }\n Ordering::Greater => {\n if &a_dims[1..] != &b_dims[..] {\n return Err(EvalError::IncompatibleArrayDimensions {\n dims: None,\n });\n }\n dims = vec![\n ArrayDimension { lower_bound : a_dims[0].lower_bound, length : a_dims[0]\n .length + 1, }\n ];\n dims.extend(b_dims);\n }\n }\n let elems = a_array.elements().iter().chain(b_array.elements().iter());\n Ok(temp_storage.try_make_datum(|packer| packer.try_push_array(&dims, elems))?)\n}\n"
4+
---
5+
#[derive(
6+
proptest_derive::Arbitrary,
7+
Ord,
8+
PartialOrd,
9+
Clone,
10+
Debug,
11+
Eq,
12+
PartialEq,
13+
serde::Serialize,
14+
serde::Deserialize,
15+
Hash,
16+
mz_lowertest::MzReflect
17+
)]
18+
pub struct ArrayArrayConcat;
19+
impl<'a> crate::func::binary::EagerBinaryFunc<'a> for ArrayArrayConcat {
20+
type Input1 = Datum<'a>;
21+
type Input2 = Datum<'a>;
22+
type Output = Result<Datum<'a>, EvalError>;
23+
fn call(
24+
&self,
25+
a: Self::Input1,
26+
b: Self::Input2,
27+
temp_storage: &'a mz_repr::RowArena,
28+
) -> Self::Output {
29+
array_array_concat(a, b, temp_storage)
30+
}
31+
fn output_type(
32+
&self,
33+
input_type_a: mz_repr::ColumnType,
34+
input_type_b: mz_repr::ColumnType,
35+
) -> mz_repr::ColumnType {
36+
use mz_repr::AsColumnType;
37+
let output = input_type_a.scalar_type.without_modifiers().nullable(true);
38+
let propagates_nulls = crate::func::binary::EagerBinaryFunc::propagates_nulls(
39+
self,
40+
);
41+
let nullable = output.nullable;
42+
output
43+
.nullable(
44+
nullable
45+
|| (propagates_nulls
46+
&& (input_type_a.nullable || input_type_b.nullable)),
47+
)
48+
}
49+
fn introduces_nulls(&self) -> bool {
50+
false
51+
}
52+
fn is_infix_op(&self) -> bool {
53+
true
54+
}
55+
fn propagates_nulls(&self) -> bool {
56+
false
57+
}
58+
}
59+
impl std::fmt::Display for ArrayArrayConcat {
60+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
61+
f.write_str("||")
62+
}
63+
}
64+
fn array_array_concat<'a>(
65+
a: Datum<'a>,
66+
b: Datum<'a>,
67+
temp_storage: &'a RowArena,
68+
) -> Result<Datum<'a>, EvalError> {
69+
if a.is_null() {
70+
return Ok(b);
71+
} else if b.is_null() {
72+
return Ok(a);
73+
}
74+
let a_array = a.unwrap_array();
75+
let b_array = b.unwrap_array();
76+
let a_dims: Vec<ArrayDimension> = a_array.dims().into_iter().collect();
77+
let b_dims: Vec<ArrayDimension> = b_array.dims().into_iter().collect();
78+
let a_ndims = a_dims.len();
79+
let b_ndims = b_dims.len();
80+
if a_ndims == 0 {
81+
return Ok(b);
82+
} else if b_ndims == 0 {
83+
return Ok(a);
84+
}
85+
#[allow(clippy::as_conversions)]
86+
if (a_ndims as isize - b_ndims as isize).abs() > 1 {
87+
return Err(EvalError::IncompatibleArrayDimensions {
88+
dims: Some((a_ndims, b_ndims)),
89+
});
90+
}
91+
let mut dims;
92+
match a_ndims.cmp(&b_ndims) {
93+
Ordering::Equal => {
94+
if &a_dims[1..] != &b_dims[1..] {
95+
return Err(EvalError::IncompatibleArrayDimensions {
96+
dims: None,
97+
});
98+
}
99+
dims = vec![
100+
ArrayDimension { lower_bound : a_dims[0].lower_bound, length : a_dims[0]
101+
.length + b_dims[0].length, }
102+
];
103+
dims.extend(&a_dims[1..]);
104+
}
105+
Ordering::Less => {
106+
if &a_dims[..] != &b_dims[1..] {
107+
return Err(EvalError::IncompatibleArrayDimensions {
108+
dims: None,
109+
});
110+
}
111+
dims = vec![
112+
ArrayDimension { lower_bound : b_dims[0].lower_bound, length : b_dims[0]
113+
.length + 1, }
114+
];
115+
dims.extend(a_dims);
116+
}
117+
Ordering::Greater => {
118+
if &a_dims[1..] != &b_dims[..] {
119+
return Err(EvalError::IncompatibleArrayDimensions {
120+
dims: None,
121+
});
122+
}
123+
dims = vec![
124+
ArrayDimension { lower_bound : a_dims[0].lower_bound, length : a_dims[0]
125+
.length + 1, }
126+
];
127+
dims.extend(b_dims);
128+
}
129+
}
130+
let elems = a_array.elements().iter().chain(b_array.elements().iter());
131+
Ok(temp_storage.try_make_datum(|packer| packer.try_push_array(&dims, elems))?)
132+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
source: src/expr/src/scalar/func.rs
3+
expression: "#[sqlfunc(\n output_type = \"bool\",\n is_infix_op = true,\n sqlname = \"array_contains\",\n propagates_nulls = true,\n introduces_nulls = false\n)]\nfn array_contains<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {\n let array = Datum::unwrap_array(&b);\n Datum::from(array.elements().iter().any(|e| e == a))\n}\n"
4+
---
5+
#[derive(
6+
proptest_derive::Arbitrary,
7+
Ord,
8+
PartialOrd,
9+
Clone,
10+
Debug,
11+
Eq,
12+
PartialEq,
13+
serde::Serialize,
14+
serde::Deserialize,
15+
Hash,
16+
mz_lowertest::MzReflect
17+
)]
18+
pub struct ArrayContains;
19+
impl<'a> crate::func::binary::EagerBinaryFunc<'a> for ArrayContains {
20+
type Input1 = Datum<'a>;
21+
type Input2 = Datum<'a>;
22+
type Output = Datum<'a>;
23+
fn call(
24+
&self,
25+
a: Self::Input1,
26+
b: Self::Input2,
27+
temp_storage: &'a mz_repr::RowArena,
28+
) -> Self::Output {
29+
array_contains(a, b)
30+
}
31+
fn output_type(
32+
&self,
33+
input_type_a: mz_repr::ColumnType,
34+
input_type_b: mz_repr::ColumnType,
35+
) -> mz_repr::ColumnType {
36+
use mz_repr::AsColumnType;
37+
let output = <bool>::as_column_type();
38+
let propagates_nulls = crate::func::binary::EagerBinaryFunc::propagates_nulls(
39+
self,
40+
);
41+
let nullable = output.nullable;
42+
output
43+
.nullable(
44+
nullable
45+
|| (propagates_nulls
46+
&& (input_type_a.nullable || input_type_b.nullable)),
47+
)
48+
}
49+
fn introduces_nulls(&self) -> bool {
50+
false
51+
}
52+
fn is_infix_op(&self) -> bool {
53+
true
54+
}
55+
fn propagates_nulls(&self) -> bool {
56+
true
57+
}
58+
}
59+
impl std::fmt::Display for ArrayContains {
60+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
61+
f.write_str("array_contains")
62+
}
63+
}
64+
fn array_contains<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {
65+
let array = Datum::unwrap_array(&b);
66+
Datum::from(array.elements().iter().any(|e| e == a))
67+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
source: src/expr/src/scalar/func.rs
3+
expression: "#[sqlfunc(\n output_type = \"bool\",\n is_infix_op = true,\n sqlname = \"@>\",\n propagates_nulls = true,\n introduces_nulls = false\n)]\nfn array_contains_array<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {\n let a = a.unwrap_array().elements();\n let b = b.unwrap_array().elements();\n if b.iter().contains(&Datum::Null) {\n Datum::False\n } else {\n b.iter().all(|item_b| a.iter().any(|item_a| item_a == item_b)).into()\n }\n}\n"
4+
---
5+
#[derive(
6+
proptest_derive::Arbitrary,
7+
Ord,
8+
PartialOrd,
9+
Clone,
10+
Debug,
11+
Eq,
12+
PartialEq,
13+
serde::Serialize,
14+
serde::Deserialize,
15+
Hash,
16+
mz_lowertest::MzReflect
17+
)]
18+
pub struct ArrayContainsArray;
19+
impl<'a> crate::func::binary::EagerBinaryFunc<'a> for ArrayContainsArray {
20+
type Input1 = Datum<'a>;
21+
type Input2 = Datum<'a>;
22+
type Output = Datum<'a>;
23+
fn call(
24+
&self,
25+
a: Self::Input1,
26+
b: Self::Input2,
27+
temp_storage: &'a mz_repr::RowArena,
28+
) -> Self::Output {
29+
array_contains_array(a, b)
30+
}
31+
fn output_type(
32+
&self,
33+
input_type_a: mz_repr::ColumnType,
34+
input_type_b: mz_repr::ColumnType,
35+
) -> mz_repr::ColumnType {
36+
use mz_repr::AsColumnType;
37+
let output = <bool>::as_column_type();
38+
let propagates_nulls = crate::func::binary::EagerBinaryFunc::propagates_nulls(
39+
self,
40+
);
41+
let nullable = output.nullable;
42+
output
43+
.nullable(
44+
nullable
45+
|| (propagates_nulls
46+
&& (input_type_a.nullable || input_type_b.nullable)),
47+
)
48+
}
49+
fn introduces_nulls(&self) -> bool {
50+
false
51+
}
52+
fn is_infix_op(&self) -> bool {
53+
true
54+
}
55+
fn propagates_nulls(&self) -> bool {
56+
true
57+
}
58+
}
59+
impl std::fmt::Display for ArrayContainsArray {
60+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
61+
f.write_str("@>")
62+
}
63+
}
64+
fn array_contains_array<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {
65+
let a = a.unwrap_array().elements();
66+
let b = b.unwrap_array().elements();
67+
if b.iter().contains(&Datum::Null) {
68+
Datum::False
69+
} else {
70+
b.iter().all(|item_b| a.iter().any(|item_a| item_a == item_b)).into()
71+
}
72+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
source: src/expr/src/scalar/func.rs
3+
expression: "#[sqlfunc(\n output_type = \"bool\",\n is_infix_op = true,\n sqlname = \"<@\",\n propagates_nulls = true,\n introduces_nulls = false\n)]\nfn array_contains_array_rev<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {\n array_contains_array(a, b)\n}\n"
4+
---
5+
#[derive(
6+
proptest_derive::Arbitrary,
7+
Ord,
8+
PartialOrd,
9+
Clone,
10+
Debug,
11+
Eq,
12+
PartialEq,
13+
serde::Serialize,
14+
serde::Deserialize,
15+
Hash,
16+
mz_lowertest::MzReflect
17+
)]
18+
pub struct ArrayContainsArrayRev;
19+
impl<'a> crate::func::binary::EagerBinaryFunc<'a> for ArrayContainsArrayRev {
20+
type Input1 = Datum<'a>;
21+
type Input2 = Datum<'a>;
22+
type Output = Datum<'a>;
23+
fn call(
24+
&self,
25+
a: Self::Input1,
26+
b: Self::Input2,
27+
temp_storage: &'a mz_repr::RowArena,
28+
) -> Self::Output {
29+
array_contains_array_rev(a, b)
30+
}
31+
fn output_type(
32+
&self,
33+
input_type_a: mz_repr::ColumnType,
34+
input_type_b: mz_repr::ColumnType,
35+
) -> mz_repr::ColumnType {
36+
use mz_repr::AsColumnType;
37+
let output = <bool>::as_column_type();
38+
let propagates_nulls = crate::func::binary::EagerBinaryFunc::propagates_nulls(
39+
self,
40+
);
41+
let nullable = output.nullable;
42+
output
43+
.nullable(
44+
nullable
45+
|| (propagates_nulls
46+
&& (input_type_a.nullable || input_type_b.nullable)),
47+
)
48+
}
49+
fn introduces_nulls(&self) -> bool {
50+
false
51+
}
52+
fn is_infix_op(&self) -> bool {
53+
true
54+
}
55+
fn propagates_nulls(&self) -> bool {
56+
true
57+
}
58+
}
59+
impl std::fmt::Display for ArrayContainsArrayRev {
60+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
61+
f.write_str("<@")
62+
}
63+
}
64+
fn array_contains_array_rev<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {
65+
array_contains_array(a, b)
66+
}

src/expr/src/scalar/snapshots/mz_expr__scalar__func__array_length.snap

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: src/expr/src/scalar/func.rs
3-
expression: "#[sqlfunc(\n is_monotone = \"(false, false)\",\n output_type = \"Option<i32>\",\n is_infix_op = true,\n sqlname = \"array_length\",\n propagates_nulls = true,\n introduces_nulls = true\n)]\nfn array_length<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let i = match usize::try_from(b.unwrap_int64()) {\n Ok(0) | Err(_) => return Ok(Datum::Null),\n Ok(n) => n - 1,\n };\n Ok(\n match a.unwrap_array().dims().into_iter().nth(i) {\n None => Datum::Null,\n Some(dim) => {\n Datum::Int32(\n dim\n .length\n .try_into()\n .map_err(|_| EvalError::Int32OutOfRange(\n dim.length.to_string().into(),\n ))?,\n )\n }\n },\n )\n}\n"
3+
expression: "#[sqlfunc(\n output_type = \"Option<i32>\",\n is_infix_op = true,\n sqlname = \"array_length\",\n propagates_nulls = true,\n introduces_nulls = true\n)]\nfn array_length<'a>(a: Datum<'a>, b: Datum<'a>) -> Result<Datum<'a>, EvalError> {\n let i = match usize::try_from(b.unwrap_int64()) {\n Ok(0) | Err(_) => return Ok(Datum::Null),\n Ok(n) => n - 1,\n };\n Ok(\n match a.unwrap_array().dims().into_iter().nth(i) {\n None => Datum::Null,\n Some(dim) => {\n Datum::Int32(\n dim\n .length\n .try_into()\n .map_err(|_| EvalError::Int32OutOfRange(\n dim.length.to_string().into(),\n ))?,\n )\n }\n },\n )\n}\n"
44
---
55
#[derive(
66
proptest_derive::Arbitrary,
@@ -52,9 +52,6 @@ impl<'a> crate::func::binary::EagerBinaryFunc<'a> for ArrayLength {
5252
fn is_infix_op(&self) -> bool {
5353
true
5454
}
55-
fn is_monotone(&self) -> (bool, bool) {
56-
(false, false)
57-
}
5855
fn propagates_nulls(&self) -> bool {
5956
true
6057
}

0 commit comments

Comments
 (0)