Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
2010YOUY01 committed Aug 7, 2024
1 parent 0e5be03 commit e42ce0f
Show file tree
Hide file tree
Showing 4 changed files with 653 additions and 636 deletions.
64 changes: 32 additions & 32 deletions src/sqlancer/datafusion/DataFusionSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ public boolean isNumeric() {
// select table_name, column_name, data_type from information_schema.columns;
public static DataFusionDataType parseFromDataFusionCatalog(String typeString) {
switch (typeString) {
case "Int64":
return DataFusionDataType.BIGINT;
case "Float64":
return DataFusionDataType.DOUBLE;
case "Boolean":
return DataFusionDataType.BOOLEAN;
case "Utf8":
return DataFusionDataType.STRING;
default:
dfAssert(false, "Unreachable. All branches should be eovered");
case "Int64":
return DataFusionDataType.BIGINT;
case "Float64":
return DataFusionDataType.DOUBLE;
case "Boolean":
return DataFusionDataType.BOOLEAN;
case "Utf8":
return DataFusionDataType.STRING;
default:
dfAssert(false, "Unreachable. All branches should be eovered");
}

dfAssert(false, "Unreachable. All branches should be eovered");
Expand All @@ -134,31 +134,31 @@ public Node<DataFusionExpression> getRandomConstant(DataFusionGlobalState state)
return DataFusionConstant.createNullConstant();
}
switch (this) {
case BIGINT:
long randInt = Randomly.getBoolean() ? state.getRandomly().getInteger()
: state.getRandomly().getInteger(-5, 5);
return DataFusionConstant.createIntConstant(randInt);
case BOOLEAN:
return new DataFusionConstant.DataFusionBooleanConstant(Randomly.getBoolean());
case DOUBLE:
case BIGINT:
long randInt = Randomly.getBoolean() ? state.getRandomly().getInteger()
: state.getRandomly().getInteger(-5, 5);
return DataFusionConstant.createIntConstant(randInt);
case BOOLEAN:
return new DataFusionConstant.DataFusionBooleanConstant(Randomly.getBoolean());
case DOUBLE:
if (Randomly.getBoolean()) {
if (Randomly.getBoolean()) {
if (Randomly.getBoolean()) {
Double randomDouble = state.getRandomly().getDouble(); // [0.0, 1.0);
Double scaledDouble = (randomDouble - 0.5) * 2 * Double.MAX_VALUE;
return new DataFusionConstant.DataFusionDoubleConstant(scaledDouble);
}
String doubleStr = Randomly.fromOptions("'NaN'::Double", "'+Inf'::Double", "'-Inf'::Double", "-0.0",
"+0.0");
return new DataFusionConstant.DataFusionDoubleConstant(doubleStr);
Double randomDouble = state.getRandomly().getDouble(); // [0.0, 1.0);
Double scaledDouble = (randomDouble - 0.5) * 2 * Double.MAX_VALUE;
return new DataFusionConstant.DataFusionDoubleConstant(scaledDouble);
}
String doubleStr = Randomly.fromOptions("'NaN'::Double", "'+Inf'::Double", "'-Inf'::Double", "-0.0",
"+0.0");
return new DataFusionConstant.DataFusionDoubleConstant(doubleStr);
}

return new DataFusionConstant.DataFusionDoubleConstant(state.getRandomly().getDouble());
case NULL:
return DataFusionConstant.createNullConstant();
case STRING:
return new DataFusionConstant.DataFusionStringConstant(state.getRandomly().getString());
default:
dfAssert(false, "Unreachable. All branches should be eovered");
return new DataFusionConstant.DataFusionDoubleConstant(state.getRandomly().getDouble());
case NULL:
return DataFusionConstant.createNullConstant();
case STRING:
return new DataFusionConstant.DataFusionStringConstant(state.getRandomly().getString());
default:
dfAssert(false, "Unreachable. All branches should be eovered");
}

dfAssert(false, "Unreachable. All branches should be eovered");
Expand Down
40 changes: 20 additions & 20 deletions src/sqlancer/datafusion/DataFusionToStringVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ private void visit(DataFusionFrom from) {
visit(from.tableList.get(0));
for (int i = 0; i < from.joinConditionList.size(); i++) {
switch (from.joinTypeList.get(i)) {
case INNER:
sb.append(Randomly.fromOptions(" JOIN ", " INNER JOIN "));
break;
case LEFT:
sb.append(Randomly.fromOptions(" LEFT JOIN ", " LEFT OUTER JOIN "));
break;
case RIGHT:
sb.append(Randomly.fromOptions(" RIGHT JOIN ", " RIGHT OUTER JOIN "));
break;
case FULL:
sb.append(Randomly.fromOptions(" FULL JOIN ", " FULL OUTER JOIN "));
break;
case CROSS:
sb.append(" CROSS JOIN ");
break;
case NATURAL:
sb.append(" NATURAL JOIN ");
break;
default:
dfAssert(false, "Unreachable");
case INNER:
sb.append(Randomly.fromOptions(" JOIN ", " INNER JOIN "));
break;
case LEFT:
sb.append(Randomly.fromOptions(" LEFT JOIN ", " LEFT OUTER JOIN "));
break;
case RIGHT:
sb.append(Randomly.fromOptions(" RIGHT JOIN ", " RIGHT OUTER JOIN "));
break;
case FULL:
sb.append(Randomly.fromOptions(" FULL JOIN ", " FULL OUTER JOIN "));
break;
case CROSS:
sb.append(" CROSS JOIN ");
break;
case NATURAL:
sb.append(" NATURAL JOIN ");
break;
default:
dfAssert(false, "Unreachable");
}

visit(from.tableList.get(i + 1)); // ti
Expand Down
Loading

0 comments on commit e42ce0f

Please sign in to comment.