
We would like to introduce you to the spark-cloudant connector, allowing you to use Spark to conduct advanced analytics on your Cloudant data. The spark-cloudant connector can be found on GitHub or the Spark Packages site and is available for all to use under the Apache 2.0 License. As with most things Spark, it’s available for Python and Scala applications.
If you haven’t heard of Apache Spark™, it is the new cool kid on the block in the analytics space. Spark is touted as being an order of magnitude faster and much easier to use than its analytic predecessors, and its popularity has skyrocketed in the past couple of years. If you would like to learn more about Spark in general, I recommend checking out the Spark Fundamentals classes on Big Data Universityand the great tutorials on IBM developerWorks.
Start fast with Spark on Bluemix
So how do you get going quickly in analyzing your Cloudant data in Spark? Luckily, IBM has a fully-managed Spark-aaS offering in IBM Bluemix that has the latest version of the spark-cloudant connector already loaded for you. Head on over to theBluemix catalog to sign-up and create a Spark instance to get started. Since the spark-cloudant connector is open source, you are also free to use it in your own stand-alone Spark deployments with Cloudant or Apache CouchDB™. Next, check out the README on GitHub, the Bluemix docs on Spark-aaS, and the great video tutorials on the Learning Center showing how to use the connector in both a Scala and Python notebook.
The integration with Spark opens the door to a number of new analytical use cases for Cloudant data. You can load whole databases into a Spark cluster for analysis. Alternatively you can read from a Cloudant secondary index (a.k.a. “MapReduce view”) to pull a filtered subset or cleansed version of your Cloudant JSON. Once you have the data in Spark, use SparkSQL for full adhoc querying capabilities in familiar SQL syntax. Spark can efficiently transform or filter your data and write it back into Cloudant or another data source. Because Spark has a variety of connection capabilities, you can also use it to conduct federated analytics over disparate data sources such as Cloudant, dashDB and Object Storage.
Example: Cloudant analytics with Spark
To provide another example of using the spark-cloudant connector, check out thisexample Python Notebook on GitHub and load it into your Spark service running on Bluemix. (It becomes interactive once you upload it to a Spark notebook using the instructions below.) This notebook does the following:
- Loads a Cloudant database
spark_sales
from Cloudant’s examples account containing documents with sales rep, month, and amount fields.(Feel free to replicate thehttps://examples.cloudant.com/spark_sales
database into your own Cloudant account and update the connection details if you prefer.) - Detects and prints the schema found in the JSON documents.
- Counts the number of documents in the database.
- Prints out a subset of the data and shows how to print out a specific field in the data.
- Uses SparkSQL to perform counts, sums, and order by value queries on the data.
- Prints a graph of the monthly sales.
- Filters the data based on a specific sales rep and month.
- Counts and shows the filtered data.
- Saves the filtered data as documents into a Cloudant database in your own account.
This article was originally published on ibm.com and can be viewed in full here


Archive
- October 2024(44)
- September 2024(94)
- August 2024(100)
- July 2024(99)
- June 2024(126)
- May 2024(155)
- April 2024(123)
- March 2024(112)
- February 2024(109)
- January 2024(95)
- December 2023(56)
- November 2023(86)
- October 2023(97)
- September 2023(89)
- August 2023(101)
- July 2023(104)
- June 2023(113)
- May 2023(103)
- April 2023(93)
- March 2023(129)
- February 2023(77)
- January 2023(91)
- December 2022(90)
- November 2022(125)
- October 2022(117)
- September 2022(137)
- August 2022(119)
- July 2022(99)
- June 2022(128)
- May 2022(112)
- April 2022(108)
- March 2022(121)
- February 2022(93)
- January 2022(110)
- December 2021(92)
- November 2021(107)
- October 2021(101)
- September 2021(81)
- August 2021(74)
- July 2021(78)
- June 2021(92)
- May 2021(67)
- April 2021(79)
- March 2021(79)
- February 2021(58)
- January 2021(55)
- December 2020(56)
- November 2020(59)
- October 2020(78)
- September 2020(72)
- August 2020(64)
- July 2020(71)
- June 2020(74)
- May 2020(50)
- April 2020(71)
- March 2020(71)
- February 2020(58)
- January 2020(62)
- December 2019(57)
- November 2019(64)
- October 2019(25)
- September 2019(24)
- August 2019(14)
- July 2019(23)
- June 2019(54)
- May 2019(82)
- April 2019(76)
- March 2019(71)
- February 2019(67)
- January 2019(75)
- December 2018(44)
- November 2018(47)
- October 2018(74)
- September 2018(54)
- August 2018(61)
- July 2018(72)
- June 2018(62)
- May 2018(62)
- April 2018(73)
- March 2018(76)
- February 2018(8)
- January 2018(7)
- December 2017(6)
- November 2017(8)
- October 2017(3)
- September 2017(4)
- August 2017(4)
- July 2017(2)
- June 2017(5)
- May 2017(6)
- April 2017(11)
- March 2017(8)
- February 2017(16)
- January 2017(10)
- December 2016(12)
- November 2016(20)
- October 2016(7)
- September 2016(102)
- August 2016(168)
- July 2016(141)
- June 2016(149)
- May 2016(117)
- April 2016(59)
- March 2016(85)
- February 2016(153)
- December 2015(150)