logica icon indicating copy to clipboard operation
logica copied to clipboard

Re-digest predicates from DB

Open yilinxia opened this issue 2 years ago • 4 comments

I tried to pass one predicate to another with the following scripts on local PC

%%logica Child

@Engine("sqlite");

@AttachDatabase("mydata", "my_database.db");
@Dataset("ParentTable");

Parent(..r) :- mydata.ParentTable(..r);

Child(x):- Parent(child:x);

The Child table is supposed to be created successfully, but I encountered the error below

Running predicate: Child
--- SQL ---
SELECT
  JSON_EXTRACT(mydata_ParentTable, "$.child") AS col0
FROM
  mydata.ParentTable AS mydata_ParentTable
[ Error ] Error while executing SQL:
Execution failed on sql 'SELECT
  JSON_EXTRACT(mydata_ParentTable, "$.child") AS col0
FROM
  mydata.ParentTable AS mydata_ParentTable': no such column: mydata_ParentTable

yilinxia avatar Oct 13 '23 18:10 yilinxia

@yilinxia I've tried in my colab and it worked: https://colab.research.google.com/drive/1n8TG1THH6nr0aCyHx-GAIx4r7pVnXLcb?usp=sharing

Can you please take a look and see what's the difference?

EvgSkv avatar Oct 14 '23 20:10 EvgSkv

@EvgSkv I compared the SQL in Colab and Jupyter
Colab

SELECT
  JSON_EXTRACT(JSON_OBJECT('child', mydata_ParentTable.child), "$.child") AS col0
FROM
  mydata.ParentTable AS mydata_ParentTable;

JupyterLab

SELECT
  JSON_EXTRACT(mydata_ParentTable, "$.child") AS col0
FROM
  mydata.ParentTable AS mydata_ParentTable

somehow they are different, although we are using the same script

yilinxia avatar Oct 16 '23 03:10 yilinxia

Maybe this was fixed after you installed logica? Can you please try upgrading to the latest version and seeing if it helps?

EvgSkv avatar Oct 17 '23 17:10 EvgSkv

the update works! and the one i used is version: 1.3.1415926

yilinxia avatar Oct 17 '23 18:10 yilinxia