[CONJ-963] Cume_dist with Partition by returns error java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 348 Created: 2022-04-18  Updated: 2022-04-25  Resolved: 2022-04-25

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 3.0.3
Fix Version/s: 3.0.5

Type: Bug Priority: Major
Reporter: Mike Savoie Assignee: Diego Dupin
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates CONJ-956 ArrayIndexOutOfBoundsException when a... Closed

 Description   

The SQL below works with Mariadb driver 2.7.3. Using drivers 3.0.3 or 3.0.4, java.lang.ArrayIndexOutOfBoundsException occurs.

SELECT
`SNO`,
`PNO`,
CUME_DIST()
OVER(
PARTITION BY
`SNO`,
`PNO`
ORDER BY
CASE
WHEN `QTY` IS NULL THEN 1
ELSE 0
END,
`QTY` ASC
)
FROM
`TSUPPLY`

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 348

The issue seems to be with partition by because the SQL below(no partition by clause) does not fail

SELECT
`SNO`,
`PNO`,
CUME_DIST()
OVER(
ORDER BY
CASE
WHEN `QTY` IS NULL THEN 1
ELSE 0
END,
`QTY` ASC
)
FROM
`TSUPPLY`

Info for table TSUPPLY

CREATE TABLE IF NOT EXISTS `tsupply` (
`RNUM` int(11) NOT NULL,
`SNO` varchar(2) DEFAULT NULL,
`PNO` varchar(2) DEFAULT NULL,
`JNO` varchar(2) DEFAULT NULL,
`QTY` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `tsupply` (`RNUM`, `SNO`, `PNO`, `JNO`, `QTY`) VALUES
(0, 'S1', 'P1', 'J1', 200),
(1, 'S1', 'P1', 'J4', 700),
(2, 'S2', 'P3', 'J1', 400),
(3, 'S2', 'P3', 'J2', 200),
(4, 'S2', 'P3', 'J3', 200),
(5, 'S2', 'P3', 'J4', 500),
(6, 'S2', 'P3', 'J5', 600),
(7, 'S2', 'P3', 'J6', 400),
(8, 'S2', 'P3', 'J7', 800),
(9, 'S2', 'P5', 'J2', 100),
(10, 'S3', 'P3', 'J1', 200),
(11, 'S3', 'P4', 'J2', 500),
(12, 'S4', 'P6', 'J3', 300),
(13, 'S4', 'P6', 'J7', 300),
(14, 'S5', 'P2', 'J2', 200),
(15, 'S5', 'P2', 'J4', 100),
(16, 'S5', 'P5', 'J5', 500),
(17, 'S5', 'P5', 'J7', 100),
(18, 'S5', 'P6', 'J2', 200),
(19, 'S5', 'P1', 'J4', 100),
(20, 'S5', 'P3', 'J4', 200),
(21, 'S5', 'P4', 'J4', 800),
(22, 'S5', 'P5', 'J4', 400),
(23, 'S5', 'P6', 'J4', 500);


Generated at Thu Feb 08 03:19:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.