Skip to content

Commit b2d0284

Browse files
committed
format hive code
1 parent 294eb73 commit b2d0284

17 files changed

Lines changed: 127 additions & 159 deletions

src/sqlancer/hive/HiveOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public enum HiveOracleFactory implements OracleFactory<HiveGlobalState> {
2828
@Override
2929
public TestOracle<HiveGlobalState> create(HiveGlobalState globalState) throws SQLException {
3030
HiveExpressionGenerator gen = new HiveExpressionGenerator(globalState);
31-
ExpectedErrors expectedErrors = ExpectedErrors.newErrors()
32-
.with(HiveErrors.getExpressionErrors()).build();
31+
ExpectedErrors expectedErrors = ExpectedErrors.newErrors().with(HiveErrors.getExpressionErrors())
32+
.build();
3333

3434
return new TLPWhereOracle<>(globalState, gen, expectedErrors);
3535
}

src/sqlancer/hive/HiveProvider.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ public void generateDatabase(HiveGlobalState globalState) throws Exception {
6161
String tableName = globalState.getSchema().getFreeTableName();
6262
SQLQueryAdapter qt = HiveTableGenerator.generate(globalState, tableName);
6363
success = globalState.executeStatement(qt);
64-
} while(!success);
64+
} while (!success);
6565
}
6666
if (globalState.getSchema().getDatabaseTables().isEmpty()) {
6767
throw new IgnoreMeException(); // TODO
6868
}
6969

70-
StatementExecutor<HiveGlobalState, Action> se = new StatementExecutor<HiveGlobalState, Action>(
71-
globalState, Action.values(),
72-
HiveProvider::mapActions, (q) -> {
70+
StatementExecutor<HiveGlobalState, Action> se = new StatementExecutor<HiveGlobalState, Action>(globalState,
71+
Action.values(), HiveProvider::mapActions, (q) -> {
7372
if (globalState.getSchema().getDatabaseTables().isEmpty()) {
7473
throw new IgnoreMeException();
7574
}
@@ -107,9 +106,8 @@ public SQLConnection createDatabase(HiveGlobalState globalState) throws SQLExcep
107106
s.execute("USE " + databaseName);
108107
}
109108
con.close();
110-
con = DriverManager.getConnection(
111-
String.format("jdbc:hive2://%s:%d/%s", host, port, databaseName,
112-
username, password));
109+
con = DriverManager
110+
.getConnection(String.format("jdbc:hive2://%s:%d/%s", host, port, databaseName, username, password));
113111

114112
return new SQLConnection(con);
115113
}

src/sqlancer/hive/HiveToStringVisitor.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,26 @@ private void visit(HiveSelect select) {
7171

7272
private void visit(HiveJoin join) {
7373
switch (join.getJoinType()) {
74-
case INNER:
75-
sb.append(" INNER JOIN ");
76-
break;
77-
case LEFT_OUTER:
78-
sb.append(" LEFT JOIN ");
79-
break;
80-
case RIGHT_OUTER:
81-
sb.append(" RIGHT JOIN ");
82-
break;
83-
case FULL_OUTER:
84-
sb.append(" FULL JOIN ");
85-
break;
86-
case LEFT_SEMI:
87-
sb.append(" LEFT SEMI JOIN ");
88-
break;
89-
case CROSS:
90-
sb.append(" CROSS JOIN ");
91-
break;
92-
default:
93-
throw new UnsupportedOperationException();
74+
case INNER:
75+
sb.append(" INNER JOIN ");
76+
break;
77+
case LEFT_OUTER:
78+
sb.append(" LEFT JOIN ");
79+
break;
80+
case RIGHT_OUTER:
81+
sb.append(" RIGHT JOIN ");
82+
break;
83+
case FULL_OUTER:
84+
sb.append(" FULL JOIN ");
85+
break;
86+
case LEFT_SEMI:
87+
sb.append(" LEFT SEMI JOIN ");
88+
break;
89+
case CROSS:
90+
sb.append(" CROSS JOIN ");
91+
break;
92+
default:
93+
throw new UnsupportedOperationException();
9494
}
9595
visit((TableReferenceNode<HiveExpression, HiveSchema.HiveTable>) join.getRightTable());
9696
if (join.getOnClause() != null) {

src/sqlancer/hive/ast/HiveBetweenOperation.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import sqlancer.common.ast.newast.NewBetweenOperatorNode;
44

5-
public class HiveBetweenOperation extends NewBetweenOperatorNode<HiveExpression>
6-
implements HiveExpression {
7-
8-
public HiveBetweenOperation(HiveExpression left, HiveExpression middle, HiveExpression right,
9-
boolean isTrue) {
5+
public class HiveBetweenOperation extends NewBetweenOperatorNode<HiveExpression> implements HiveExpression {
6+
7+
public HiveBetweenOperation(HiveExpression left, HiveExpression middle, HiveExpression right, boolean isTrue) {
108
super(left, middle, right, isTrue);
119
}
1210
}

src/sqlancer/hive/ast/HiveBinaryOperation.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import sqlancer.common.ast.BinaryOperatorNode.Operator;
44
import sqlancer.common.ast.newast.NewBinaryOperatorNode;
55

6-
public class HiveBinaryOperation extends NewBinaryOperatorNode<HiveExpression>
7-
implements HiveExpression {
8-
6+
public class HiveBinaryOperation extends NewBinaryOperatorNode<HiveExpression> implements HiveExpression {
7+
98
public HiveBinaryOperation(HiveExpression left, HiveExpression right, Operator op) {
109
super(left, right, op);
1110
}

src/sqlancer/hive/ast/HiveCaseOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sqlancer.common.ast.newast.NewCaseOperatorNode;
66

77
public class HiveCaseOperation extends NewCaseOperatorNode<HiveExpression> implements HiveExpression {
8-
8+
99
public HiveCaseOperation(HiveExpression switchCondition, List<HiveExpression> conditions,
1010
List<HiveExpression> expressions, HiveExpression elseExpr) {
1111
super(switchCondition, conditions, expressions, elseExpr);

src/sqlancer/hive/ast/HiveCastOperation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
import sqlancer.hive.HiveSchema.HiveDataType;
44

55
public class HiveCastOperation implements HiveExpression {
6-
6+
77
private final HiveExpression expression;
88
private final HiveDataType type;
9-
9+
1010
public HiveCastOperation(HiveExpression expression, HiveDataType type) {
1111
if (expression == null) {
1212
throw new AssertionError();
1313
}
1414
this.expression = expression;
1515
this.type = type;
1616
}
17-
17+
1818
public HiveExpression getExpression() {
1919
return expression;
2020
}
21-
21+
2222
public HiveDataType getType() {
2323
return type;
2424
}

src/sqlancer/hive/ast/HiveFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public class HiveFunction<F> extends NewFunctionNode<HiveExpression, F> implemen
99
public HiveFunction(List<HiveExpression> args, F func) {
1010
super(args, func);
1111
}
12-
12+
1313
}

src/sqlancer/hive/ast/HiveInOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sqlancer.common.ast.newast.NewInOperatorNode;
66

77
public class HiveInOperation extends NewInOperatorNode<HiveExpression> implements HiveExpression {
8-
8+
99
public HiveInOperation(HiveExpression left, List<HiveExpression> right, boolean isNegated) {
1010
super(left, right, isNegated);
1111
}

src/sqlancer/hive/ast/HiveJoin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum JoinType {
1717
INNER, LEFT_OUTER, RIGHT_OUTER, FULL_OUTER, LEFT_SEMI, CROSS;
1818
}
1919

20-
public HiveJoin(HiveTableReference leftTable, HiveTableReference rightTable, JoinType joinType,
20+
public HiveJoin(HiveTableReference leftTable, HiveTableReference rightTable, JoinType joinType,
2121
HiveExpression onClause) {
2222
this.leftTable = leftTable;
2323
this.rightTable = rightTable;

0 commit comments

Comments
 (0)