Merge pull request #47322 from evillique/running_difference

Add support for big int types to runningDifference() function
This commit is contained in:
Nikolay Degterinsky 2023-03-09 12:39:35 +01:00 committed by GitHub
commit 44531e5f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 1 deletions

View File

@ -70,7 +70,7 @@ private:
if (!has_prev_value)
{
dst[i] = is_first_line_zero ? 0 : src[i];
dst[i] = is_first_line_zero ? static_cast<Dst>(0) : static_cast<Dst>(src[i]);
prev = src[i];
has_prev_value = true;
}
@ -102,6 +102,10 @@ private:
f(UInt32());
else if (which.isUInt64())
f(UInt64());
else if (which.isUInt128())
f(UInt128());
else if (which.isUInt256())
f(UInt256());
else if (which.isInt8())
f(Int8());
else if (which.isInt16())
@ -110,6 +114,10 @@ private:
f(Int32());
else if (which.isInt64())
f(Int64());
else if (which.isInt128())
f(Int128());
else if (which.isInt256())
f(Int256());
else if (which.isFloat32())
f(Float32());
else if (which.isFloat64())

View File

@ -276,10 +276,14 @@ SELECT runningDifference(CAST( 0 AS Nullable(Int8)));
SELECT runningDifference(CAST( 0 AS Nullable(Int16)));
SELECT runningDifference(CAST( 0 AS Nullable(Int32)));
SELECT runningDifference(CAST( 0 AS Nullable(Int64)));
SELECT runningDifference(CAST( 0 AS Nullable(Int128)));
SELECT runningDifference(CAST( 0 AS Nullable(Int256)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt8)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt16)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt32)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt64)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt128)));
SELECT runningDifference(CAST( 0 AS Nullable(UInt256)));
SELECT runningDifference(CAST( 0 AS Nullable(Float32)));
SELECT runningDifference(CAST( 0 AS Nullable(Float64)));
SELECT runningDifference(CAST( 0 AS Nullable(Date)));
@ -288,10 +292,14 @@ SELECT runningDifference(CAST(NULL AS Nullable(Int8)));
SELECT runningDifference(CAST(NULL AS Nullable(Int16)));
SELECT runningDifference(CAST(NULL AS Nullable(Int32)));
SELECT runningDifference(CAST(NULL AS Nullable(Int64)));
SELECT runningDifference(CAST(NULL AS Nullable(Int128)));
SELECT runningDifference(CAST(NULL AS Nullable(Int256)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt8)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt16)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt32)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt64)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt128)));
SELECT runningDifference(CAST(NULL AS Nullable(UInt256));
SELECT runningDifference(CAST(NULL AS Nullable(Float32)));
SELECT runningDifference(CAST(NULL AS Nullable(Float64)));
SELECT runningDifference(CAST(NULL AS Nullable(Date)));

View File

@ -19,6 +19,30 @@
\N
\N
2
-
0
1
4
5
170141183460469231731687303715884105717
-
0
1
4
5
170141183460469231731687303715884105718
-
0
1
4
5
170141183460469231731687303715884105717
-
0
1
4
5
170141183460469231731687303715884105718
--Date Difference--
\N
\N

View File

@ -5,6 +5,14 @@ select '-';
select runningDifference(x) from (select arrayJoin([Null, 1]) as x);
select '-';
select runningDifference(x) from (select arrayJoin([Null, Null, 1, 3, Null, Null, 5]) as x);
select '-';
select runningDifference(x) from (select arrayJoin([0, 1, 5, 10, 170141183460469231731687303715884105727]::Array(UInt128)) as x);
select '-';
select runningDifference(x) from (select arrayJoin([0, 1, 5, 10, 170141183460469231731687303715884105728]::Array(UInt256)) as x);
select '-';
select runningDifference(x) from (select arrayJoin([0, 1, 5, 10, 170141183460469231731687303715884105727]::Array(Int128)) as x);
select '-';
select runningDifference(x) from (select arrayJoin([0, 1, 5, 10, 170141183460469231731687303715884105728]::Array(Int256)) as x);
select '--Date Difference--';
select runningDifference(x) from (select arrayJoin([Null, Null, toDate('1970-1-1'), toDate('1970-12-31'), Null, Null, toDate('2010-8-9')]) as x);
select '-';