Github user iyerr3 commented on a diff in the pull request:
https://github.com/apache/madlib/pull/204#discussion_r152122999
--- Diff: src/ports/postgres/modules/knn/knn.py_in ---
@@ -88,12 +88,28 @@ def knn_validate_src(schema_madlib, point_source,
point_column_name, point_id,
plpy.error("kNN Error: Data type '{0}' is not a valid type for"
" column '{1}' in table '{2}'.".
format(col_type_test, test_id, test_source))
+
+ fn_dist = fn_dist.lower().strip()
+ dist_functions = {
+ schema_madlib + '.dist_norm1',
+ schema_madlib + '.dist_norm2',
+ schema_madlib + '.squared_dist_norm2',
+ schema_madlib + '.dist_angle',
+ schema_madlib + '.dist_tanimoto'}
+
+ if plpy.execute("""select prorettype != 'DOUBLE PRECISION'::regtype
--- End diff --
Please avoid expressions with side effects in the if statement. The
`plpy.execute` result can be placed in a variable and tested in the next step.
---