Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6690 fixed empty values type handling in TableDisplay (jvm) #6693

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ public TableDisplay(Collection<Map<String, Object>> v, BeakerObjectConverter ser

if (currentType == null || !currentType.equals("string")) {
Object rowItem = row.get(columnToCheck);
String colType = rowItem.getClass().getName();
String beakerColType = serializer.convertType(colType);
typeTracker.put(columnToCheck, beakerColType);

if (beakerColType.equals("string")) {
columnsToRemove.add(columnToCheck);
if (rowItem != null) {
String colType = rowItem.getClass().getName();
String beakerColType = serializer.convertType(colType);
typeTracker.put(columnToCheck, beakerColType);

if (beakerColType.equals("string")) {
columnsToRemove.add(columnToCheck);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.twosigma.beakerx.table.serializer.TimeStringFormatSerializer;
import com.twosigma.beakerx.table.serializer.UniqueEntriesHighlighterSerializer;
import com.twosigma.beakerx.table.serializer.ValueHighlighterSerializer;
import com.twosigma.beakerx.widgets.selectioncontainer.Tab;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -590,6 +591,15 @@ public void createWithMultipleTypesPerColumnParam_hasSafeTypesInOrder() throws E
assertThat(tableDisplay.getTypes()).isEqualTo(expectedValues);
}

@Test
public void createWithUndefinedTypes() throws Exception {
TableDisplay tableDisplay = new TableDisplay(getListOfMapsWithEmptyTypes());
assertThat(tableDisplay.getSubtype()).isEqualTo(TableDisplay.LIST_OF_MAPS_SUBTYPE);
System.out.println(tableDisplay.getTypes());
List<String> expectedValues = Arrays.asList("string", "double", "integer");
assertThat(tableDisplay.getTypes()).isEqualTo(expectedValues);
}

@Test
public void createWithListOfMapsParam_hasListOfMapsSubtype() throws Exception {
//when
Expand Down Expand Up @@ -796,6 +806,36 @@ public static List<Map<String, Object>> getListOfMapsWithMostlyInconsistentTypes
return list;
}

public static List<Map<String, Object>> getListOfMapsWithEmptyTypes() {
List<Map<String, Object>> list = new ArrayList<>();
List<String> cols = getStringList();
list.add(
new LinkedHashMap<String, Object>() {
{
put(cols.get(0), "string 1");
put(cols.get(1), null);
put(cols.get(2), 1);
}
});
list.add(
new LinkedHashMap<String, Object>() {
{
put(cols.get(0), null);
put(cols.get(1), 2.2);
put(cols.get(2), 2);
}
});
list.add(
new LinkedHashMap<String, Object>() {
{
put(cols.get(0), "string 3");
put(cols.get(1), 2.3);
put(cols.get(2), null);
}
});
return list;
}

private Map<?, ?> getMapData() {
return new HashMap<String, Object>() {
{
Expand Down