[Enhancement] lead/lag/first_value/last_value support array type (#63547)
Signed-off-by: satanson <ranpanf@gmail.com>
This commit is contained in:
parent
d0b7c2226f
commit
78945fde78
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
#include <type_traits>
|
||||
|
||||
#include "column/array_column.h"
|
||||
#include "column/type_traits.h"
|
||||
#include "gutil/strings/fastmem.h"
|
||||
#include "types/logical_type.h"
|
||||
|
||||
namespace starrocks {
|
||||
|
||||
// Type traits from aggregate functions
|
||||
template <LogicalType lt, typename = guard::Guard>
|
||||
struct AggDataTypeTraits {};
|
||||
|
|
@ -41,6 +41,7 @@ struct AggDataTypeTraits<lt, FixedLengthLTGuard<lt>> {
|
|||
static RefType get_ref(const ValueType& value) { return value; }
|
||||
|
||||
static void update_max(ValueType& current, const RefType& input) { current = std::max<ValueType>(current, input); }
|
||||
|
||||
static void update_min(ValueType& current, const RefType& input) { current = std::min<ValueType>(current, input); }
|
||||
|
||||
static bool is_equal(const RefType& lhs, const RefType& rhs) { return lhs == rhs; }
|
||||
|
|
@ -56,7 +57,9 @@ struct AggDataTypeTraits<lt, ObjectFamilyLTGuard<lt>> {
|
|||
using RefType = RunTimeCppType<lt>;
|
||||
|
||||
static void assign_value(ValueType& value, RefType ref) { value = *ref; }
|
||||
|
||||
static void assign_value(ColumnType* column, size_t row, const RefType& ref) { *column->get_object(row) = *ref; }
|
||||
|
||||
static void assign_value(ColumnType* column, size_t row, const ValueType& ref) { *column->get_object(row) = ref; }
|
||||
|
||||
static void append_value(ColumnType* column, const ValueType& value) { column->append(&value); }
|
||||
|
|
@ -65,12 +68,47 @@ struct AggDataTypeTraits<lt, ObjectFamilyLTGuard<lt>> {
|
|||
static const RefType get_row_ref(const ColumnType& column, size_t row) { return column.get_object(row); }
|
||||
|
||||
static void update_max(ValueType& current, const RefType& input) { current = std::max<ValueType>(current, *input); }
|
||||
|
||||
static void update_min(ValueType& current, const RefType& input) { current = std::min<ValueType>(current, *input); }
|
||||
|
||||
static bool is_equal(const RefType& lhs, const RefType& rhs) { return *lhs == *rhs; }
|
||||
static bool equals(const ValueType& lhs, const RefType& rhs) { return lhs == *rhs; }
|
||||
};
|
||||
|
||||
// For pointer ref types
|
||||
template <LogicalType lt>
|
||||
struct AggDataTypeTraits<lt, ArrayGuard<lt>> {
|
||||
using CppType = RunTimeCppType<lt>;
|
||||
using ColumnType = RunTimeColumnType<lt>;
|
||||
using ValueType = typename ColumnType::MutablePtr;
|
||||
|
||||
struct RefType {
|
||||
const ColumnType* column;
|
||||
const size_t row;
|
||||
|
||||
RefType(const ColumnType* c, size_t r) : column(c), row(r) {}
|
||||
};
|
||||
|
||||
static void assign_value(ValueType& value, const RefType& ref) {
|
||||
value = ArrayColumn::static_pointer_cast(ref.column->clone_empty());
|
||||
value->append_datum(ref.column->get(ref.row).template get<CppType>());
|
||||
}
|
||||
|
||||
static void append_value(ColumnType* column, const ValueType& value) {
|
||||
column->append_datum(value->get(0).template get<CppType>());
|
||||
}
|
||||
|
||||
static RefType get_row_ref(const ColumnType& column, size_t row) { return RefType(&column, row); }
|
||||
|
||||
static bool is_equal(const ValueType& lhs, const ValueType& rhs) {
|
||||
return lhs->get(0).template get<CppType>() == rhs->get(0).template get<CppType>();
|
||||
}
|
||||
|
||||
static bool equals(const ValueType& lhs, const ValueType& rhs) {
|
||||
return lhs->get(0).template get<CppType>() == rhs->get(0).template get<CppType>();
|
||||
}
|
||||
};
|
||||
|
||||
template <LogicalType lt>
|
||||
struct AggDataTypeTraits<lt, StringLTGuard<lt>> {
|
||||
using ColumnType = RunTimeColumnType<lt>;
|
||||
|
|
@ -96,6 +134,7 @@ struct AggDataTypeTraits<lt, StringLTGuard<lt>> {
|
|||
memcpy(current.data(), input.data, input.size);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_min(ValueType& current, const RefType& input) {
|
||||
if (Slice(current.data(), current.size()).compare(input) > 0) {
|
||||
current.resize(input.size);
|
||||
|
|
@ -110,5 +149,4 @@ template <LogicalType lt>
|
|||
using AggDataValueType = typename AggDataTypeTraits<lt>::ValueType;
|
||||
template <LogicalType lt>
|
||||
using AggDataRefType = typename AggDataTypeTraits<lt>::RefType;
|
||||
|
||||
} // namespace starrocks
|
||||
} // namespace starrocks
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
TYPE_BIGINT, TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE,
|
||||
TYPE_VARCHAR, TYPE_CHAR, TYPE_DATE, TYPE_DATETIME,
|
||||
TYPE_DECIMALV2, TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128,
|
||||
TYPE_DECIMAL256, TYPE_HLL, TYPE_OBJECT};
|
||||
TYPE_DECIMAL256, TYPE_HLL, TYPE_OBJECT, TYPE_ARRAY};
|
||||
return kTypes;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace starrocks {
|
|||
struct WindowDispatcher {
|
||||
template <LogicalType lt>
|
||||
void operator()(AggregateFuncResolver* resolver) {
|
||||
if constexpr (lt_is_aggregate<lt> || is_object_type(lt)) {
|
||||
if constexpr (lt_is_aggregate<lt> || is_object_type(lt) || lt_is_array<lt>) {
|
||||
resolver->add_aggregate_mapping_notnull<lt, lt>(
|
||||
"first_value", true, AggregateFactory::MakeFirstValueWindowFunction<lt, false>());
|
||||
// use first_value_in for first_value with ingnore nulls.
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "column/array_column.h"
|
||||
#include "column/column_helper.h"
|
||||
#include "column/nullable_column.h"
|
||||
#include "column/vectorized_fwd.h"
|
||||
|
|
@ -101,6 +102,10 @@ struct ValueWindowStrategy<LT, JsonGuard<LT>> {
|
|||
/// The dst Object column hasn't been resized.
|
||||
static constexpr bool use_append = true;
|
||||
};
|
||||
template <LogicalType LT>
|
||||
struct ValueWindowStrategy<LT, ArrayGuard<LT>> {
|
||||
static constexpr bool use_append = true;
|
||||
};
|
||||
|
||||
template <LogicalType LT, typename State, typename T = RunTimeCppType<LT>>
|
||||
class ValueWindowFunction : public WindowFunction<State> {
|
||||
|
|
@ -124,7 +129,7 @@ public:
|
|||
|
||||
Column* data_column = nullable_column->mutable_data_column();
|
||||
auto* column = down_cast<InputColumnType*>(data_column);
|
||||
auto value = AggregateFunctionStateHelper<State>::data(state).value;
|
||||
auto& value = AggregateFunctionStateHelper<State>::data(state).value;
|
||||
for (size_t i = start; i < end; ++i) {
|
||||
AggDataTypeTraits<LT>::append_value(column, value);
|
||||
}
|
||||
|
|
@ -562,8 +567,14 @@ class LeadLagWindowFunction final : public ValueWindowFunction<LT, LeadLagState<
|
|||
if (default_column->is_nullable()) {
|
||||
this->data(state).default_is_null = true;
|
||||
} else {
|
||||
auto value = ColumnHelper::get_const_value<LT>(arg2);
|
||||
AggDataTypeTraits<LT>::assign_value(this->data(state).default_value, value);
|
||||
if constexpr (lt_is_array<LT>) {
|
||||
const auto* column = down_cast<const ArrayColumn*>(ColumnHelper::get_data_column(arg2));
|
||||
AggDataTypeTraits<LT>::assign_value(this->data(state).default_value,
|
||||
AggDataTypeTraits<LT>::get_row_ref(*column, 0));
|
||||
} else {
|
||||
auto value = ColumnHelper::get_const_value<LT>(arg2);
|
||||
AggDataTypeTraits<LT>::assign_value(this->data(state).default_value, value);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (ignoreNulls) {
|
||||
|
|
@ -669,7 +680,13 @@ class LeadLagWindowFunction final : public ValueWindowFunction<LT, LeadLagState<
|
|||
if (this->data(state).default_is_null) {
|
||||
this->data(state).is_null = true;
|
||||
} else {
|
||||
this->data(state).value = this->data(state).default_value;
|
||||
if constexpr (lt_is_array<LT>) {
|
||||
AggDataTypeTraits<LT>::assign_value(
|
||||
this->data(state).value,
|
||||
AggDataTypeTraits<LT>::get_row_ref(*this->data(state).default_value, 0));
|
||||
} else {
|
||||
this->data(state).value = this->data(state).default_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const Column* data_column = ColumnHelper::get_data_column(columns[0]);
|
||||
|
|
@ -686,7 +703,13 @@ class LeadLagWindowFunction final : public ValueWindowFunction<LT, LeadLagState<
|
|||
this->data(state).is_null = true;
|
||||
} else {
|
||||
this->data(state).is_null = false;
|
||||
this->data(state).value = this->data(state).default_value;
|
||||
if constexpr (lt_is_array<LT>) {
|
||||
AggDataTypeTraits<LT>::assign_value(
|
||||
this->data(state).value,
|
||||
AggDataTypeTraits<LT>::get_row_ref(*this->data(state).default_value, 0));
|
||||
} else {
|
||||
this->data(state).value = this->data(state).default_value;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FunctionSet {
|
||||
|
|
@ -1387,12 +1388,7 @@ public class FunctionSet {
|
|||
addBuiltin(AggregateFunction.createBuiltin(COLUMN_COMPRESSED_SIZE, Lists.newArrayList(Type.ANY_ELEMENT),
|
||||
Type.BIGINT, Type.BIGINT, false, false, false));
|
||||
|
||||
for (Type t : Type.getSupportedTypes()) {
|
||||
// null/char/time is handled through type promotion
|
||||
// TODO: array/json/pseudo is not supported yet
|
||||
if (!t.canBeWindowFunctionArgumentTypes()) {
|
||||
continue;
|
||||
}
|
||||
Consumer<Type> registerLeadLagFunctions = t -> {
|
||||
addBuiltin(AggregateFunction.createAnalyticBuiltin(
|
||||
FIRST_VALUE, Lists.newArrayList(t), t, t));
|
||||
// Implements FIRST_VALUE for some windows that require rewrites during planning.
|
||||
|
|
@ -1417,6 +1413,17 @@ public class FunctionSet {
|
|||
LEAD, Lists.newArrayList(t), t, t));
|
||||
addBuiltin(AggregateFunction.createAnalyticBuiltin(
|
||||
LEAD, Lists.newArrayList(t, Type.BIGINT), t, t));
|
||||
};
|
||||
for (Type t : Type.getSupportedTypes()) {
|
||||
// null/char/time is handled through type promotion
|
||||
// TODO: array/json/pseudo is not supported yet
|
||||
if (!t.canBeWindowFunctionArgumentTypes()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Type arrayType = new ArrayType(t);
|
||||
registerLeadLagFunctions.accept(t);
|
||||
registerLeadLagFunctions.accept(arrayType);
|
||||
}
|
||||
|
||||
for (Type t : HISTOGRAM_TYPE) {
|
||||
|
|
|
|||
|
|
@ -326,7 +326,8 @@ class DecodeContext {
|
|||
List<ScalarOperator> newChildren = visitList(call.getChildren(), hasChange);
|
||||
|
||||
if (call.getFunction() instanceof AggregateFunction) {
|
||||
Type[] argTypes = new Type[] {Type.INT};
|
||||
Type argType = newChildren.get(0).getType().isArrayType() ? new ArrayType(Type.INT) : Type.INT;
|
||||
Type[] argTypes = new Type[] {argType};
|
||||
Function fn = Expr.getBuiltinFunction(call.getFnName(), argTypes, Function.CompareMode.IS_SUPERTYPE_OF);
|
||||
// min/max function: will rewrite all stage, return type is dict type
|
||||
if (FunctionSet.MAX.equals(call.getFnName()) || FunctionSet.MIN.equals(call.getFnName())) {
|
||||
|
|
|
|||
|
|
@ -316,13 +316,10 @@ public class ArrayTypeTest extends PlanTestBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testArrayWindowFunction() {
|
||||
public void testArrayWindowFunction() throws Exception {
|
||||
for (String fnName : Sets.newHashSet(AnalyticExpr.LASTVALUE, AnalyticExpr.FIRSTVALUE)) {
|
||||
String sql = String.format("select %s(v3) over() from tarray", fnName.toLowerCase());
|
||||
Throwable exception = assertThrows(SemanticException.class, () ->
|
||||
getFragmentPlan(sql));
|
||||
assertThat(exception.getMessage(), containsString(
|
||||
String.format("No matching function with signature: %s(array<bigint(20)>)", fnName.toLowerCase())));
|
||||
getFragmentPlan(sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1124,4 +1124,28 @@ public class LowCardinalityArrayTest extends PlanTestBase {
|
|||
" | window: ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING\n" +
|
||||
" | cardinality: 1"), plan);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeadLagUsingArrayAsParameterType() throws Exception {
|
||||
|
||||
String sql = "select /*+SET_VAR(array_low_cardinality_optimize=true)*/ v1, v2," +
|
||||
" lead(a1) over(partition by v1 order by v2)\n" +
|
||||
" from s1;";
|
||||
String plan = getVerboseExplain(sql);
|
||||
Assertions.assertTrue(plan.contains(" 4:Decode\n" +
|
||||
" | <dict id 7> : <string id 5>\n" +
|
||||
" | cardinality: 1\n" +
|
||||
" | \n" +
|
||||
" 3:Project\n" +
|
||||
" | output columns:\n" +
|
||||
" | 1 <-> [1: v1, BIGINT, true]\n" +
|
||||
" | 2 <-> [2: v2, INT, true]\n" +
|
||||
" | 7 <-> [7: lead(3: a1, 1, null), ARRAY<INT>, true]\n" +
|
||||
" | cardinality: 1\n" +
|
||||
" | \n" +
|
||||
" 2:ANALYTIC\n" +
|
||||
" | functions: [, lead[([6: a1, ARRAY<INT>, true], 1, NULL); " +
|
||||
"args: INVALID_TYPE; result: ARRAY<INT>; args nullable: true; result nullable: true], ]\n" +
|
||||
" | partition by: [1: v1, BIGINT, true]"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ package com.starrocks.sql.plan;
|
|||
|
||||
import com.starrocks.common.FeConstants;
|
||||
import com.starrocks.sql.analyzer.SemanticException;
|
||||
import com.starrocks.utframe.StarRocksAssert;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
|
@ -24,6 +26,28 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
|
||||
public class WindowTest extends PlanTestBase {
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
PlanTestBase.beforeClass();
|
||||
StarRocksAssert starRocksAssert = new StarRocksAssert(connectContext);
|
||||
starRocksAssert.withTable("CREATE TABLE `s1` ( \n" +
|
||||
" `v1` bigint(20) NULL COMMENT \"\", \n" +
|
||||
" `v2` int(11) NULL COMMENT \"\", \n" +
|
||||
" `a1` array<varchar(65533)> NULL COMMENT \"\", \n" +
|
||||
" `a2` array<varchar(65533)> NULL COMMENT \"\" \n" +
|
||||
") ENGINE=OLAP \n" +
|
||||
"DUPLICATE KEY(`v1`) \n" +
|
||||
"COMMENT \"OLAP\" \n" +
|
||||
"DISTRIBUTED BY HASH(`v1`) BUCKETS 10 \n" +
|
||||
"PROPERTIES ( \n" +
|
||||
"\"replication_num\" = \"1\", \n" +
|
||||
"\"in_memory\" = \"false\", \n" +
|
||||
"\"enable_persistent_index\" = \"true\", \n" +
|
||||
"\"replicated_storage\" = \"false\", \n" +
|
||||
"\"light_schema_change\" = \"true\", \n" +
|
||||
"\"compression\" = \"LZ4\" \n" +
|
||||
");");
|
||||
}
|
||||
@Test
|
||||
public void testLagWindowFunction() throws Exception {
|
||||
String sql = "select lag(id_datetime, 1, '2020-01-01') over(partition by t1c) from test_all_type;";
|
||||
|
|
@ -1644,4 +1668,45 @@ public class WindowTest extends PlanTestBase {
|
|||
String plan = getFragmentPlan(sql);
|
||||
assertContains(plan, "window: ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeadLagUsingArrayAsParameterType() throws Exception {
|
||||
|
||||
String sql = "select v1, v2," +
|
||||
" lead(a1) over(partition by v1 order by v2),\n" +
|
||||
" lag(a1) over(partition by v1 order by v2),\n" +
|
||||
" lead(a1 ignore nulls) over(partition by v1 order by v2),\n" +
|
||||
" lag(a1 ignore nulls) over(partition by v1 order by v2),\n" +
|
||||
" first_value(a1) over(partition by v1 order by v2),\n" +
|
||||
" last_value(a1) over(partition by v1 order by v2),\n" +
|
||||
" first_value(a1 ignore nulls) over(partition by v1 order by v2),\n" +
|
||||
" last_value(a1 ignore nulls) over(partition by v1 order by v2)\n" +
|
||||
"from s1;";
|
||||
String plan = getVerboseExplain(sql);
|
||||
Assertions.assertTrue(plan.contains(" 4:ANALYTIC\n" +
|
||||
" | functions: [, first_value[([3: a1, ARRAY<VARCHAR(65533)>, true]); " +
|
||||
"args: INVALID_TYPE; result: ARRAY<VARCHAR>; args nullable: true; result nullable: true], ], " +
|
||||
"[, last_value[([3: a1, ARRAY<VARCHAR(65533)>, true]); " +
|
||||
"args: INVALID_TYPE; result: ARRAY<VARCHAR>; args nullable: true; result nullable: true], ]\n" +
|
||||
" | partition by: [1: v1, BIGINT, true]\n" +
|
||||
" | order by: [2: v2, INT, true] ASC\n" +
|
||||
" | window: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n" +
|
||||
" | cardinality: 1\n" +
|
||||
" | \n" +
|
||||
" 3:ANALYTIC\n" +
|
||||
" | functions: [, lag[([3: a1, ARRAY<VARCHAR(65533)>, true], 1, NULL);" +
|
||||
" args: INVALID_TYPE; result: ARRAY<VARCHAR>; args nullable: true; result nullable: true], ]\n" +
|
||||
" | partition by: [1: v1, BIGINT, true]\n" +
|
||||
" | order by: [2: v2, INT, true] ASC\n" +
|
||||
" | window: ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING\n" +
|
||||
" | cardinality: 1\n" +
|
||||
" | \n" +
|
||||
" 2:ANALYTIC\n" +
|
||||
" | functions: [, lead[([3: a1, ARRAY<VARCHAR(65533)>, true], 1, NULL); " +
|
||||
"args: INVALID_TYPE; result: ARRAY<VARCHAR>; args nullable: true; result nullable: true], ]\n" +
|
||||
" | partition by: [1: v1, BIGINT, true]\n" +
|
||||
" | order by: [2: v2, INT, true] ASC\n" +
|
||||
" | window: ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING\n" +
|
||||
" | cardinality: 1"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
-- name: test_lead_lag_support_array_type
|
||||
CREATE TABLE `t0` (
|
||||
`c0` int(11) NULL COMMENT "",
|
||||
`c1` int(11) NULL COMMENT "",
|
||||
`c2` varchar(65533) NULL COMMENT "",
|
||||
`c3` varchar(65533) NULL COMMENT "",
|
||||
`c4` array<varchar(65533)> NULL COMMENT ""
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`c0`, `c1`, `c2`)
|
||||
DISTRIBUTED BY RANDOM
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
-- result:
|
||||
-- !result
|
||||
insert into t0 select
|
||||
i%10 as c0,
|
||||
i as c1,
|
||||
if (i % 3=0, NULL, concat("foo_",i)) as c2,
|
||||
if (i % 3=0, NULL, concat("bar_",i)) as c3,
|
||||
if (i % 3=0, NULL, [concat("foo_",i),concat("bar_",i)]) as c4
|
||||
from table(generate_series(1,10000)) t(i);
|
||||
-- result:
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
first_value(c2) over(partition by c0 order by c1) a,
|
||||
first_value(c3) over(partition by c0 order by c1) b,
|
||||
first_value(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
first_value(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
first_value(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
first_value(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
last_value(c2) over(partition by c0 order by c1) a,
|
||||
last_value(c3) over(partition by c0 order by c1) b,
|
||||
last_value(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
last_value(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
last_value(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
last_value(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
lead(c2) over(partition by c0 order by c1) a,
|
||||
lead(c3) over(partition by c0 order by c1) b,
|
||||
lead(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
lead(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
lead(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
lead(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
lag(c2) over(partition by c0 order by c1) a,
|
||||
lag(c3) over(partition by c0 order by c1) b,
|
||||
lag(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
with cte as(
|
||||
select
|
||||
lag(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
lag(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
lag(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
-- result:
|
||||
1
|
||||
-- !result
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
-- name: test_lead_lag_support_array_type
|
||||
CREATE TABLE `t0` (
|
||||
`c0` int(11) NULL COMMENT "",
|
||||
`c1` int(11) NULL COMMENT "",
|
||||
`c2` varchar(65533) NULL COMMENT "",
|
||||
`c3` varchar(65533) NULL COMMENT "",
|
||||
`c4` array<varchar(65533)> NULL COMMENT ""
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`c0`, `c1`, `c2`)
|
||||
DISTRIBUTED BY RANDOM
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
insert into t0 select
|
||||
i%10 as c0,
|
||||
i as c1,
|
||||
if (i % 3=0, NULL, concat("foo_",i)) as c2,
|
||||
if (i % 3=0, NULL, concat("bar_",i)) as c3,
|
||||
if (i % 3=0, NULL, [concat("foo_",i),concat("bar_",i)]) as c4
|
||||
from table(generate_series(1,10000)) t(i);
|
||||
with cte as(
|
||||
select
|
||||
first_value(c2) over(partition by c0 order by c1) a,
|
||||
first_value(c3) over(partition by c0 order by c1) b,
|
||||
first_value(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
first_value(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
first_value(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
first_value(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
last_value(c2) over(partition by c0 order by c1) a,
|
||||
last_value(c3) over(partition by c0 order by c1) b,
|
||||
last_value(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
last_value(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
last_value(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
last_value(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
lead(c2) over(partition by c0 order by c1) a,
|
||||
lead(c3) over(partition by c0 order by c1) b,
|
||||
lead(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
lead(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
lead(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
lead(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
lag(c2) over(partition by c0 order by c1) a,
|
||||
lag(c3) over(partition by c0 order by c1) b,
|
||||
lag(c4) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
with cte as(
|
||||
select
|
||||
lag(c2 ignore nulls) over(partition by c0 order by c1) a,
|
||||
lag(c3 ignore nulls) over(partition by c0 order by c1) b,
|
||||
lag(c4 ignore nulls) over(partition by c0 order by c1) c
|
||||
from t0
|
||||
),
|
||||
cte1 as(
|
||||
select concat(a, ",", b)=array_join(c, ",") pred from cte
|
||||
)
|
||||
select assert_true(count(pred)=count(if(pred,1,NULL))) from cte1;
|
||||
|
|
@ -301,51 +301,87 @@ SELECT FIRST_VALUE(c11) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CU
|
|||
-- !result
|
||||
SELECT FIRST_VALUE(c12) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<boolean>).')
|
||||
[1,0,1]
|
||||
[1,0,1]
|
||||
[1,0,1]
|
||||
[1,0,1]
|
||||
[1,0,1]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c13) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<tinyint(4)>).')
|
||||
[1,-1,127]
|
||||
[1,-1,127]
|
||||
[1,-1,127]
|
||||
[1,-1,127]
|
||||
[1,-1,127]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c14) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<smallint(6)>).')
|
||||
[100,-100,32767]
|
||||
[100,-100,32767]
|
||||
[100,-100,32767]
|
||||
[100,-100,32767]
|
||||
[100,-100,32767]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c15) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<int(11)>).')
|
||||
[100000,-100000,2147483647]
|
||||
[100000,-100000,2147483647]
|
||||
[100000,-100000,2147483647]
|
||||
[100000,-100000,2147483647]
|
||||
[100000,-100000,2147483647]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c16) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<bigint(20)>).')
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c17) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<largeint(40)>).')
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c18) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<double>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c19) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<float>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c20) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<DECIMAL64(10,2)>)..')
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT FIRST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<char(100)>).')
|
||||
7698522700
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT FIRST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<date>).')
|
||||
9489753355
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT FIRST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 22. Detail message: No matching function with signature: first_value(array<datetime>).')
|
||||
-2908793330
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c24) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -534,10 +570,10 @@ None
|
|||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 PRECEDING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -549,8 +585,8 @@ None
|
|||
-- !result
|
||||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
|
|
@ -567,9 +603,9 @@ SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 PRECEDIN
|
|||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -597,19 +633,19 @@ None
|
|||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 PRECEDING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -623,8 +659,8 @@ SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWE
|
|||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 10 PRECEDING AND 5 PRECEDING) wv FROM t1;
|
||||
|
|
@ -637,11 +673,11 @@ None
|
|||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND 5 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -655,17 +691,17 @@ SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWE
|
|||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN CURRENT ROW AND 5 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c0) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -765,51 +801,87 @@ None
|
|||
-- !result
|
||||
SELECT LAST_VALUE(c12) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<boolean>).')
|
||||
[1,0,1]
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c13) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<tinyint(4)>).')
|
||||
[1,-1,127]
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c14) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<smallint(6)>).')
|
||||
[100,-100,32767]
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c15) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<int(11)>).')
|
||||
[100000,-100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c16) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<bigint(20)>).')
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c17) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<largeint(40)>).')
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c18) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<double>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c19) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<float>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c20) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<DECIMAL64(10,2)>)..')
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT LAST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<char(100)>).')
|
||||
6158818160
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT LAST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<date>).')
|
||||
7591802684
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT LAST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 21. Detail message: No matching function with signature: last_value(array<datetime>).')
|
||||
-2327034664
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c24) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -990,16 +1062,16 @@ SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN CURRENT ROW AN
|
|||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
|
|
@ -1014,8 +1086,8 @@ None
|
|||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
|
|
@ -1029,11 +1101,11 @@ None
|
|||
-- !result
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND 5 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -1053,27 +1125,27 @@ None
|
|||
-- !result
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN CURRENT ROW AND 5 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 PRECEDING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -1086,10 +1158,10 @@ None
|
|||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 10 PRECEDING AND 5 PRECEDING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -1103,9 +1175,9 @@ SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEE
|
|||
-- result:
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -1117,8 +1189,8 @@ None
|
|||
-- !result
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
-- result:
|
||||
None
|
||||
{"key": "value"}
|
||||
None
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
{"key": "value"}
|
||||
|
|
@ -1229,51 +1301,87 @@ None
|
|||
-- !result
|
||||
SELECT LEAD(c12) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<boolean>).')
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c13) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<tinyint(4)>).')
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c14) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<smallint(6)>).')
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c15) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<int(11)>).')
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c16) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<bigint(20)>).')
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c17) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<largeint(40)>).')
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c18) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<double>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c19) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<float>).')
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c20) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<DECIMAL64(10,2)>)..')
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
None
|
||||
None
|
||||
-- !result
|
||||
SELECT LEAD(c21) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LEAD(c21) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<char(100)>).')
|
||||
4619113620
|
||||
-- !result
|
||||
SELECT LEAD(c22) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LEAD(c22) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<date>).')
|
||||
5693852013
|
||||
-- !result
|
||||
SELECT LEAD(c23) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LEAD(c23) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 15. Detail message: No matching function with signature: lead(array<datetime>).')
|
||||
-1745275998
|
||||
-- !result
|
||||
SELECT LEAD(c24) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
|
|
@ -1481,51 +1589,87 @@ None
|
|||
-- !result
|
||||
SELECT LAG(c12) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<boolean>).')
|
||||
None
|
||||
[1,0,1]
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
[0,0,0]
|
||||
-- !result
|
||||
SELECT LAG(c13) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<tinyint(4)>).')
|
||||
None
|
||||
[1,-1,127]
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
[1,1,127]
|
||||
-- !result
|
||||
SELECT LAG(c14) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<smallint(6)>).')
|
||||
None
|
||||
[100,-100,32767]
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
[100,100,32767]
|
||||
-- !result
|
||||
SELECT LAG(c15) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<int(11)>).')
|
||||
None
|
||||
[100000,-100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
[100000,100000,2147483647]
|
||||
-- !result
|
||||
SELECT LAG(c16) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<bigint(20)>).')
|
||||
None
|
||||
[10000000000,-10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
[10000000000,10000000000,9223372036854775807]
|
||||
-- !result
|
||||
SELECT LAG(c17) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<largeint(40)>).')
|
||||
None
|
||||
[12345678901234567890,-12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
[12345678901234567890,12345678901234567890,170141183460469231731687303715884105727]
|
||||
-- !result
|
||||
SELECT LAG(c18) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<double>).')
|
||||
None
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
-- !result
|
||||
SELECT LAG(c19) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<float>).')
|
||||
None
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
[1.23,4.56,7.89]
|
||||
-- !result
|
||||
SELECT LAG(c20) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<DECIMAL64(10,2)>)..')
|
||||
None
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
[1.23,2.35,3.46]
|
||||
-- !result
|
||||
SELECT LAG(c21) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LAG(c21) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<char(100)>).')
|
||||
6158818160
|
||||
-- !result
|
||||
SELECT LAG(c22) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LAG(c22) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<date>).')
|
||||
7591802684
|
||||
-- !result
|
||||
SELECT LAG(c23) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LAG(c23) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
-- result:
|
||||
E: (1064, 'Getting analyzing error from line 1, column 7 to line 1, column 14. Detail message: No matching function with signature: lag(array<datetime>).')
|
||||
-2327034664
|
||||
-- !result
|
||||
SELECT LAG(c24) OVER(ORDER BY k1) wv FROM t1;
|
||||
-- result:
|
||||
|
|
|
|||
|
|
@ -224,9 +224,10 @@ SELECT FIRST_VALUE(c17) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CU
|
|||
SELECT FIRST_VALUE(c18) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c19) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c20) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT FIRST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT FIRST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT FIRST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
|
||||
SELECT FIRST_VALUE(c24) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c25) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c26) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
|
|
@ -252,6 +253,7 @@ SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 PRECEDING A
|
|||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN CURRENT ROW AND 5 FOLLOWING) wv FROM t1;
|
||||
|
||||
-- FIRST_VALUE(HAS_NULL) with partition by
|
||||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) wv FROM t1;
|
||||
SELECT FIRST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
|
|
@ -294,9 +296,10 @@ SELECT LAST_VALUE(c17) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CUR
|
|||
SELECT LAST_VALUE(c18) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c19) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c20) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
with cte as( SELECT LAST_VALUE(c21) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LAST_VALUE(c22) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LAST_VALUE(c23) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
|
||||
SELECT LAST_VALUE(c24) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c25) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c26) OVER(ORDER BY k1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
|
|
@ -322,6 +325,8 @@ SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 PRECEDING AN
|
|||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 FOLLOWING AND 10 FOLLOWING) wv FROM t1;
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(ORDER BY c3 ROWS BETWEEN CURRENT ROW AND 5 FOLLOWING) wv FROM t1;
|
||||
|
||||
|
||||
-- LAST_VALUE(HAS_NULL) with partition by
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) wv FROM t1;
|
||||
SELECT LAST_VALUE(c25) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
|
|
@ -342,7 +347,7 @@ SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEE
|
|||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) wv FROM t1;
|
||||
SELECT LAST_VALUE(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY c3 ROWS BETWEEN CURRENT ROW AND 5 FOLLOWING) wv FROM t1;
|
||||
|
||||
-- ========================================================= FIRST_VALUE =========================================================
|
||||
-- ========================================================= LAST_VALUE =========================================================
|
||||
SELECT LEAD(c0) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c1) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c2) OVER(ORDER BY k1) wv FROM t1;
|
||||
|
|
@ -364,9 +369,9 @@ SELECT LEAD(c17) OVER(ORDER BY k1) wv FROM t1;
|
|||
SELECT LEAD(c18) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c19) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c20) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c21) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c22) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c23) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LEAD(c21) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LEAD(c22) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LEAD(c23) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
SELECT LEAD(c24) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c25) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LEAD(c26) OVER(ORDER BY k1) wv FROM t1;
|
||||
|
|
@ -380,6 +385,7 @@ SELECT LEAD(c25, 5, -1) OVER(ORDER BY k1) AS wv FROM t1;
|
|||
SELECT LEAD(c25 IGNORE NULLS) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LEAD(c25 IGNORE NULLS, 3) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LEAD(c25 IGNORE NULLS, 5, -1) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
|
||||
-- LEAD(HAS_NULL) with partition by
|
||||
SELECT LEAD(c25) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LEAD(c25, 3) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
|
|
@ -388,7 +394,6 @@ SELECT LEAD(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
|||
SELECT LEAD(c25 IGNORE NULLS, 3) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LEAD(c25 IGNORE NULLS, 5, -1) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
|
||||
|
||||
-- ========================================================= LAG =========================================================
|
||||
SELECT LAG(c0) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c1) OVER(ORDER BY k1) wv FROM t1;
|
||||
|
|
@ -411,9 +416,10 @@ SELECT LAG(c17) OVER(ORDER BY k1) wv FROM t1;
|
|||
SELECT LAG(c18) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c19) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c20) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c21) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c22) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c23) OVER(ORDER BY k1) wv FROM t1;
|
||||
with cte as( SELECT LAG(c21) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LAG(c22) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
with cte as( SELECT LAG(c23) OVER(ORDER BY k1) wv FROM t1) select sum(murmur_hash3_32(array_join(array_map(x->murmur_hash3_32(x),wv),","))) from cte;
|
||||
|
||||
SELECT LAG(c24) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c25) OVER(ORDER BY k1) wv FROM t1;
|
||||
SELECT LAG(c26) OVER(ORDER BY k1) wv FROM t1;
|
||||
|
|
@ -427,6 +433,7 @@ SELECT LAG(c25, 5, -1) OVER(ORDER BY k1) AS wv FROM t1;
|
|||
SELECT LAG(c25 IGNORE NULLS) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LAG(c25 IGNORE NULLS, 3) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LAG(c25 IGNORE NULLS, 5, -1) OVER(ORDER BY k1) AS wv FROM t1;
|
||||
|
||||
-- LAG(HAS_NULL) with partition by
|
||||
SELECT LAG(c25) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LAG(c25, 3) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
|
|
@ -434,5 +441,3 @@ SELECT LAG(c25, 5, -1) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
|||
SELECT LAG(c25 IGNORE NULLS) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LAG(c25 IGNORE NULLS, 3) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
SELECT LAG(c25 IGNORE NULLS, 5, -1) OVER(PARTITION BY k1 ORDER BY k1) AS wv FROM t1;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue