There don't seem to be any examples of how to connect to an existing (say sqlite) database even though it says you should try logica if "you already have data in BigQuery, PostgreSQL or SQLite,". How do you connect to an existing sqlite database?
I was turned off by this at first, but then tried it out. These are mistakes in the documentation. The tools just work with PostgreSQL and SQLite without any extra work.
Logica – Declarative logic programming language for data
51–60 of 67 posts
Re: Logica – Declarative logic programming language for data
#52Earlier quoted context omitted.
I may be misremembering but I think that at the time, Logica was the work of one developer who happened to be at Google. I'm not sure that there was an institutional push to use this language, nor that it has significant adoption at Google itself.
This seems supported by the fact that the repo is not under a Google org and it has a single maintainer.
I don't think that matters? github.com/google has a bunch of projects with large warnings that "This is not a Google project", not sure why or how that is. From the outside it looks like if you work at Google, they take ownership of anything you write.
Re: Logica – Declarative logic programming language for data
#53There's also Malloy[0] from Google that compiles into SQL > Malloy is an experimental language for describing data relationships and transformations. [0]: https://github.com/malloydata/malloy
https://www.linkedin.com/posts/medriscoll_big-news-in-the-da...
Also for those playing along at home - a few other related tools for “doing more with queries”.
- AtScale - a semantic layer not dissimilar to LookML but with a good engine to optimize pre building the aggregates and routing queries among sql engines for perf.
- SDF - a team that left Meta to make a commercial offering for a sql parser and related tools. Say to help make dbt better.
(No affiliation other than having used / been involved with / know some of these people at work)
Re: Logica – Declarative logic programming language for data
#54Earlier quoted context omitted.
This seems supported by the fact that the repo is not under a Google org and it has a single maintainer.
> that the repo is not under a Google org I don't think that matters? github.com/google has a bunch of projects with large warnings that "This is not a Google project", not sure why or how that is. From the outside it looks like if you work at Google, they take ownership of anything you write.
That is precisely how it works.
Disclaimer: I am not a lawyer, and I'm sure the validity and enforceability of the relevant contract clauses varies by jurisdiction.
Re: Logica – Declarative logic programming language for data
#55Earlier quoted context omitted.
Never heard of M4 before and, lo and behold, of course HN has a discussion of it: https://news.ycombinator.com/item?id=34159699 The author discusses Logica vs. plain SQL vs POSIX. I’d always start with dbt/ Sqlmesh. The library you’re talking about exists: dbt packages. Check out hub.getdbt.com and you’ll find dozens of public packages for standardizing sources, data formatting or all kinds of data ops. You can use a…
M4 is absolutely ancient, one of those things you've probably only seen flashing by on your screen if you've found yourself running `make; make install`. I suppose it is a perfectly cromulent tool for SQL templating but you're right that you must be able to get more mileage out of something targeted like dbt/SQLMesh.
It’d be like saying - “hey, I’m starting a new project and trying to pick between ed, sed, or awk. Whatcha think”? Def not.
Re: Logica – Declarative logic programming language for data
#56Earlier quoted context omitted.
Never heard of M4 before and, lo and behold, of course HN has a discussion of it: https://news.ycombinator.com/item?id=34159699 The author discusses Logica vs. plain SQL vs POSIX. I’d always start with dbt/ Sqlmesh. The library you’re talking about exists: dbt packages. Check out hub.getdbt.com and you’ll find dozens of public packages for standardizing sources, data formatting or all kinds of data ops. You can use a…
M4 is absolutely ancient, one of those things you've probably only seen flashing by on your screen if you've found yourself running `make; make install`. I suppose it is a perfectly cromulent tool for SQL templating but you're right that you must be able to get more mileage out of something targeted like dbt/SQLMesh.
Re: Logica – Declarative logic programming language for data
#57Earlier quoted context omitted.
For the record, I don't use Logica myself so I'm not familiar with every design decision or feature -- I'm not a Python programmer. I'm speaking about Datalog in general. > making variables implicit at the call site What example are you looking at? The NewsData example for instance seems pretty understandable to me. It seems like for any given predicate you can either take the implicit name of the column or you can m…
They define a NewsData/5, but use a NewsData/2. Are you aware of any SQL transpilers that spend so much time transpiling that you get irritated? I'm not.
> Are you aware of any SQL transpilers that spend so much time transpiling that you get irritated? I'm not.
Again, when you are running a tool on something that returns results in ~millisecond time, it is important the tool does not spoil that. Even 100-200ms is noticeable when you're typing things out. They could have worded it differently, it's probably just typical "A programmer wrote these docs" stuff, so it's just bad copy. A dedicated technical writer would probably do something different.
Re: Logica – Declarative logic programming language for data
#58> Composite(a * b) distinct :- ... Wait, does Logica factorize the number passed to this predicate when unifying the number with a * b? So when we call Composite (100) it automatically tries all a's and b's who give 100 when m7ltiplied I'd be curious to see the SQL it transpiles to.
As someone who is intimately familiar with Datalog, but have not read much about Logica: The way I read these rules is not from left-to-right but from right-to-left. In this case, it would say: Pick two numbers a > 1 and b > 1, their product a*b is a composite number. The solver starts with the facts that are immediately evident, and repeatedly apply these rules until no more conclusions are left to be drawn. "But th…
I found a way to look at the SQL it generates without installing anything:
Execute the first two cells in the online tutorial collab (the Install and Import). Then replace the 3rd cell content with the following and execute it:
%%logica Composite
@Engine("sqlite"); # don't try to authorise and use BigQuery
# Define numbers 1 to 30.
Number(x + 1) :- x in Range(30);
# Defining composite numbers.
Composite(a * b) distinct :- Number(a), Number(b), a > 1, b > 1;
# Defining primes as "not composite".
Prime(n) distinct :- Number(n), n > 1, ~Composite(n);
Look at the SQL tab in the results.Re: Logica – Declarative logic programming language for data
#59> Composite(a * b) distinct :- ... Wait, does Logica factorize the number passed to this predicate when unifying the number with a * b? So when we call Composite (100) it automatically tries all a's and b's who give 100 when m7ltiplied I'd be curious to see the SQL it transpiles to.
As someone who is intimately familiar with Datalog, but have not read much about Logica: The way I read these rules is not from left-to-right but from right-to-left. In this case, it would say: Pick two numbers a > 1 and b > 1, their product a*b is a composite number. The solver starts with the facts that are immediately evident, and repeatedly apply these rules until no more conclusions are left to be drawn. "But th…
Re: Logica – Declarative logic programming language for data
#60There don't seem to be any examples of how to connect to an existing (say sqlite) database even though it says you should try logica if "you already have data in BigQuery, PostgreSQL or SQLite,". How do you connect to an existing sqlite database?
To use SQLite use @Engine("sqlite") imperative. And you can then connect to you database file with @AttachDatabase imperative.
For example if you have example.db file with Fruit table which has col0 column, then you can count fruits with program:
@Engine("sqlite"); @AttachDatabase("example", "example.db");
CountFruit(fruit) += 1 :- Fruit(fruit);
Then run CountFruit predicate.