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

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
multiply(num) aggregate function in postgresql

Categories

HOME
skype-for-business
ide
salesforce
casting
livecharts
where
comments
android-webview
osx-yosemite
pyodbc
box-api
minimax
openbsd
core-data
ldap-query
drush
android-notifications
logstash-configuration
repeater
hql
ringcentral
orange
project-reactor
civicrm
loader
autologin
conditional-formatting
glibc
gomobile
jopendocument
formtastic
libxml2
request-uri
cqlsh
federated
r-factor
concrete5
openoffice-impress
edsdk
slim-lang
circle
webspeech-api
offset
tunnel
anypoint-studio
form-fields
lex
directadmin
contenteditable
colorbox
head
grails-2.0
api-key
qtwebkit
cloudconvert
photoshop-script
ajv
selection-sort
codesniffer
networkstream
android-xmlpullparser
angularfire
3d-rendering
nugetgallery
calc
music-player
github-for-mac
om
pushwoosh
android-filterable
photogrammetry
sicstus-prolog
data-quality-services
alpha-beta-pruning
tigase
redmine-plugins
selenium-grid2
twitter-finagle
node-mongodb-native
imaplib
mencoder
extensibility
panelgrid
exi
boost.build
gssapi
teamsystem
motordriver
django-admin-tools
bash4
nude.js
nserror
joomla1.7
jquery-click-event
sessiontracking
viewdata
simultaneous
miniport
mysql-logic
datadude
vista64

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