<<

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!

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 : Data tables and sources

•! Collections of structured documents –! Pictures, events, connections, items… •! Yahoo! specific sets of tables –! Social, Upcoming, Flickr, Geo, Local, Search •! External data source tables –! XML (, RSS), JSON, CSV, HTML

7! WHERE : Remote and Local filtering

•! 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 : Remote filtering

•! 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 : Local filtering

•! 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 : Projecting the data you need

•! 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: –!

(0)

13 ! Post-query manipulation

•! Simple post-SELECT processing can be performed by appending the “pipe” symbol to the end of the statement:

SELECT … |sort(field=item.date)" SELECT … |unique(field=item.title)| …

•! Functions only operate on the data being returned by the query, nothing to do with the tables or data sources themselves

14 ! Using YQL in your applications

•! YQL can be accessed at: http://query.yahooapis.com/v1/yql?q=… "

•! oauth 1.1. protected –! You’ll need an oauth ck+cks and (optionally) a user access token and access token secret to execute calls

15 ! From PHP or YAP/PHP

! ! !

 ! getSessionedUser(); ! $client = new YahooClient($session); ! var_dump( $client->query('select * from social.profile where guid=me') ); ! ?> ! 
! !

16 ! From YAP/

!

17 ! 18 ! Where now?

•! Main page http://hackday.developer.yahoo.com/yql •! Testing console http://hackday.developer.yahoo.com/yql/ console •! Documentation http://hackday.developer.yahoo.com/yql/docs

19 ! Q&A

20 ! Testing your queries hackday.developer.yahoo.com/yql/console/

21 !