320 likes | 443 Views
Continue the Development of SQL in fJySwan. Blake Kobelan , Brittany Blassingill , Andrew Spence. What we added. Basic functionality: Doubles Dates Longs Strings Expressions: Addition Multiplication < > !=. What we added. ORDER Bys JOIN OR AND ? - SUBSELECT.
E N D
Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence
Whatweadded • Basic functionality: • Doubles • Dates • Longs • Strings • Expressions: • Addition • Multiplication • < • > • !=
Whatweadded • ORDER Bys • JOIN • OR • AND • ? - SUBSELECT
Whatweinitiallydid • Instead of implementingthese changes in PyTuple.java, wecreated a visitor class thatusedJSQLParser and it’sowninternalgrammar to recognizefilters, tables, columns, etc.
Whatweinitiallydid • Wealso made someminor changes in Python.g:
‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’ • The JSQL Parser has a ‘temp’ global variable thatischangedbased on itsinternalgrammar. The parserwillautomaticallydetermine (via itsacceptmethod) which part of the SQL statementiswhat and passes itinto the appropriatevisitmethod. The temp variable isthenchanged. In this case, itwill first get the table name: Will call this temp = Persons
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’ • It willthen check for a WHERE clause and goesthrough a series of visits:
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’
getWhere() visit(OrExpression) getLeftExpression() getRightExpression() visit(EqualsTo) visit(EqualsTo) getLeftExpression() getRightExpression() getLeftExpression() getRightExpression() visit(column) visit(String) visit(column) visit(String) temp = FirstName temp = ‘Tove’ temp = FirstName temp = ‘Ola’ ‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’ Will do the samething for the right hand side
‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’ • wasEqualsiseventually set to false sincetherewere no matches and the OR clauses are interpreted as filters: • Finally, the columns are added:
‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’ • Final test output before RDF conversion:
Conversion to RDF • Our conversion takes place insideourSQLVisitor class. • As a smallexample: SELECT * FROM NEWTEST1 • Based on what isseen, a string getsconsistentlybuiltuntilit’s in the correct RDF format:
SELECT * FROM NEWTEST1 • SELECT sub, pred, objfrom table( SEM_MATCH(SELECT ?sub ?pred ?obj WHERE (?sub ?pred ?obj . )’. SEM_Models(‘NEWTEST1_CS345_RICK), null, SEM_ALIASES(SEM_ALIAS(‘tbl’, ‘www.example.org/NEWTEST1/’)), null))
Implementation in PyTuple.java • Sinceweused a visitor class, implementationwaspretty simple: • Wejust made a visitorobject and passed in the sqlstatement,