Hi!
There is a property proposal to store a SPARQL query equivalent to a category: https://www.wikidata.org/wiki/Wikidata:Property_proposal/Wikidata_SPARQL_que...
I have some doubts about the appropriate datatype. I guess it depends on future plans/community preferences.
I think right now it should be string. Can be changed later if we want specific datatype for queries, right now we don't have one.