-
Hi Evgeniy! It seems there is no way to create something like this from Logica: I understand that similar semantics can be achieved by using ANY_VALUE aggregation together with IS NULL check ..., but specifically in PostgreSQL the query plan generated for the latter is vastly more complicated and performance of the latter is dramatically worse (for my complete queries this one change makes the difference between 10 minutes and 5 seconds). Is there a way to make Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Hi Robert, |
Beta Was this translation helpful? Give feedback.
-
Hello, I am new to Logica, but really like the approach. I have programmed a little bit with Prolog before, but I find it a little bit difficult to learn Logica syntax. Apparently Logica does not have constructs for predicate logic "there exists" and "for all". I was struggling to implement the latter with count, as the count is not defined for empty query set. And the example above (select ... where not (select any_value(1) from ...) is null) seems like a way to implement it, but any_value is not supported by SQLite3. How would you implement it using Logica constructs? For me, the performance is not an issue. |
Beta Was this translation helpful? Give feedback.
-
Hi Mikko! This is how it would look in Logica:
This would select x's from A that do not exist in B:
For this use-case other aggregations would work just as well (it doesn't matter what it returned from the subquery as long as it's not NULL:
so you can use that instead of AnyValue to the same effect. Also, you can add Any_Value or other functions to your SQLite when connecting to it programmatically. logica/common/sqlite3_logica.py Line 220 in 5c645ec Does this help? |
Beta Was this translation helpful? Give feedback.
-
By the way, I noticed that if you are running your Logica on SQLite through the logica/common/sqlite3_logica.py Line 226 in 5c645ec |
Beta Was this translation helpful? Give feedback.
@rvalek I looked at it. There is some type casting that was added for robustness, which prevents
exists
working as-is. But we can figure that part out.For now I created
exists
branch, where I disabled the type casting of aggregates.There you can do:
Which produces (as expected):
By default SQL that you get looks like this: