diff --git a/engine/api/src/main/java/io/deephaven/engine/table/ColumnDefinition.java b/engine/api/src/main/java/io/deephaven/engine/table/ColumnDefinition.java index 2a6ce0160c2..684f63191e2 100644 --- a/engine/api/src/main/java/io/deephaven/engine/table/ColumnDefinition.java +++ b/engine/api/src/main/java/io/deephaven/engine/table/ColumnDefinition.java @@ -356,7 +356,7 @@ private ColumnDefinition( @NotNull final Class dataType, @Nullable final Class componentType, @NotNull final ColumnType columnType) { - this.name = Objects.requireNonNull(name); + this.name = Objects.requireNonNull(name, "Column names cannot be null"); this.dataType = Objects.requireNonNull(dataType); this.componentType = componentType; this.columnType = Objects.requireNonNull(columnType); diff --git a/engine/table/src/main/java/io/deephaven/engine/table/impl/InMemoryTable.java b/engine/table/src/main/java/io/deephaven/engine/table/impl/InMemoryTable.java index c7f135ee388..c6b05308878 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/impl/InMemoryTable.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/impl/InMemoryTable.java @@ -3,7 +3,7 @@ */ package io.deephaven.engine.table.impl; -import io.deephaven.datastructures.util.CollectionUtil; +import io.deephaven.engine.exceptions.ArgumentException; import io.deephaven.engine.table.TableDefinition; import io.deephaven.engine.table.impl.sources.ArrayBackedColumnSource; import io.deephaven.engine.table.ColumnSource; @@ -13,7 +13,6 @@ import io.deephaven.qst.table.NewTable; import java.lang.reflect.Array; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -64,7 +63,13 @@ private InMemoryTable(TableDefinition definition, TrackingRowSet rowSet, private static Map> createColumnsMap(String[] columnNames, Object[] arrayValues) { Map> map = new LinkedHashMap<>(); for (int i = 0; i < columnNames.length; i++) { - map.put(columnNames[i], ArrayBackedColumnSource.getMemoryColumnSourceUntyped((arrayValues[i]))); + final String columnName = columnNames[i]; + final Object array = arrayValues[i]; + if (array == null) { + throw new ArgumentException("Value array for column " + columnName + " is null"); + } + + map.put(columnName, ArrayBackedColumnSource.getMemoryColumnSourceUntyped(array)); } return map; } diff --git a/engine/table/src/main/java/io/deephaven/engine/util/TableTools.java b/engine/table/src/main/java/io/deephaven/engine/util/TableTools.java index 80473c8d827..bb419ecbb53 100644 --- a/engine/table/src/main/java/io/deephaven/engine/util/TableTools.java +++ b/engine/table/src/main/java/io/deephaven/engine/util/TableTools.java @@ -9,6 +9,7 @@ import io.deephaven.base.verify.Require; import io.deephaven.datastructures.util.CollectionUtil; import io.deephaven.engine.context.ExecutionContext; +import io.deephaven.engine.exceptions.ArgumentException; import io.deephaven.engine.rowset.WritableRowSet; import io.deephaven.engine.rowset.RowSequence; import io.deephaven.engine.rowset.RowSetFactory; @@ -694,8 +695,7 @@ private static , KT, VT> MT newMapFromLists(Class map */ public static Table newTable(long size, List names, List> columnSources) { // noinspection unchecked - return new QueryTable(RowSetFactory.flat(size).toTracking(), - newMapFromLists(LinkedHashMap.class, names, columnSources)); + return newTable(size, newMapFromLists(LinkedHashMap.class, names, columnSources)); } /** @@ -706,6 +706,13 @@ public static Table newTable(long size, List names, List * @return a Deephaven Table */ public static Table newTable(long size, Map> columns) { + for (final Map.Entry> entry : columns.entrySet()) { + final String columnName = entry.getKey(); + if (entry.getValue() == null) { + throw new ArgumentException("Column source for " + columnName + " is null"); + } + } + return new QueryTable(RowSetFactory.flat(size).toTracking(), columns); }