If someone runs into this problem (as I did today). If calling groups_get_groups in a hook like “plugins_loaded” it is to early in the WordPress loading sequence, and gives the SQL error. I moved my hook from plugins_loaded to bp_loaded and the SQL error went away. This is logic as to ensure that BuddyPress is loaded we should use a hook that ensures it.
I still think that groups_get_group shouldn’t give an SQL error though…