Book Image

Clojure Data Analysis Cookbook - Second Edition

By : Eric Richard Rochester
Book Image

Clojure Data Analysis Cookbook - Second Edition

By: Eric Richard Rochester

Overview of this book

Table of Contents (19 chapters)
Clojure Data Analysis Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Executing complex queries with Cascalog


So far, we've seen basic Cascalog predicates and queries. We saw queries that pull data from one source generator and maybe include one predicate test. In this recipe, we'll see several more complex queries.

Getting ready

For this recipe, we'll need the same project.clj file and dependencies from the Initializing Cascalog and Hadoop for distributed processing recipe. We'll also use the Doctor Who companion data that we defined in that recipe. The source code for this data is available in the code for the book, and you can also download just the code from http://www.ericrochester.com/clj-data-analysis/data/companions.clj to create this dataset.

How to do it…

We'll start with simple queries and build up from there:

  1. First, let's take a look at a simple join:

    user=> (?<- (stdout) [?name ?dr]
          (full-name ?c ?name) (doctor ?c ?dr))
    …
    RESULTS
    -----------------------
    Ace     7
    Adam Mitchell   9
    Adelaide Brooke 10
    Adric   4
    Adric   5
    Amy Pond        11...