saltzm / yadi Goto Github PK
View Code? Open in Web Editor NEWThe YADI2 Project for the Advanced Databases Course in the DMKM Master's Program
License: BSD 3-Clause "New" or "Revised" License
The YADI2 Project for the Advanced Databases Course in the DMKM Master's Program
License: BSD 3-Clause "New" or "Revised" License
yadi> m(M) :- movie(M,'Chabrol',,D), D=Y,Y=Z,Z=2000.
Info:
Query transformed into: m(M):-movie(M,'Chabrol',,2000)
2013-11-18 02:40:39,141 INFO sqlalchemy.engine.base.Engine SELECT movie._0 as M FROM movie WHERE movie._3 = 2000 AND movie._1 = 'Chabrol';
2013-11-18 02:40:39,141 INFO sqlalchemy.engine.base.Engine {}
++
++
Hard to intepret
decide whether or not to allow duplicate results
yadi> users(Name):-tuser(Name,,,),not(tuser(Name,,,'Lyon')).
Original query before processing: users():-tuser(,,),!tuser(,,'Lyon')
Info:
Query transformed into: users():-tuser(,,),!tuser(,_,'Lyon')
Traceback (most recent call last):
File "./yadi/TranslationWrapper/translateDatalogToSQL.py", line 28, in translateDatalogToSql
sql_query = QueryExecutor().execute_query(ast_query)
File "./yadi/queryExecutor/queryExecutor.py", line 14, in execute_query
sql = SQLGenerator().get_SQL_code(new_query,query)
File "./yadi/queryExecutor/sqlFactory.py", line 9, in get_SQL_code
return sql_gen.get_SQL_code(query,old_query)
File "./yadi/queryExecutor/sqlFactory.py", line 28, in get_SQL_code
negated_queries = self.get_negated_queries(query.get_relations(),var_dict)
File "./yadi/queryExecutor/sqlFactory.py", line 181, in get_negated_queries
if element.is_variable():
AttributeError: 'str' object has no attribute 'is_variable'
r(M,A):- movie(M, 'Ethan Coen', ,), featuring (M,A,,). is functioning
r(M,Ac):- movie(M,'Ethan Coen', ,), featuring (M,Ac,,). is not functioning
The only difference is the name of the actor variable A, Ac. Shouldn't Ac be accepted?
yadi> tweet(X, Y, Z).
Original query before processing: None:-tweet(X,Y,Z)
Query transformed into: answer(Y,X,Z):-tweet(X,Y,Z)
yadi> moviesDirectorNotActor(Title):- movie(Title,Director,,),not(featuring(Title,Director,)).
Original query before processing: moviesDirectorNotActor():-movie(,),!featuring()
Info:
Query transformed into: moviesDirectorNotActor():-movie(,),!featuring(_)
Traceback (most recent call last):
File "./yadi/TranslationWrapper/translateDatalogToSQL.py", line 28, in translateDatalogToSql
sql_query = QueryExecutor().execute_query(ast_query)
File "./yadi/queryExecutor/queryExecutor.py", line 14, in execute_query
sql = SQLGenerator().get_SQL_code(new_query,query)
File "./yadi/queryExecutor/sqlFactory.py", line 9, in get_SQL_code
return sql_gen.get_SQL_code(query,old_query)
File "./yadi/queryExecutor/sqlFactory.py", line 28, in get_SQL_code
negated_queries = self.get_negated_queries(query.get_relations(),var_dict)
File "./yadi/queryExecutor/sqlFactory.py", line 181, in get_negated_queries
if element.is_variable():
AttributeError: 'str' object has no attribute 'is_variable'
Lexical analysis/parsing to extract tokens from charstream (Lex-like)
yadi> asdf.
Traceback (most recent call last):
File "./yadi/TranslationWrapper/translateDatalogToSQL.py", line 24, in translateDatalogToSql
ast_query_list = ast_builder.buildAST(parsed_statement.asList())
File "./yadi/ASTFactory/ASTBuilder.py", line 35, in buildAST
x = self.handleStatement(code_line)
File "./yadi/ASTFactory/ASTBuilder.py", line 63, in handleStatement
statement_ast = self.handleFact(statement)
File "./yadi/ASTFactory/ASTBuilder.py", line 81, in handleFact
return self.rule_handler.handleFact(statement)
File "./yadi/ASTFactory/RuleHandler.py", line 26, in handleFact
relation_object_list, constraint_object_list = self.handleBody(fact)
File "./yadi/ASTFactory/RuleHandler.py", line 61, in handleBody
relation_list.append(self.handleRelation(body_part))
File "./yadi/ASTFactory/RuleHandler.py", line 77, in handleRelation
if not isinstance(relation[1], list):
IndexError: list index out of range
yadi> r(Title1,Title2,ReleaseDate):-movie(Title1,,,ReleaseDate),movie(Title2,,,ReleaseDate).
Original query before processing: r():-movie(,),movie(,)
Info:
Query transformed into: r():-movie(,),movie(,)
2013-11-18 02:51:50,747 INFO sqlalchemy.engine.base.Engine SELECT 'TRUE' FROM movie as movie1, movie as movie0;
2013-11-18 02:51:50,747 INFO sqlalchemy.engine.base.Engine {}
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
If someone turns on duplicates, for example, or turns off pretty print, we need a way to store and access that information. The creation of a container class will probably be necessary.
yadi> tuser(,,).
Info:
Query transformed into: answer():-tuser(,,)
2013-11-18 02:15:37,701 INFO sqlalchemy.engine.base.Engine SELECT 'TRUE' FROM tuser;
2013-11-18 02:15:37,701 INFO sqlalchemy.engine.base.Engine {}
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
| TRUE |
+------+
yadi> r(Title1,Title2,Release_date):-movie(Title1,,,Release_date),movie(Title2,,,Release_date).
Original query before processing: r(date):-movie(,,date),movie(,,date)
Info:
Query transformed into: r(date):-movie(,,date),movie(,_,_date)
2013-11-18 02:50:13,618 INFO sqlalchemy.engine.base.Engine SELECT _date FROM movie as movie1, movie as movie0 WHERE movie1._2 = _date AND movie0._2 = _date;
2013-11-18 02:50:13,618 INFO sqlalchemy.engine.base.Engine {}
2013-11-18 02:50:13,619 INFO sqlalchemy.engine.base.Engine ROLLBACK
(ProgrammingError) column "_date" does not exist
LINE 1: SELECT _date FROM movie as movie1, movie as movie0 WHERE mov...
^
'SELECT _date FROM movie as movie1, movie as movie0 WHERE movie1._2 = _date AND movie0._2 = _date;' {}
yadi> asdf.
Traceback (most recent call last):
File "./yadi/TranslationWrapper/translateDatalogToSQL.py", line 24, in translateDatalogToSql
ast_query_list = ast_builder.buildAST(parsed_statement.asList())
File "./yadi/ASTFactory/ASTBuilder.py", line 35, in buildAST
x = self.handleStatement(code_line)
File "./yadi/ASTFactory/ASTBuilder.py", line 63, in handleStatement
statement_ast = self.handleFact(statement)
File "./yadi/ASTFactory/ASTBuilder.py", line 81, in handleFact
return self.rule_handler.handleFact(statement)
File "./yadi/ASTFactory/RuleHandler.py", line 26, in handleFact
relation_object_list, constraint_object_list = self.handleBody(fact)
File "./yadi/ASTFactory/RuleHandler.py", line 61, in handleBody
relation_list.append(self.handleRelation(body_part))
File "./yadi/ASTFactory/RuleHandler.py", line 77, in handleRelation
if not isinstance(relation[1], list):
IndexError: list index out of range
yadi> tuser(x,y).
Info:
Query transformed into: answer():-tuser(x,y)
2013-11-18 02:18:45,647 INFO sqlalchemy.engine.base.Engine SELECT 'TRUE' FROM tuser WHERE tuser._1 = y AND tuser._0 = x;
2013-11-18 02:18:45,647 INFO sqlalchemy.engine.base.Engine {}
2013-11-18 02:18:45,648 INFO sqlalchemy.engine.base.Engine ROLLBACK
(ProgrammingError) column "y" does not exist
LINE 1: SELECT 'TRUE' FROM tuser WHERE tuser._1 = y AND tuser._0 = x...
^
"SELECT 'TRUE' FROM tuser WHERE tuser._1 = y AND tuser._0 = x;" {}
Query transformed into: movie(A):-movie(A,B,C,D,E,F)
2013-11-20 14:02:06,699 INFO sqlalchemy.engine.base.Engine SELECT movie._0 as A FROM movie;
2013-11-20 14:02:06,699 INFO sqlalchemy.engine.base.Engine {}
+------------------------+
| Home Alone |
+------------------------+
| Life Is Beautiful |
+------------------------+
| Casino |
+------------------------+
| Toy Story |
+------------------------+
| No Country for Old Men |
+------------------------+
yadi> movie(E) :- movie(A, B, C, D, E, F).
Original query before processing: movie(E):-movie(A,B,C,D,E,F)
Info:
Query transformed into: movie(E):-movie(A,B,C,D,E,F)
2013-11-20 14:02:12,415 INFO sqlalchemy.engine.base.Engine SELECT movie._4 as E FROM movie;
2013-11-20 14:02:12,415 INFO sqlalchemy.engine.base.Engine {}
2013-11-20 14:02:12,419 INFO sqlalchemy.engine.base.Engine ROLLBACK
(ProgrammingError) column movie._4 does not exist
LINE 1: SELECT movie._4 as E FROM movie;
^
'SELECT movie._4 as E FROM movie;' {}
Since the SQL selects only based on head variables, if you do something like movie(A):-movie(A,B,C,D,E,F), even if there are only 3 columns in the movie relation, it will return successfully instead of raising an error. I think it should raise an error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.