Apache Sqoop
- Problem solved: bulk-transfer tables from a relational database (MySQL, Oracle, PostgreSQL...) into HDFS or Hive, in parallel and without home-made scripts, and send results back to the database.
- Era: announced on June 1, 2009 at Cloudera, Hadoop contrib module from May 2009 to April 2010, Apache Incubator on June 13, 2011, Apache top-level project on March 21, 2012, retired in June 2021 (Attic in July 2021).
- Category: batch data ingestion and transfer tool (relational databases and Hadoop).
- Created by: Aaron Kimball, at Cloudera; later maintained notably by Arvind Prabhakar and Ahmed Radwan.
Historical context
In 2009, companies adopt Hadoop to analyze data that often
lives elsewhere: in relational databases, spreadsheets or data warehouses. To
bring it into HDFS, the methods of the time are "inefficient and ad hoc, often
consisting of manual steps specific to the external system", sums up the
incubation proposal. Hadoop already offers DBInputFormat, which lets a
MapReduce job read rows through JDBC, but you have to write everything
yourself.
On June 1, 2009, Aaron Kimball announces Sqoop on the Cloudera blog, for "SQL-to-Hadoop": "a straightforward command-line tool" that imports a table or a whole database into HDFS, generates Java classes to work with the imported data and can load it straight into Hive. The tool was previewed at the May 2009 Bay Area Hadoop User Group. It ships as a beta in Cloudera's Hadoop distribution and is offered to Hadoop as a patch (HADOOP-5815).
Sqoop first lives as a Hadoop contrib module, from May 2009 to April 2010, then is removed from it (MAPREDUCE-1644) and maintained by Cloudera as an open source project, with three releases (1.0, 1.1 and 1.2). In June 2011, it enters the Apache Incubator with committers from Cloudera, Odiago, Quest and NASA's JPL. It becomes a top-level project on March 21, 2012, with "jobs transferring data on the order of billions of rows" according to its vice president Arvind Prabhakar.
What follows is a slow decline. The last stable release, 1.4.7, comes out in January 2018. The last release of the Sqoop 2 branch (1.99.7, 2016) is not intended for production, warns the website. In June 2021, noting that "the project contributions have been steadily diminishing", the project committee votes to move to the Apache Attic, the ASF's home for retired projects.
Key idea
Turn an import into a parallel MapReduce task. Sqoop reads the table schema from the database, generates a Java class that can read and write a row, then launches a MapReduce job: each "map" task reads a slice of the table through JDBC and writes it to HDFS. You get Hadoop's parallelism and fault tolerance without writing code.
The split relies on a split column (the primary key by default): Sqoop asks the database for the minimum and maximum values, then divides the range into equal parts across tasks.
How it works
- JDBC connection:
--connectgives the database URL; specialized connectors exist for MySQL, PostgreSQL, Oracle, SQL Server and DB2, and the architecture accepts third-party connectors. - Code generation: Sqoop writes the class definition matching the imported columns, reusable in other MapReduce programs.
- Parallelism: 4 map tasks by default (
-mor--num-mappers). With anidkey from 0 to 1000 and 4 tasks, each task runs a querySELECT * FROM table WHERE id >= lo AND id < hion a quarter of the range.--split-bypicks another column if values are unevenly distributed. - Direct mode: for MySQL, Sqoop can use the native export tool
mysqldump, faster than JDBC. - Incremental import:
--incremental append(new rows with increasing IDs) orlastmodified(rows changed since a timestamp), with--check-columnand--last-value. - Export: the
exporttool reads HDFS files back and inserts them into a table that must already exist in the database. - Targets: HDFS files, Hive and HBase tables.
# 2009: import the USERS table from a local MySQL database straight into Hive
sqoop --connect jdbc:mysql://db.example.com/website --table USERS --local --hive-import
# Sqoop 1.4: parallel import on 8 tasks, then incremental import
sqoop import --connect jdbc:mysql://db.example.com/shop --table orders \
--split-by order_id -m 8 --target-dir /data/orders
sqoop import --connect jdbc:mysql://db.example.com/shop --table orders \
--incremental append --check-column order_id --last-value 100000
By the numbers
| Figure | Context | Source |
|---|---|---|
| 4 | Number of map tasks launched by default; 8 or 16 may help depending on the database (1.4.7 guide) | Sqoop user guide |
| 5 | Systems with a connector when leaving the incubator: MySQL, PostgreSQL, Oracle, SQL Server, DB2 (April 2012) | ASF press release 2012 |
| Billions of rows | Order of magnitude of production transfers cited by the project vice president (April 2012) | ASF press release 2012 |
| 3 | Releases published at Cloudera before the ASF: 1.0, 1.1 and 1.2 (2011) | Incubation proposal |
| 9 months | Length of incubation, from June 13, 2011 to March 21, 2012 | ASF incubation page |
| 32 committers, 18 PMC members | Project headcount at the time of the retirement vote (June 2021) | ASF board |
| 3.5 years | Gap between the last stable release (January 2018) and retirement (June 2021) | ASF board |
Milestones
- May 2009: preview at the Bay Area Hadoop User Group; HADOOP-5815 patch for Hadoop.
- June 1, 2009: Sqoop announced on the Cloudera blog, first beta in Cloudera's distribution.
- April 2010: removed from Hadoop contrib (MAPREDUCE-1644), Sqoop becomes an open source project maintained by Cloudera.
- June 13, 2011: enters the Apache Incubator; transfer from Cloudera completed on July 23, 2011.
- November 29, 2011: first incubating release, 1.4.0-incubating.
- March 21, 2012: Sqoop becomes an Apache top-level project (public announcement on April 2, 2012).
- August 8, 2016: Sqoop 2 version 1.99.7 is released, not intended for production.
- January 2018: Sqoop 1.4.7 is released, the last stable version.
- June 16, 2021: the ASF board terminates the project; the move to the Attic is completed in July 2021.
Did you know?
- A name that says it all: Sqoop is short for "SQL-to-Hadoop", wrote Aaron Kimball in the very first post.
- Export, not yet: to a reader asking in June 2009 whether the tool could run in reverse, from Hive to MySQL, Aaron Kimball replied "Not yet. But we're working on it!".
- NASA on the team: among the initial committers of the incubation was an engineer from the Jet Propulsion Laboratory.
- Sqoop 2, the eternal draft: the official website warns that 1.99.7 "is not compatible with 1.4.7 and not feature complete, it is not intended for production deployment".
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Parallel import without writing code | Batch processing: no continuous change capture |
| Built on JDBC, so on almost any database | Unbalanced split if the split column is unevenly distributed |
| Direct integration with Hive and HBase | Tied to MapReduce, an ageing execution model |
| Incremental import and export to the database | Retired since 2021, no longer maintained |
What came next
- Sqoop has no successor designated by the ASF. For similar needs, see change data capture with Debezium, data flows with NiFi or parallel JDBC reads in Spark.
- Imported tables fed Hive, then SQL engines such as Impala or Trino.
Sources
raw-data/apache/sqoop/sqoop.md- https://web.archive.org/web/2009/http://www.cloudera.com/blog/2009/06/introducing-sqoop/
- https://cwiki.apache.org/confluence/display/INCUBATOR/SqoopProposal
- https://incubator.apache.org/projects/sqoop.html
- https://news.apache.org/foundation/entry/the_apache_software_foundation_announces25
- https://www.apache.org/foundation/board/minutes/Sqoop.html
- https://attic.apache.org/projects/sqoop.html
- https://sqoop.apache.org/
- https://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html
- https://en.wikipedia.org/wiki/Sqoop [S]
- Exact date of 1.4.7: board reports give January 23 or 24, 2018, Wikipedia [S] says December 6, 2017.
- Release date of Sqoop 1.0 at Cloudera: not sourced.
- Limitations "no continuous change capture" and "ageing execution model": plausible deductions, not explicitly sourced.
- Parallel JDBC reads in Spark: capability to source from the Spark documentation.