continue the development of sql in fjyswan blake kobelan, brittany blassingill, andrew spence

32
Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Upload: jessie-walker

Post on 19-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Continue the Development of SQL in fJySwan

Blake Kobelan, Brittany Blassingill, Andrew Spence

Page 2: 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– <– >– !=

Page 3: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

What we added

• ORDER Bys• JOIN• OR • AND• ? - SUBSELECT

Page 4: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

What we initially did

• Instead of implementing these changes in PyTuple.java, we created a visitor class that used JSQLParser and it’s own internal grammar to recognize filters, tables, columns, etc.

Page 5: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

What we initially did

• We also made some minor changes in Python.g:

Page 6: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’

• The JSQL Parser has a ‘temp’ global variable that is changed based

on its internal grammar. The parser will automatically determine (via its accept method) which part of the SQL statement is what and passes it into the appropriate visit method. The temp variable is then changed. In this case, it will first get the table name:

temp = Persons

Will call this

Page 7: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’

• It will then check for a WHERE clause and goes through 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’

Page 8: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 9: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 10: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 11: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 12: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 13: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 14: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 15: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 16: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Page 17: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’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’

Will do the same thing for the right hand side

Page 18: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’

• wasEquals is eventually set to false since there were no matches and the OR clauses are interpreted as filters:

• Finally, the columns are added:

Page 19: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

• Final test output before RDF conversion:

‘’SELECT * FROM Persons WHERE FirstName=‘Tove’ OR FirstName=‘Ola’’’

Page 20: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Conversion to RDF

• Our conversion takes place inside our SQLVisitor class.• As a small example: SELECT * FROM NEWTEST1

– Based on what is seen, a string gets consistently built until it’s in the correct RDF format:

Page 21: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

SELECT * FROM NEWTEST1

Page 22: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

SELECT * FROM NEWTEST1

– SELECT sub, pred, obj from 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))

Page 23: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Implementation in PyTuple.java

– Since we used a visitor class, implementation was pretty simple:– We just made a visitor object and passed in the sql statement,

Page 24: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 25: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 26: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 27: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 28: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 29: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 30: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 31: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered

Page 32: Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence

Concepts Covered