The bold clause references the IDF values from Output.
CREATE fact TABLE tfidf_output2 DISTRIBUTE BY hash(term) AS SELECT * FROM tf_idf ( ON TF ( ON tfidf_input2 PARTITION BY docid Formula ('normal') ) AS tf PARTITION BY term ON (SELECT DISTINCT(term) AS term, idf FROM tfidf_output1 ) AS idf PARTITION BY term );