Skip to content

How to do Left Joins when compiling to PostgreSQL? #313

Answered by EvgSkv
katelynrwalker asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reporting this. I've fixed it in the main branch. Your code should work now if you are running main branch.

But it was not released to pip yet. To make it work right away you can define a custom function for taking any value.
Simplest is just to use Min:

TakeAnyValue(x) = Min(x);
Query(a:, b:, c:, d:) :- 
    Table1(a:, b:, c:),
    d TakeAnyValue= (x:- Table2(a:, b:, c:, d: x));

But Min won't work if the taken value is a struct or a list. For that use ArgMin with a constant value.

TakeAnyValue(x) = ArgMin(x -> 1);

Query(a:, b:, c:, d:) :- 
    Table1(a:, b:, c:),
    d TakeAnyValue= (x:- Table2(a:, b:, c:, d: x));

CoLab:
https://colab.research.google.com/drive/1afE6Kayh9vhS…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@katelynrwalker
Comment options

Answer selected by katelynrwalker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants