[MCOL-3570] Type convertion problems columnstore Created: 2019-10-21  Updated: 2023-03-06

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr, PrimProc
Affects Version/s: 1.1.7, 1.2.5, 5.5.1, 6.1.1
Fix Version/s: Icebox

Type: Bug Priority: Minor
Reporter: Matthias Dr. Döring Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hello,

the SELECT at the end of the example below provides wrong NULL values as result for
the columns s2, s3 and s4.

Best regards

DROP TABLE IF EXISTS fact;
CREATE TABLE fact (
atc INT(11),
v1 INT(11)
)
ENGINE=Columnstore;

INSERT INTO fact VALUES
(1,11),
(2,22);

CREATE OR REPLACE VIEW v_fact_primary AS
SELECT
atc,
v1
FROM fact;

CREATE OR REPLACE VIEW v_fact_secondary AS
SELECT
atc,
v1,
CAST(0 AS UNSIGNED) AS v2 – without CAST one gets "the storage engine ... doesn't support Unknown REF item
FROM v_fact_primary;

SELECT
atc,
SUM(v1) AS sum1,
SUM(v2) AS sum2,
CAST(SUM(v1) AS CHAR(100)) AS s1,

CAST(SUM(v2) AS CHAR(100)) AS s2, – not working
CONVERT(SUM(v2),CHAR) AS s3, – not working
'' + SUM(v2) AS s4 – not working
FROM
v_fact_secondary
GROUP BY atc;



 Comments   
Comment by Roman [ 2021-03-03 ]

Looks like MDB optimizes the query replacing CAST(SUM(v2) AS CHAR(100)) AS s2 with a constant '0' that CAST and CONVERT can't process properly.
Here is what CSEP has for CAST(SUM(v2) AS CHAR(100)) AS s2
ConstantColumn: intVal=0 uintVal=0(null) resultType=bigint/Alias: s2

Generated at Thu Feb 08 02:43:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.