CREATE TABLE crashes when using multiple Analytic Functions with similar but not exactly the same sorting information

Details

Detail name Value
Changelog Number 4683
Type Bug
Status Resolved
Affected Versions EXASOL 6.0.0, EXASolution 5.0.0
Fix Versions EXASolution 5.0.20, EXASOL 6.0.2
Resolution Date 2017-06-12

Problem
When using CREATE TABLE AS with a sub-query which uses analytic functions that have similar but not exctly the same sorting information (ORDER BY),
the SQL-Compiler crashes.

Example

create or replace table a(id int);

create or
replace table
	c as
SELECT
	count(*) OVER(
		PARTITION BY
			a.id
		ORDER BY
			a.id rows between unbounded preceding and
			unbounded following
	) as col_2,
	count(*) OVER(PARTITION BY a.id ORDER BY a.id) as col_1
FROM
	a;

Workaround
Separate the analytic functions with similar but not exactly the same sorting information into different selects, for instance by using a subselect like this for the example above:

create or
replace table
	c as
select count(*) OVER(PARTITION BY id ORDER BY id) as col_1, col_2 from
(
SELECT
    id,
	count(*) OVER(
		PARTITION BY
			a.id
		ORDER BY
			a.id rows between unbounded preceding and
			unbounded following
	) as col_2
FROM
	a);