Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 16F79200D4F for ; Wed, 22 Nov 2017 01:15:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 15724160C10; Wed, 22 Nov 2017 00:15:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66784160BFC for ; Wed, 22 Nov 2017 01:15:32 +0100 (CET) Received: (qmail 25483 invoked by uid 500); 22 Nov 2017 00:15:31 -0000 Mailing-List: contact dev-help@madlib.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@madlib.apache.org Delivered-To: mailing list dev@madlib.apache.org Received: (qmail 25453 invoked by uid 99); 22 Nov 2017 00:15:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2017 00:15:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AA6C0DFF9F; Wed, 22 Nov 2017 00:15:30 +0000 (UTC) From: iyerr3 To: dev@madlib.apache.org Reply-To: dev@madlib.apache.org References: In-Reply-To: Subject: [GitHub] madlib pull request #204: Added additional distance metrics for k-NN: Jira-1... Content-Type: text/plain Message-Id: <20171122001530.AA6C0DFF9F@git1-us-west.apache.org> Date: Wed, 22 Nov 2017 00:15:30 +0000 (UTC) archived-at: Wed, 22 Nov 2017 00:15:33 -0000 Github user iyerr3 commented on a diff in the pull request: https://github.com/apache/madlib/pull/204#discussion_r152420323 --- Diff: src/ports/postgres/modules/knn/knn.py_in --- @@ -89,20 +89,20 @@ def knn_validate_src(schema_madlib, point_source, point_column_name, point_id, " 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 - OR proisagg = TRUE AS OUTPUT from pg_proc where - oid='{fn_dist}(DOUBLE PRECISION[], DOUBLE PRECISION[])'::regprocedure;""" - .format(**locals()))[0]['output'] or fn_dist not in dist_functions: - plpy.error( - "KNN error: Distance function has wrong signature or is not a simple function.") + if fn_dist and fn_dist is not None: + fn_dist = fn_dist.lower().strip() + dist_functions = set([schema_madlib + dist for dist in + ('.dist_norm1', '.dist_norm2', '.squared_dist_norm2', '.dist_angle', '.dist_tanimoto')]) + + is_invalid_func = plpy.execute( + """select prorettype != 'DOUBLE PRECISION'::regtype + OR proisagg = TRUE AS OUTPUT from pg_proc where + oid='{fn_dist}(DOUBLE PRECISION[], DOUBLE PRECISION[])'::regprocedure; + """.format(**locals()))[0]['output'] + + if is_invalid_func or fn_dist not in dist_functions: --- End diff -- To double check: input is expected to be of the form `madlib.dist_norm2` and not just `dist_norm2`? ---