[ 
https://issues.apache.org/jira/browse/HAWQ-815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15329642#comment-15329642
 ] 

ASF GitHub Bot commented on HAWQ-815:
-------------------------------------

GitHub user huor opened a pull request:

    https://github.com/apache/incubator-hawq/pull/711

    HAWQ-815. KeyError while compiling PLPython function due to deletion of 
non-existent record from Python global dict

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/huor/incubator-hawq huor_plpython

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-hawq/pull/711.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #711
    
----
commit afd80af05dcdf0b19ebbf4ef2e85b36787fa19a4
Author: Ruilong Huo <r...@pivotal.io>
Date:   2016-06-14T15:15:07Z

    HAWQ-815. KeyError while compiling PLPython function due to deletion of 
non-existent record from Python global dict

----


> KeyError while compiling PLPython function due to deletion of non-existent 
> record from Python global dict
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HAWQ-815
>                 URL: https://issues.apache.org/jira/browse/HAWQ-815
>             Project: Apache HAWQ
>          Issue Type: Bug
>          Components: Query Execution
>            Reporter: Ruilong Huo
>            Assignee: Ruilong Huo
>
> It raise KeyError while compiling PLPython function due to deletion of 
> non-existent record from Python global dict. Below are two example to 
> reproduce the issue:
> Example 1:
> {noformat}
> -- 1) prepare schema and data
> CREATE LANGUAGE plpythonu;
> CREATE TABLE gp_single_row(a int) DISTRIBUTED BY (a);
> INSERT INTO gp_single_row VALUES (1);
> CREATE OR REPLACE FUNCTION test_return_table(s TEXT)
> RETURNS TABLE(first TEXT, second INT4)
> AS $$
>    exec('y = ' + s)
>    return y
> $$ LANGUAGE plpythonu;
> SELECT (test_return_table('[]')).*;
> SELECT (test_return_table('[]')).*
> FROM gp_single_row;
> -- 2) Actual output
> SELECT (test_return_table('[]')).*;
>  first | second
> -------+--------
> (0 rows)
> SELECT (test_return_table('[]')).*
> FROM gp_single_row;
> ERROR:  could not compile PL/Python function "test_return_table" 
> (plpython.c:4651)  (seg5 test1:31100 pid=36826) (dispatcher.c:1801)
> DETAIL:  KeyError: 's'
> -- 3) Expected output
> SELECT (test_return_table('[]')).*;
>  first | second
> -------+--------
> (0 rows)
> SELECT (test_return_table('[]')).*
> FROM gp_single_row;
>  first | second
> -------+--------
> (0 rows)
> {noformat}
> Example 2:
> {noformat}
> -- 1) prepare schema and data
> CREATE LANGUAGE plpythonu;
> CREATE OR REPLACE FUNCTION func1(var_cause_bug int4[])
> RETURNS SETOF INT4 AS $$
> for el in var_cause_bug:
>     yield el
> $$ LANGUAGE plpythonu;
> CREATE OR REPLACE FUNCTION func2()
> RETURNS INT4 AS $$
> return 1
> $$ LANGUAGE plpythonu;
> SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
> SELECT func2();
> -- 2) Actual output
> SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
>  func1 | func1 
> -------+-------
>      1 |     1
>      2 |     2
>      3 |     3
> (3 rows)
> SELECT func2();
> ERROR:  could not compile PL/Python function "func2" (plpython.c:4648)
> DETAIL:  KeyError: 'var_cause_bug'
> -- 3) Expected output
> SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
>  func1 | func1
> -------+-------
>      1 |     1
>      2 |     2
>      3 |     3
> (3 rows)
> SELECT func2();
>  func2
> -------
>      1
> (1 row)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to