Skip to content

Commit

Permalink
[CALCITE-4215] Avoid NPE when getReferentialConstraints() returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Oct 1, 2020
1 parent 58adcae commit 1f57bd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,16 @@ private Map<String, Table> createTableMap() {
FieldTable table =
(FieldTable) tableMap.get(Util.last(rc.getSourceQualifiedName()));
assert table != null;
List<RelReferentialConstraint> referentialConstraints =
table.getStatistic().getReferentialConstraints();
if (referentialConstraints == null) {
// This enables to keep the same Statistics.of below
referentialConstraints = ImmutableList.of();
}
table.statistic = Statistics.of(
ImmutableList.copyOf(
Iterables.concat(
table.getStatistic().getReferentialConstraints(),
referentialConstraints,
Collections.singleton(rc))));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ protected boolean compensatePartial(
// Add edges between tables
List<RelReferentialConstraint> constraints =
tRef.getTable().getReferentialConstraints();
if (constraints == null) {
constraints = ImmutableList.of();
}
for (RelReferentialConstraint constraint : constraints) {
Collection<RelTableRef> parentTableRefs =
tableVNameToTableRefs.get(constraint.getTargetQualifiedName());
Expand Down

0 comments on commit 1f57bd4

Please sign in to comment.