Where does the username in "yum history" come from?

Yum commands record the user that logged into the machine (login name). You can see your current session’s login name with logname. su (with or without sudo) will start a new shell, but will not change the login name.

If you run yum history stats {TRANSACTION ID}, it will tell you the location of the SQLite database file where the yum transaction data is stored. You can open this file with sqlite3 to find out all sorts of information. A table called trans_beg has a field called loginuid.

[root ~]# yum history stats 4
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
File        : //var/lib/yum/history/history-2015-11-10.sqlite
..
[root ~]# sqlite3 //var/lib/yum/history/history-2015-11-10.sqlite
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE trans_beg (
     tid INTEGER PRIMARY KEY,
     timestamp INTEGER NOT NULL, rpmdb_version TEXT NOT NULL,
     loginuid INTEGER);