Skip to content

Commit

Permalink
Bugfix: preserve layers can only be already flattened
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 2, 2023
1 parent 3e642ab commit cc9e4cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
final public class PreserveColumnLayer extends DependencyLayerBase {
private final BitSet dependencyBitSet;
private final boolean flattenedResult;
private final boolean alreadyFlattenedSources;

PreserveColumnLayer(SelectAndViewAnalyzer inner, String name, SelectColumn sc, ColumnSource<?> cs, String[] deps,
ModifiedColumnSet mcsBuilder, boolean flattenedResult) {
ModifiedColumnSet mcsBuilder, boolean alreadyFlattenedSources) {
super(inner, name, sc, cs, deps, mcsBuilder);
this.dependencyBitSet = new BitSet();
this.flattenedResult = flattenedResult;
this.alreadyFlattenedSources = alreadyFlattenedSources;
Arrays.stream(deps).mapToInt(inner::getLayerIndexFor).forEach(dependencyBitSet::set);
}

Expand Down Expand Up @@ -77,15 +77,10 @@ public LogOutput append(LogOutput logOutput) {
.append("}");
}

@Override
public boolean flattenedResult() {
return flattenedResult;
}

@Override
public boolean alreadyFlattenedSources() {
// we can only preserve a flat source if it was already made flat
return flattenedResult;
// we can only preserve a flat source if it was already flat
return alreadyFlattenedSources;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static SelectAndViewAnalyzerWrapper create(
}

analyzer = analyzer.createLayerForPreserve(
sc.getName(), sc, sc.getDataView(), distinctDeps, mcsBuilder, flatResult && flattenedResult);
sc.getName(), sc, sc.getDataView(), distinctDeps, mcsBuilder, flattenedResult);

if (!sourceIsNew) {
// we can not flatten future columns because we are preserving a column that may not be flat
Expand All @@ -196,7 +196,7 @@ public static SelectAndViewAnalyzerWrapper create(
final ColumnSource<?> alias = resultAlias.get(realColumn.getSourceName());
if (alias != null) {
analyzer = analyzer.createLayerForPreserve(
sc.getName(), sc, alias, distinctDeps, mcsBuilder, flatResult);
sc.getName(), sc, alias, distinctDeps, mcsBuilder, flattenedResult);
continue;
}
}
Expand Down Expand Up @@ -387,8 +387,9 @@ private SelectAndViewAnalyzer createLayerForView(String name, SelectColumn sc, C
}

private SelectAndViewAnalyzer createLayerForPreserve(String name, SelectColumn sc, ColumnSource<?> cs,
String[] parentColumnDependencies, ModifiedColumnSet mcsBuilder, boolean flatResult) {
return new PreserveColumnLayer(this, name, sc, cs, parentColumnDependencies, mcsBuilder, flatResult);
String[] parentColumnDependencies, ModifiedColumnSet mcsBuilder, boolean alreadyFlattenedSources) {
return new PreserveColumnLayer(this, name, sc, cs, parentColumnDependencies, mcsBuilder,
alreadyFlattenedSources);
}

abstract void populateModifiedColumnSetRecurse(ModifiedColumnSet mcsBuilder, Set<String> remainingDepsToSatisfy);
Expand Down

0 comments on commit cc9e4cf

Please sign in to comment.