Skip to content

Commit

Permalink
Remove unused parameter from TestingPrestoClient::convertToRowValue
Browse files Browse the repository at this point in the history
  • Loading branch information
nezihyigitbasi committed Jan 2, 2019
1 parent b712beb commit 5d231d1
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.facebook.presto.spi.type.MapType;
import com.facebook.presto.spi.type.SqlTimestamp;
import com.facebook.presto.spi.type.SqlTimestampWithTimeZone;
import com.facebook.presto.spi.type.TimeZoneKey;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.spi.type.VarcharType;
import com.facebook.presto.testing.MaterializedResult;
Expand Down Expand Up @@ -94,7 +93,7 @@ public TestingPrestoClient(TestingPrestoServer prestoServer, Session defaultSess
@Override
protected ResultsSession<MaterializedResult> getResultSession(Session session)
{
return new MaterializedResultSession(session);
return new MaterializedResultSession();
}

private class MaterializedResultSession
Expand All @@ -108,13 +107,6 @@ private class MaterializedResultSession
private final AtomicReference<Optional<String>> updateType = new AtomicReference<>(Optional.empty());
private final AtomicReference<OptionalLong> updateCount = new AtomicReference<>(OptionalLong.empty());

private final TimeZoneKey timeZoneKey;

private MaterializedResultSession(Session session)
{
this.timeZoneKey = session.getTimeZoneKey();
}

@Override
public void setUpdateType(String type)
{
Expand All @@ -140,7 +132,7 @@ public void addResults(QueryStatusInfo statusInfo, QueryData data)

if (data.getData() != null) {
checkState(types.get() != null, "data received without types");
rows.addAll(transform(data.getData(), dataToRow(timeZoneKey, types.get())));
rows.addAll(transform(data.getData(), dataToRow(types.get())));
}
}

Expand All @@ -158,21 +150,21 @@ public MaterializedResult build(Map<String, String> setSessionProperties, Set<St
}
}

private static Function<List<Object>, MaterializedRow> dataToRow(final TimeZoneKey timeZoneKey, final List<Type> types)
private static Function<List<Object>, MaterializedRow> dataToRow(final List<Type> types)
{
return data -> {
checkArgument(data.size() == types.size(), "columns size does not match types size");
List<Object> row = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
Object value = data.get(i);
Type type = types.get(i);
row.add(convertToRowValue(type, value, timeZoneKey));
row.add(convertToRowValue(type, value));
}
return new MaterializedRow(DEFAULT_PRECISION, row);
};
}

private static Object convertToRowValue(Type type, Object value, TimeZoneKey timeZoneKey)
private static Object convertToRowValue(Type type, Object value)
{
if (value == null) {
return null;
Expand Down Expand Up @@ -237,14 +229,14 @@ else if (INTERVAL_YEAR_MONTH.equals(type)) {
}
else if (type instanceof ArrayType) {
return ((List<Object>) value).stream()
.map(element -> convertToRowValue(((ArrayType) type).getElementType(), element, timeZoneKey))
.map(element -> convertToRowValue(((ArrayType) type).getElementType(), element))
.collect(toList());
}
else if (type instanceof MapType) {
return ((Map<Object, Object>) value).entrySet().stream()
.collect(Collectors.toMap(
e -> convertToRowValue(((MapType) type).getKeyType(), e.getKey(), timeZoneKey),
e -> convertToRowValue(((MapType) type).getValueType(), e.getValue(), timeZoneKey)));
e -> convertToRowValue(((MapType) type).getKeyType(), e.getKey()),
e -> convertToRowValue(((MapType) type).getValueType(), e.getValue())));
}
else if (type instanceof DecimalType) {
return new BigDecimal((String) value);
Expand Down

0 comments on commit 5d231d1

Please sign in to comment.