Hive Formatter
Format Apache Hive HiveQL with Hive rules for backtick identifiers, single and double quoted strings with backslash escapes and ${hivevar:name} variables. CLUSTER BY, DISTRIBUTE BY and SORT BY are kept as clauses, LATERAL VIEW and LEFT SEMI JOIN start new lines, and columns and conditions are indented. Unclosed strings and parentheses are reported with line and column for data engineers working with Hadoop.
Frequently asked questions
Which HiveQL syntax is understood?
Backtick identifiers and single and double quoted strings with backslash escapes are recognized. Map['key'] and array[0] subscripts and variable substitutions such as ${hivevar:date} and ${hiveconf:x} are kept intact.
Which Hive clauses get their own line?
CLUSTER BY, DISTRIBUTE BY and SORT BY are handled like ORDER BY. LATERAL VIEW, LATERAL VIEW OUTER and LEFT SEMI JOIN start new lines like joins.
Are variable substitutions kept?
Yes. ${hivevar:...} and ${hiveconf:...} placeholders are kept exactly as written. The colon inside them is never spaced out.
Can it format INSERT OVERWRITE statements?
Yes. INSERT OVERWRITE TABLE ... PARTITION (...) stays together and the SELECT that feeds it is formatted beneath it.
Does it support MERGE?
Yes. WHEN MATCHED and WHEN NOT MATCHED branches of ACID MERGE statements start new lines.
Are comments kept?
Yes. -- line comments and /* block comments */ stay in place. Multi-line block comments are re-indented to the new layout.
Does it change keyword case?
No. Keywords and names keep the case you wrote. Only whitespace and line breaks change.
Which errors are detected?
Unclosed strings, backtick identifiers, subscripts and block comments, and unbalanced parentheses, each with line and column. Nothing runs on your cluster.
How large can the input be?
Up to 1 MB per request and 128 KB per statement. Scripts with many statements are formatted one statement at a time.
Can I choose the indentation, and is my SQL stored?
Use 2 or 4 spaces or tabs. The SQL is formatted in memory only and never saved.