Since Sqoop2 is primarily JAVA, we will be using the google JAVA coding standards for the most parts. Some of the custom nuances that already exist in Sqoop are also highlighted with code examples,so new contributors spend your time wisely. When in doubt, use the google guide as a reference and email the about a convention you deem is important for us to follow.

General Rules

  • No wildcard imports.
  • Overloads appear sequentially.
  • Braces are used even when the body is empty or contains a single statement.
  • 2 spaces indentation.
  • Column limit can be 80 or 100 characters.
  • No C-style array declarations.
  • The default statement in switch statements are required.
  • Modifiers appear in the order recommended by the Java Language Specification.
  • Constants use CONSTANT_CASE. Note that every constant is a static final field, but not all static final fields are constants

Must Follow Rules

License or copyright information

The Apache License info must be present for all files. So please use a simple script to check this license header exists before uploading the patch. ! 

Wild card imports

Unless the entire set of imports are used in the file. For example in every single constant in DerbySchemaConstants is used. In this case, it is ok to use wildcard. 

Column Limit and Line Wrapping

We can use the 100 character limit.

 Having said that,  I have to steal this line from the Kafka Style guide.


There is not a maximum line length (certainly not 80 characters, we don't work on punch cards any more), but be reasonable

Import Order and Grouping

Import statements are not line-wrapped

  1. All static imports in a single group
  2. com.* imports (only if this source file is in the package space)
  3. Third-party imports, one group per top-level package, in ASCII sort orderjava imports
    • for example: androidcomjunitorgsun
  4. java imports

  5. javax imports

Method Names in APIs

Method names are typically verbs or verb phrases. For example, sendMessage or stopJob. We do not recommend messageSend or jobStop.!

Do not ignore caught Exceptions

If in case, you have very legit reason to ignore it , have a comment, DO NOT leave it blank. It's also generally a good idea to log the error message, so that we know that it happened.

try {
} catch (SqoopException ok) {
  // its ok for me ignore this, since it is harmless

Some conventions in Sqoop that you should follow!

  1. All unit test classes should be in the exact same package hierarchy as the source java class
  2. All unit test classes should begin with Test for instance instead of CSVIntermediateFormatTest. Integration tests apparently have format 

  3. If you see code duplicated, please create a JIRA and let us all know, we can collectively do the cleanup.

  4. Do not try to catch exceptions that you do not know how to handle, let it bubble up. 

  5. Try to use the IDE to clean-up unused imports

  6. Try not to create code with warnings. Especially when the IDE is screaming at you and telling you how to fix them!

  7. Goes without saying, do not have functions that run 100 lines long. break them down so it is easy to read and unit test

  8. Use Log.DEBUG / Log.INFO statements generously in code that is not easy to follow. It helps the person debugging your code!
  9. Use IDE for hashCode and equals and toString code generation. Use IDE for refactoring cues.
  10. Apache Kafka Coding Guide very beautifully documents some of the basic stuff of writing code. Kindly read it. 

        Few of our favorites are:

    •  Clear code is preferable to comments. When possible make your naming so good you don't need comments. When that isn't possible comments should be thought of as mandatory, write them to beread.
    •  Don't be sloppy. Don't check in commented out code: we use version control, it is still there in the history. Don't leave TODOs in the code or FIXMEs if you can help it. Don't leave println statements in the code. Hopefully this is all  obvious.  But if you still need to leave a TODO, create a ticket and then leave a TODO(SQOOP-1444), so we know what the details of the TODO are and who created it.
    •  Don't duplicate code (duh). Not even in tests. Not even constants!
    • Logging, configuration, and public APIs are our "UI". Make them pretty, consistent, and usable.

Sqoopesque Conventions !

Dont ask me which coding standard/ style guide prescribes the following conventions, but it exists in Sqoop predating 1.99.4 and the committers follow this religiously!. So spend you time wisely ! Feel free to leave comments on additional things you notice that might sound very much Sqoopesque ( Conventions that are less prevalent outside of Sqoop)  

  • Enum classes, the semicolon needs to be in its own line. 
public enum AuditLoggerError implements ErrorCode {
  /** An unknown error has occurred. */
  AUDIT_0000("An unknown error has occurred"),
  /** The system was unable to find or load the audit logger provider. */
  AUDIT_0001("The system was unable to find or load audit logger class"),
  /** The audit logger output file is not given. */
  AUDIT_0002("The output file for FileAuditLogger is not given"),
  • Also the Error codes have a format! Error codes are in the format ERROR_XXXX - four digits with leading zeros.
  • //todo





Before you get on to uploading the patch, also read this wiki that will help with getting through larger feature reviews quicker

Sqoop 2 Review Board Guidelines

  • No labels

1 Comment

  1. Error codes are in the format ERROR_XXXX - four digits with leading zeros.