You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hawq.apache.org by "Ruilong Huo (JIRA)" <ji...@apache.org> on 2016/06/17 01:31:05 UTC
[jira] [Updated] (HAWQ-815) KeyError while compiling PLPython
function due to deletion of non-existent record from Python global dict
[ https://issues.apache.org/jira/browse/HAWQ-815?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ruilong Huo updated HAWQ-815:
-----------------------------
Affects Version/s: 2.0.0
> 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
> Affects Versions: 2.0.0
> 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)