aggregate-functions


SAP Hana - STRING_AGG issue with ORDER BY CLAUSE


We are currently facing an issue with Window Functions in SAP Hana SPS12.
One of our error is when we are using STRING_AGG function.
Here is the code :
/*
CREATE TABLE TEST_STR_AGG (
GROUP_ID varchar(1)
, CLASS_ID varchar(5)
, MEMBER varchar(5)
);
*/
TRUNCATE TABLE TEST_STR_AGG;
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX1', 'A0001');
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX1', 'A0002');
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX1', 'A0003');
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX2', 'A0004');
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX2', 'A0005');
INSERT INTO TEST_STR_AGG VALUES ('A', 'A_XX3', 'A0006');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX1', 'B0001');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX2', 'B0002');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX3', 'B0003');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX4', 'B0004');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX4', 'B0005');
INSERT INTO TEST_STR_AGG VALUES ('B', 'B_XX4', 'B0006');
SELECT GROUP_ID
, CLASS_ID
, STRING_AGG( MEMBER, ' ; ' **ORDER BY MEMBER ASC** ) as MEMBERS
FROM TEST_STR_AGG
GROUP BY GROUP_ID
, CLASS_ID ;
The STRING_AGG used to work perfectly with an ORDER BY clause before a patch install. Now, it is only working with a little volume of lines, as it works in the example I'm giving you. When we are working on more than 500k lines, some lines are disappearring from our result if we add the ORDER BY clause in the STRING_AGG. If we're not, it works.
We have the same issue on FIRST_VALUE and LAST_VALUE functions.
It seems to be a core optimization rule which is corrupting the results...
Does anybody know something about this, please ?
Many thanks
Yep, it's a known bug. Don't have the SAP note ready right now, but it's fixed in a current revision.
/--
Found the SAP note for this:
2365540 - Aggregation Function AVG() Returns ? / NULL Values When Used in Combination With STRING_AGG Including an ORDER BY Clause
Solution
Apply SAP HANA database Revision >= 112.07 (SPS11) or >= 122.02 (SPS12).
--/

Related Links

SAP Hana - STRING_AGG issue with ORDER BY CLAUSE
rrdtool does not keep max
Tableau Aggregate Percentage
use aggregates (min, max, avg) in CONSTRUCT query [duplicate]
R: transposing and aggregating columns
SQL Query Aggregate Error
Usage of aggregate functions in MarkLogic
Querying customDimensions in Google Bigquery
NHibernate - QueryOver criteria appearing in Where instead in Having clause, error
Howto aggregate on full data set in Spring Batch jobs?
Creating an aggregate function fails
Necessity of declaration of function in c and cpp
Calculate window average in tableau
Complexity asymptotic relation (theta, Big O, little o, Big Omega, little omega) between functions
What are TOP_COUNT and TOP_MAXCOUNT in BigQuery?
marklogic need advise for approach to aggregate documents

Categories

HOME
repository
model-view-controller
azure-active-directory
webvr
xss
snmp
download
foreach
docker-compose
scapy
google-app-maker
osclass
resharper
expo
jinja2
alert
printf
monad-transformers
polybase
tcpdf
prepros
datastax-enterprise
grunt-contrib-uglify
inspec
gulp-jshint
tftp
restangular
recreate
ocl
multilanguage
mplab
keil
slim-lang
webclient
tunnel
wunderground
android-geofence
device-driver
dotnetnuke-module
word-wrap
icu
wicket-tester
susy
colorbox
text-extraction
codepen
django-cors-headers
spring-webflow-2
activeandroid
riemann
jscoverage
dotnet-cli
node-java
jenkins-docker
r-commander
liferay-ide
therubyracer
stringbuilder
blackberry-webworks
strtol
recurring
change-password
gdi
pebble-js
wiql
dnvm
pushwoosh
playn
chrome-mobile
diffmerge
sync
mvcgrid
behance-api
rda
code-smell
enquire.js
kernel-density
ardor3d
mosix
mysql2
mmo
idoc
winrt-async
automapper-2
umfpack
clgeocoder
cherokee
jquery-click-event
response-time
mdd
pixel-bender
time-management
j++

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App