initial support for distinct/unique
this implementation is terrible, but correct (as currently specified)
cbugg: close bug-676