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

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
multiply(num) aggregate function in postgresql
Binding the Result of an Aggregate Function to a Projected Variable
tableau aggregate data based on dimension
where clause and aggregate functions
Is there such a thing as a join() aggregate function that concatentates field values at a specific character?
Aggregation of an expression in Django query spanning multiple tables
How to aggregate / roll up percentile measures
A peer-to-peer and privacy-aware data mining/aggregation algorithm: is it possible?
Multiple aggregates in SPARQL
SAP BO XI Desktop Intelligence Aggregate Calculations
Mondrian: Help picking the right aggregator for Measures?

Categories

HOME
optimization
ns2
gsm
pyspark
jenkins-pipeline
abc
window.open
nagios
django-middleware
lithium
hiveql
handlebars.js
pip
wavefront
obd-ii
software-collections
phpexcel
rename
activejdbc
email-attachments
opengrok
github-flavored-markdown
webseal
bookmarklet
multibinding
template10
vivado-hls
passbook
google-drive-android-api
apdu
core-animation
continuous-fourier
hierarchy
jbossfuse
snapkit
dropdownbox
realloc
client-server
byobu
glide-image-library
datagridviewcombobox
inner-join
google-chrome-storage
skype-bots
photoshop-script
google-scholar
timefield
stripes
racket-student-languages
konakart
init
key-value-store
qtruby
airwatch
objectify
sbt-proguard
user-profile
archiva
window.location
paypal-subscriptions
salesforce-service-cloud
firefox-os
std
recode
redquerybuilder
transport
jain-sip
identifying
dnvm
glog
system.io.packaging
javacompiler
nsmutableurlrequest
scjp
switchpreference
telerik-appbuilder
db2-connect
codio
netbeans-plugins
lastinsertid
mobile-robots
pechkin
caroufredsel
kohana-orm
playing-cards
pudb
fileoutputstream
xpolog
lightopenid
azure-appfabric
jquery-attributes
ffdshow
wtsapi32

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