3 ms·
The article's behavior is non-determenistic only because author didn't finish designing the system and just kinda gave up instead. For example in the last stat
by theamk 4y ago
The article's behavior is non-determenistic only because author didn't finish designing the system and just kinda gave up instead.
For example in the last statement, one approach might be to keep all equivalent strings, then sort them using some other complete ordering function (like utf-8 codepoints) and always return first one. (Yes, this will increase complexity, but locales often do that)
- Sharlin 4y agoBut if you use eg. GROUP BY as in the author’s example it’s not really up to you which representative of the equivalence class is chosen (I wonder if there’s a Unicode algorithm for transforming a word to a canonical representative of its EC… probably not in the general case).
- theamk 4y agoIf you are a database user, sure, you are at mercy of database developer. But if you are writing a database yourself, it is entirely up to you which representative will be returned by GROUP BY. You can take an easy way out and implement "return non-deterministic random member of the group" strategy. Or you can choose the representative with smallest UTF-8 point values, so it will be fully deterministic (I'd prefer this one personally). Or choose row with smallest insertion date. Or let user choose. There are tons of options.