Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Develop the conversion of Datalog rules into operation-based SQL queries#72

Open
gfngfn wants to merge 57 commits intodangtv:masterfrom
gfngfn:dev-operation-based-conversion
Open

Develop the conversion of Datalog rules into operation-based SQL queries#72
gfngfn wants to merge 57 commits intodangtv:masterfrom
gfngfn:dev-operation-based-conversion

Conversation

@gfngfn
Copy link
Contributor

@gfngfn gfngfn commented Jun 23, 2022

This PR adds the following function to Ast2sql:

val convert_expr_to_operation_based_sql : Expr.expr -> (sql_operation list, error) result

This function takes the following arguments:

  • expr : Expr.expr: Datalog rules and sources for conversion

and then converts expr.rules to the corresponding operation-based SQL queries. Rules that contain NumberedVar or AggVar are currently not supported, though.

The present PR also adds unit tests for the function above as src/test/ast2sql_operation_based_conversion_test.ml. One can run these tests by invoking:

$ make test

In order to confirm that convert_expr_to_operation_based_sql works as intended, please see:

  1. the unit tests, and
  2. the following results of operation check:

I would appreciate it if you could give any comments or suggestion.

@gfngfn gfngfn marked this pull request as draft July 14, 2022 14:40
@gfngfn gfngfn marked this pull request as ready for review July 20, 2022 15:37
@gfngfn gfngfn changed the title [WIP] Develop the conversion of Datalog rules into operation-based SQL queries Develop the conversion of Datalog rules into operation-based SQL queries Jul 20, 2022
Printf.sprintf "CREATE TEMPORARY TABLE temp2 AS %s;" query3;
"INSERT INTO temp0 SELECT * FROM temp0 AS inst;";
"DELETE FROM temp1 WHERE EXISTS ( SELECT * FROM temp1 AS inst );";
"INSERT INTO temp2 SELECT * FROM temp2 AS inst;";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • What is AS inst? Is it necessary?
  • rule1 means add to ed, so the corresponding query1 must be INSERT INTO ed, same for temp2 and DELETE statement.
  • The DELETE statement didn't work in the original spec, if it existed, it would all disappear, what I want to do is something like eed - temp1, can SQL do something with the DELETE WHERE clause (instead of EXISTS)?

Copy link
Contributor Author

@gfngfn gfngfn Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you all for pointing out!

Firstly c1f9657 remedies the second problem.

Copy link
Contributor Author

@gfngfn gfngfn Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

205e15a remedies the first issue (i.e. removes unnecessary AS insts).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

06c3b1a fixes the third issue, i.e., makes the program output DELETE queries appropriate in operational terms (which do not seem so performant though).

@gfngfn gfngfn mentioned this pull request Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments