support CTAS for selecting from temp table