HazyResearch / ddlog

Compiler for writing DeepDive applications in a Datalog-like language — ⚠️🚧🛑 REPO MOVED TO DEEPDIVE 👇🏿
https://github.com/HazyResearch/deepdive/tree/master/compiler/ddlog
19 stars 4 forks source link

New mode for compiling SQL queries from DDlog's query syntax #76

Closed netj closed 8 years ago

netj commented 8 years ago

ddlog query for implementing deepdive query in HazyResearch/deepdive#476

feiranwang commented 8 years ago

The order_by annotation takes a different form from other annotations. Looks good other than this.

netj commented 8 years ago

Not sure what you mean by different form? That it parses with the general annotation parser also used for schema annotations? I think the rest of annotations in the future should be parsed in that way, maybe except @weight and @label that take general expressions.

feiranwang commented 8 years ago

By different form I mean there is a @order_by num_candidates, and I was assuming something like @order_by(num_candidates). Maybe the former is also allowed in the general annotations?

netj commented 8 years ago

Those two are separate: an annotation (@order_by) and an expression (num_candidates). I extended the grammar (at least for the query rules) to accept optional annotations before each head term expression. See my examples in HazyResearch/deepdive#476. So @foo @order_by @bar(123,456) num_candidates, @bar(78,90) another_var ?- ... is also valid.

Query rules are special case and the first won't get confused with rule annotations. For normal rules (in the future when we extend the grammar), I think there won't be ambiguity because the head name and a parenthesis will also be there before each head term expression, right?

There's a limitation that you can't hide the order by column of course but I think people will like to just prefix a column with an annotation rather than repeating a variable or expression to simply order by. If we think people will frequently want to drop the ordering column, we should go ahead and support @order_by for normal rules as well, so a temporary table/view can be defined first then projected out in the actual query.

feiranwang commented 8 years ago

I see. Thanks for the explanation!

On Feb 1, 2016, at 2:04 AM, Jaeho Shin notifications@github.com wrote:

Those two are separate: an annotation (@order_by) and an expression (num_candidates). I extended the grammar (at least for the query rules) to accept optional annotations before each head term expression. See my examples in HazyResearch/deepdive#476. So @foo @order_by @bar(123,456) num_candidates, @bar(78,90) another_var ?- ... is also valid.

Query rules are special case and the first won't get confused with rule annotations. For normal rules (in the future when we extend the grammar), I think there won't be ambiguity because the head name and a parenthesis will also be there before each head term expression, right?

There's a limitation that you can't hide the order by column of course but I think people will like to just prefix a column with an annotation rather than repeating a variable or expression to simply order by. If we think people will frequently want to drop the ordering column, we should go ahead and support @order_by for normal rules as well, so a temporary table/view can be defined first then projected out in the actual query.

— Reply to this email directly or view it on GitHub.

netj commented 8 years ago

(I'm resolving the merge conflicts now btw)

netj commented 8 years ago

Oops the lower coverage shows some dead code and sloppy merge of mine. Will push another commit. Please merge later!

netj commented 8 years ago

Okay ready to merge. Coverage drop seems negligible.

bar commented 8 years ago

@netj WAT?