Last modified: 2014-09-23 19:44:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T23315, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 21315 - Proposed aggregate smw query enhancement
Proposed aggregate smw query enhancement
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-27 20:01 UTC by Harold Solbrig
Modified: 2014-09-23 19:44 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to implement query aggregate functions (6.26 KB, patch)
2009-10-27 20:01 UTC, Harold Solbrig
Details

Description Harold Solbrig 2009-10-27 20:01:22 UTC
Created attachment 6728 [details]
Patch to implement query aggregate functions

The attached patch implements a limited set of aggregate functions for the SMW Query.  The syntax implemented at the moment puts the aggregate function in parenthesis immediately following the "?" in the ask statement thus:

?hasCity=city    would return a list of cities
?(count)hasCity=city count   would return the number of cities in the list.

We have implemented the following functions
count - number of entries
countp - number of entries if > 0, blank otherwise

exist, exists - "true" if number of entries > 0, "false" otherwise
existt - "true" if entries exist, blank otherwise
existf - "false" if no entries exist, blank otherwise"

We are using these functions locally and would like to propose this patch as generic solution or a guide about how one might go about implementing a similar generic solution.
Comment 1 Markus Krötzsch 2009-11-04 08:17:22 UTC
Yes, this looks useful. The new printout parameters of SMW could actually help to integrate this feature. The syntax in #ask will be slightly different. "count" would clearly be a "format" for individual printouts.

I am less sure about the others. For one thing, they are not known as formats for queries in general yet, where one achieves this behavior with other parameters. There are at least three approaches one could take:

1) Introduce "exists" et al. as new formats as you suggest. In this case, I am inclined to also provide these formats for queries in general, to ensure that all printout formats work for queries as well (the other direction makes less sense, obviously).

2) The "exists" functionality could be provided in a similar fashion like the existing "?Category:Foo" printouts; e.g. one could have "?Property::+" in these cases. The advantage is that the formatting could be controlled completely, and in a way that is already implemented.

3) "exists" could be achieved by using "limit=0" together with a suitable value for "intro" ("true") and "default" ("false"). This requires these additional parameters to work for printouts, but this might be useful anyway.

I will take a closer look at the code to decide which of those (or which others) to implement.
Comment 2 p858snake 2011-04-30 00:09:27 UTC
*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*
Comment 3 Sumana Harihareswara 2011-12-23 18:37:17 UTC
It looks like Markus reviewed this patch, so I am adding the "reviewed" keyword.
Comment 4 Jeroen De Dauw 2013-04-02 02:12:06 UTC
Removing as blocker for 1.9

Removing Markus as assignee and setting to new, as he is clearly not working on this

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links