There's nothing wrong with that line of Lua code.
The problem is in the Firaxis implementation of the database to Lua API.
pBuilding is a C++ function masquerading as a table. The Lua spec states that accessing a non-existent key (GreatWorkYieldType in this case) for a table is valid and returns nil. In addition to returning nil, Firaxis decided to also log a message, so the problem is in the Firaxis Lua API C++ code (which we do not have the source code for) and not the actual mod. Until/If I can find yet another work around to poor Firaxis code the lua.log file will be filled with unnecessary warnings.