Fix when source is query not table

Signed-off-by: Arief M Utama <arief.utama@gmail.com>