mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
better
This commit is contained in:
parent
08b63fde77
commit
aceb82ae6a
@ -387,9 +387,6 @@ void ExpressionAction::execute(Block & block, bool dry_run) const
|
||||
source.type = assert_cast<const DataTypeArray &>(*source.type).getNestedType();
|
||||
source.name = result_name;
|
||||
|
||||
if (source.type->getTypeId() == TypeIndex::Nothing)
|
||||
throw Exception("ARRAY JOIN of empty array is not allowed", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
block.insert(std::move(source));
|
||||
|
||||
break;
|
||||
|
@ -13,6 +13,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int LOGICAL_ERROR;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
void finalizeChunk(Chunk & chunk)
|
||||
@ -156,6 +157,13 @@ void TotalsHavingTransform::transform(Chunk & chunk)
|
||||
/// Compute the expression in HAVING.
|
||||
const auto & cur_header = final ? finalized_header : getInputPort().getHeader();
|
||||
auto finalized_block = cur_header.cloneWithColumns(finalized.detachColumns());
|
||||
|
||||
for (const ExpressionAction & action : expression->getActions())
|
||||
{
|
||||
if (action.type == ExpressionAction::ARRAY_JOIN)
|
||||
throw Exception("Having clause cannot contain arrayJoin", ErrorCodes::ILLEGAL_COLUMN);
|
||||
}
|
||||
|
||||
expression->execute(finalized_block);
|
||||
auto columns = finalized_block.getColumns();
|
||||
|
||||
@ -222,6 +230,9 @@ void TotalsHavingTransform::addToTotals(const Chunk & chunk, const IColumn::Filt
|
||||
const ColumnAggregateFunction::Container & vec = column->getData();
|
||||
size_t size = vec.size();
|
||||
|
||||
if (filter && filter->size() != size)
|
||||
throw Exception("Filter has size which differs from column size", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
if (filter)
|
||||
{
|
||||
for (size_t row = 0; row < size; ++row)
|
||||
|
@ -1,20 +1,3 @@
|
||||
┏━━━┳━━━━━━━━━━━━━┓
|
||||
┃ [1mg[0m ┃ [1msum(number)[0m ┃
|
||||
┡━━━╇━━━━━━━━━━━━━┩
|
||||
│ 0 │ 2 │
|
||||
├───┼─────────────┤
|
||||
│ 0 │ 2 │
|
||||
├───┼─────────────┤
|
||||
│ 1 │ 4 │
|
||||
└───┴─────────────┘
|
||||
|
||||
Totals:
|
||||
┏━━━┳━━━━━━━━━━━━━┓
|
||||
┃ [1mg[0m ┃ [1msum(number)[0m ┃
|
||||
┡━━━╇━━━━━━━━━━━━━┩
|
||||
│ 0 │ 6 │
|
||||
└───┴─────────────┘
|
||||
-
|
||||
┏━━━┳━━━┓
|
||||
┃ [1mg[0m ┃ [1ms[0m ┃
|
||||
┡━━━╇━━━┩
|
||||
@ -37,56 +20,10 @@ Totals:
|
||||
0 2
|
||||
0 2
|
||||
1 4
|
||||
|
||||
0 6
|
||||
-
|
||||
0 2
|
||||
0 2
|
||||
1 4
|
||||
1 4
|
||||
|
||||
0 6
|
||||
--
|
||||
{
|
||||
"meta":
|
||||
[
|
||||
{
|
||||
"name": "g",
|
||||
"type": "UInt64"
|
||||
},
|
||||
{
|
||||
"name": "sum(number)",
|
||||
"type": "UInt64"
|
||||
}
|
||||
],
|
||||
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"g": "0",
|
||||
"sum(number)": "2"
|
||||
},
|
||||
{
|
||||
"g": "0",
|
||||
"sum(number)": "2"
|
||||
},
|
||||
{
|
||||
"g": "1",
|
||||
"sum(number)": "4"
|
||||
}
|
||||
],
|
||||
|
||||
"totals":
|
||||
{
|
||||
"g": "0",
|
||||
"sum(number)": "6"
|
||||
},
|
||||
|
||||
"rows": 3,
|
||||
|
||||
"rows_before_limit_at_least": 4
|
||||
}
|
||||
-
|
||||
{
|
||||
"meta":
|
||||
[
|
||||
|
@ -1,15 +1,9 @@
|
||||
set output_format_write_statistics = 0;
|
||||
select g, sum(number) from numbers(4) group by bitAnd(number, 1) as g with totals having sum(number) <= arrayJoin([2, 4]) format Pretty;
|
||||
select '-';
|
||||
select g, s from (select g, sum(number) as s from numbers(4) group by bitAnd(number, 1) as g with totals) array join [1, 2] as a format Pretty;
|
||||
select '--';
|
||||
|
||||
select g, sum(number) from numbers(4) group by bitAnd(number, 1) as g with totals having sum(number) <= arrayJoin([2, 4]) format TSV;
|
||||
select '-';
|
||||
select g, s from (select g, sum(number) as s from numbers(4) group by bitAnd(number, 1) as g with totals) array join [1, 2] as a format TSV;
|
||||
select '--';
|
||||
|
||||
select g, sum(number) from numbers(4) group by bitAnd(number, 1) as g with totals having sum(number) <= arrayJoin([2, 4]) format JSON;
|
||||
select '-';
|
||||
select g, s from (select g, sum(number) as s from numbers(4) group by bitAnd(number, 1) as g with totals) array join [1, 2] as a format JSON;
|
||||
select '--';
|
||||
|
@ -1,12 +0,0 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
|
||||
0
|
@ -1,2 +1,2 @@
|
||||
SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([]); -- { serverError 43 }
|
||||
SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([3, 2, 1, 0]) ORDER BY number;
|
||||
SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([]); -- { serverError 44 }
|
||||
SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([3, 2, 1, 0]) ORDER BY number; -- { serverError 44 }
|
||||
|
Loading…
Reference in New Issue
Block a user