Yahoo! Query Language Service (YQL)
Jonathan Trevor, Nagesh Susarla, Joshua Gordineer, Brad Clawsie, Paul Donnelly, Sam Pullara
1! 2! What’s it all about?
•! SQL-like language for accessing, filtering and mashing-up Yahoo! web services and any URL-addressable structured data sources •! Like Yahoo! Pipes but with a simple text- based language
3! The language and service
•! Provides three SQL-like statements: SELECT, SHOW, DESC
!SELECT * FROM social.profile ! !WHERE guid=me
•! Single URL endpoint for executing everything –! Mix and match external data and Yahoo! APIs
4! Demo
•! http://hackday.developer.yahoo.com/yql
5! The SELECT statement
SELECT what FROM collection WHERE filter condition IN (sub-select ) OFFSET n LIMIT n
6! FROM
•! Collections of structured documents –! Pictures, events, connections, rss items… •! Yahoo! specific sets of tables –! Social, Upcoming, Flickr, Geo, Local, Search •! External data source tables –! XML (ATOM, RSS), JSON, CSV, HTML
7! WHERE
•! Table data can be filtered in the WHERE clause either: •! Remotely by the table data source provider or •! Locally by the YQL engine
8! WHERE
•! Most tables require keys in the where clause before any data is available to YQL for processing –! E.g. “guid” for social.profiles –! DESC’ing a table shows “keys” for filtering remotely •! Correspond to query parameters for that services REST-endpoint
9! WHERE
•! Works on anything in the data •! >, <, = and so on •! Multiple operators can be combined using AND or OR •! Support for string and integer types •! Uses “dot” syntax for addressing parts of the XML structure
10 ! SELECT
•! Uses the dot syntax to project only the parts of each matching data item in the results
!SELECT guid " FROM social.connections " WHERE owner_guid=me !
11 ! IN (SELECT…): Joining across data sources
•! Get my friends profile information?
SELECT * " FROM social.profile " WHERE guid IN " (SELECT guid " !FROM social.connections WHERE !owner_guid=me) !
•! Sub-select works the same as normal select except it can only return a “leaf” element value or attribute
12 ! Changing the table size
•! Yahoo! tables are limited to a small number of results by default (10)
select * from local.search where zip='94085' and query='pizza’ "
•! If you want more data, you can expand the data set size that the source is providing:
select * from local.search(1000) where zip='94085' and query='pizza’ "
•! If you want the query to work over the maximum allowable set size: –!