deduplicating code between dataset upsert and row upsert