intersystems-community / embedded-python-bugreports

Please submit bugs you found in Embedded Python here
0 stars 1 forks source link

iris python iris and python sqlproc with using iris #12

Open daimor opened 1 year ago

daimor commented 1 year ago

Describe the bug python crashes when executed SQL Query with sql function written in Python and uses iris module And it even does something with STDIN, because it does not work as expected after crash, do not let enter at all, and ignores Ctrl+D

iris version/image IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.2 (Build 227U) Mon Jul 31 2023 17:43:25 EDT

python version iris python iris

To Reproduce

irisowner@53b363b07dfb:~/app$ 
irisowner@53b363b07dfb:~/app$ iris python iris

Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type quit() or Ctrl-D to exit this shell.
>>> iris.cls('%SQL.Statement')._ExecDirect(iris.cls('%SQL.Statement')._New(),"select vector.norm_py('[1,2,3]')")._Display()
irisowner@53b363b07dfb:~/app$ 

Expected behavior The same function written in ObjectScript works well

irisowner@53b363b07dfb:~/app$ 
irisowner@53b363b07dfb:~/app$ iris python iris

Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type quit() or Ctrl-D to exit this shell.
>>> iris.cls('%SQL.Statement')._ExecDirect(iris.cls('%SQL.Statement')._New(),"select vector.norm('[1,2,3]')")._Display()
Expression_1
3.741657386773941386

1 Rows(s) Affected>>> 
daimor commented 1 year ago

With irissqlcli in Embedded mode, manages to get some error message

irisowner@53b363b07dfb:~/app$ irissqlcli iris+emb:///
Server:  IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.2 (Build 227U) Mon Jul 31 2023 17:43:25 EDT
Version: 0.5.4
[SQL]irisowner@/usr/irissys/:USER> select vector.norm_py('[1,2,3]')
Traceback (most recent call last):
  File "/home/irisowner/.local/lib/python3.10/site-packages/irissqlcli/sqlexecute.py", line 133, in run
    for result in special.execute(cur, sql):
  File "/home/irisowner/.local/lib/python3.10/site-packages/irissqlcli/packages/special/main.py", line 109, in execute
    raise CommandNotFound
irissqlcli.packages.special.main.CommandNotFound

During handling of the above exception, another exception occurred:

ModuleNotFoundError: No module named 'dc'
SQL Function VECTOR.NORM_PY failed with error:  SQLCODE=-400,%msg=ERROR #5002: ObjectScript error: <OBJECT DISPATCH>%0AmBm3l0tudf^%sqlcq.USER.cls37.1 *python object not found
[SQL]irisowner@/usr/irissys/:USER>
[SQL]irisowner@/usr/irissys/:USER> select vector.norm('[1,2,3]')
+--------------------+
| Expression_1       |
+--------------------+
| 3.7416573867739413 |
+--------------------+
1 row in set
Time: 0.062s
[SQL]irisowner@/usr/irissys/:USER>