1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Mcol 5074 Case with In and aggregates asserts (#2435)

* MCOL-5074 CASE with IN and aggregate asserts
gwip-scsp wasn't set and buildPredicateItem() was called which assumes it is set. Added code to set properly in this case
This commit is contained in:
David.Hall
2022-07-11 16:20:15 -05:00
committed by GitHub
parent 524212440e
commit 08bef648b3
7 changed files with 87 additions and 14 deletions

View File

@ -6034,7 +6034,17 @@ void gp_walk(const Item* item, void* arg)
operand = buildReturnedColumn(ifp->arguments()[i], *gwip, gwip->fatalParseError);
if (operand)
{
gwip->rcWorkStack.push(operand);
if (i == 0 && gwip->scsp == NULL) // first item is the WHEN LHS
{
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(operand);
if (sc)
{
gwip->scsp.reset(sc->clone()); // We need to clone else sc gets double deleted. This code is rarely executed so the cost is acceptable.
}
}
}
else
{
cando = false;

View File

@ -101,8 +101,6 @@ typedef std::tr1::unordered_map<TABLE_LIST*, uint> TableOuterJoinMap;
struct gp_walk_info
{
// MCOL-2178 Marked for removal after 1.4
std::vector<std::string> selectCols;
execplan::CalpontSelectExecutionPlan::ReturnedColumnList returnedCols;
execplan::CalpontSelectExecutionPlan::ReturnedColumnList groupByCols;
execplan::CalpontSelectExecutionPlan::ReturnedColumnList subGroupByCols;

View File

@ -1,6 +0,0 @@
<!DOCTYPE Workspace SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpw.dtd">
<Workspace Version="10.0" VendorName="SlickEdit">
<Projects>
<Project File="engine.vpj"/>
</Projects>
</Workspace>

View File

@ -1,6 +0,0 @@
[Global]
CurrentProject=engine.vpj
[ProjectDates]
engine.vpj=20220606154459230
[ActiveConfig]
engine.vpj=Debug

Binary file not shown.

View File

@ -0,0 +1,34 @@
DROP DATABASE IF EXISTS mcol_5074_db;
CREATE DATABASE mcol_5074_db;
USE mcol_5074_db;
CREATE TABLE `accnt` (
`acct_id` varchar(128) NOT NULL DEFAULT 'None',
`created_dt` datetime NOT NULL,
`mtn` varchar(21) NOT NULL DEFAULT 'None',
`accts` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb4;
insert into accnt values
(1, '2021-12-11', "Partner", 5),
(2, '2021-12-12', "Retail", 4),
(1, '2021-12-11', "Partner", 5),
(3, '2021-12-11', "Mid-Market", 3),
(5, '2021-12-11', "PFG", 4),
(5, '2021-12-11', "PFG", 4),
(5, '2021-12-11', "Person Focal Group", 4),
(5, '2021-12-11', "Person Focal Group", 4);
select
mtn,
accts,
DATE_FORMAT(created_dt, '%Y-%m-%d') act_created_dt,
case when da.mtn = 'Partner' then count( acct_id) end as Partner_active_accts,
case when da.mtn = 'Retail' then count( acct_id) end as Retail_active_accts,
case when da.mtn = 'Enterprise' then count( acct_id) end as ENT_active_accts,
case when da.mtn in ('PFG','Person Focal Group') then count( acct_id) end +
case when da.mtn = 'Person Focal Group' then count( acct_id) end as PFG_active_accounts
from accnt da group by mtn, accts, act_created_dt order by mtn;
mtn accts act_created_dt Partner_active_accts Retail_active_accts ENT_active_accts PFG_active_accounts
Mid-Market 3 2021-12-11 NULL NULL NULL NULL
Partner 5 2021-12-11 2 NULL NULL NULL
Person Focal Group 4 2021-12-11 NULL NULL NULL 4
PFG 4 2021-12-11 NULL NULL NULL NULL
Retail 4 2021-12-12 NULL 1 NULL NULL

View File

@ -0,0 +1,43 @@
#
# Test based on Jira MCOL-5074
# Author: dhall, david.hall@mariadb.com
#
# A case statement with an IN and an aggregate would cause plugin assert
-- source ../include/have_columnstore.inc
--disable_warnings
DROP DATABASE IF EXISTS mcol_5074_db;
--enable_warnings
CREATE DATABASE mcol_5074_db;
USE mcol_5074_db;
CREATE TABLE `accnt` (
`acct_id` varchar(128) NOT NULL DEFAULT 'None',
`created_dt` datetime NOT NULL,
`mtn` varchar(21) NOT NULL DEFAULT 'None',
`accts` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb4;
insert into accnt values
(1, '2021-12-11', "Partner", 5),
(2, '2021-12-12', "Retail", 4),
(1, '2021-12-11', "Partner", 5),
(3, '2021-12-11', "Mid-Market", 3),
(5, '2021-12-11', "PFG", 4),
(5, '2021-12-11', "PFG", 4),
(5, '2021-12-11', "Person Focal Group", 4),
(5, '2021-12-11', "Person Focal Group", 4);
select
mtn,
accts,
DATE_FORMAT(created_dt, '%Y-%m-%d') act_created_dt,
case when da.mtn = 'Partner' then count( acct_id) end as Partner_active_accts,
case when da.mtn = 'Retail' then count( acct_id) end as Retail_active_accts,
case when da.mtn = 'Enterprise' then count( acct_id) end as ENT_active_accts,
case when da.mtn in ('PFG','Person Focal Group') then count( acct_id) end +
case when da.mtn = 'Person Focal Group' then count( acct_id) end as PFG_active_accounts
from accnt da group by mtn, accts, act_created_dt order by mtn;