Github user njayaram2 commented on a diff in the pull request: https://github.com/apache/madlib/pull/315#discussion_r213792484 --- Diff: src/ports/postgres/modules/knn/knn.py_in --- @@ -243,6 +237,23 @@ def knn(schema_madlib, point_source, point_column_name, point_id, label_out = "" comma_label_out_alias = "" + # CTAS temporary table from the main table(s) to select the + # given expression from. + + point_source_temp_table = unique_string(desp='point_source') + test_source_temp_table = unique_string(desp='test_source') + point_col_name_temp = unique_string(desp='point_col_name_temp') + test_col_name_temp = unique_string(desp='test_col_name_temp') + + plpy.execute(""" + create table {point_source_temp_table} as + (select {point_id} , {point_column_name} as {point_col_name_temp} , {label_column_name} from {point_source})""" + .format(**locals())) + plpy.execute(""" + create table {test_source_temp_table} as + (select {test_id}, {test_column_name} as {test_col_name_temp} from {test_source})""" + .format(**locals())) --- End diff -- Did you mean to create a temp table for these? Either way, we don't have to create a table for these. We could directly run them as subqueries instead.
---