From: Bryan T. <br...@sy...> - 2014-11-06 13:28:14
|
The ticket for allowing aggregates in ORDER BY is: - http://trac.bigdata.com/ticket/502 (Allow aggregates in ORDER BY clause) Can you attach the EXPLAIN of the query with and without DISTINCT. The issue may be that the DISTINCT is being applied after the ORDER BY. I seem to remember some issue historically with operations being performed before/after the ORDER BY, but I do not have any distinct recollection of a problematic interaction between DISTINCT and ORDER BY. Bryan ---- Bryan Thompson Chief Scientist & Founder SYSTAP, LLC 4501 Tower Road Greensboro, NC 27410 br...@sy... http://bigdata.com http://mapgraph.io CONFIDENTIALITY NOTICE: This email and its contents and attachments are for the sole use of the intended recipient(s) and are confidential or proprietary to SYSTAP. Any unauthorized review, use, disclosure, dissemination or copying of this email or its contents or attachments is prohibited. If you have received this communication in error, please notify the sender by reply email and permanently delete all copies of the email and its contents and attachments. On Wed, Nov 5, 2014 at 6:14 PM, Jim Balhoff <ba...@ne...> wrote: > > On Nov 5, 2014, at 5:46 PM, Jeremy J Carroll <jj...@sy...> wrote: > > > > > >> On Nov 5, 2014, at 1:02 PM, Bryan Thompson <br...@sy...> wrote: > >> > >> There could be an issue with ORDER BY operating on an anonymous and > non-projected variable. Try declaring and binding a variable for > STR(?label) inside of the query and then using that variable in the ORDER > BY clause. > > > > > > Yes I tend to find the results of ORDER BY are more what I expect if I > do not include an expression in the ORDER BY but simply variables. I BIND > any expression before the ORDER BY. > > > > I believe there is a trac item for this, but since the workaround is > easy, I have never seen it as high priority > > > > As suggested I tried binding a variable as `BIND (STR(?term_label) AS > ?string_label)` and using that to sort. Still incorrect ordering. But, I > tried removing DISTINCT, and then the ordering is correct. Even going back > to the anonymous `ORDER BY STR(?term_label)`, ordering is still correct if > I remove DISTINCT. For this specific query DISTINCT is not needed, but I do > need it for my application. Is there a reason to not expect DISTINCT to > work correctly with ORDER BY? > > Thanks both of you for all of your help, > Jim > > |