Issue #47: Fix clause propagation, when materialized view has a clause

Signed-off-by: Lucas Fernandes de Oliveira's avatarLucas Fernandes de Oliveira <lfo14@inf.ufpr.br>
parent 13e28770
Pipeline #12229 passed with stage
in 44 seconds
......@@ -376,4 +376,23 @@ describe("postgres adapter", () => {
done();
});
});
it("should get data from view when joins propaged is in the aggregation", (done) => {
let view = adapterScenario.propagatedClauseAggrView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(8);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
keys = keys.concat(view.dimensions.map((item) => item.name));
result.forEach((row) => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
});
done();
});
});
});
......@@ -201,7 +201,9 @@ export class PostgresAdapter extends Adapter {
notCoveredClauses.push(clausesToCover[j]);
}
}
clausesToCover = notCoveredClauses;
clausesToCover = notCoveredClauses.filter((clause) => {
return !partialJoin[i].clauses.some((c) => c.id === clause.id);
});
if (dims.length < partialJoin[i].dimensions.length || coveredClauses.length > 0) {
const partial = new View({
metrics: partialJoin[i].metrics,
......
......@@ -55,6 +55,7 @@ interface AdapterScenario {
unMaterializebleView: View;
partialJoinView: View;
propagatedClauseView: View;
propagatedClauseAggrView: View;
}
interface DataCtrlScenario {
......@@ -364,6 +365,15 @@ const propagatedClauseView = new View({
clauses: [clauses.view7dim5, clauses.view6dim4]
});
const propagatedClauseAggrView = new View({
metrics: [mets[8], mets[5]],
dimensions: [dims[2]],
materialized: false,
origin: false,
childViews: [views[9], views[6], views[7]],
clauses: [clauses.view7dim5, clauses.view6dim4, clauses.view9dim2]
});
export const engineScenario: EngineScenario = {
metrics: mets,
dimensions: dims,
......@@ -391,7 +401,8 @@ export const adapterScenario: AdapterScenario = {
notOriginCount: notOriginCount,
unMaterializebleView: unMaterializebleView,
partialJoinView: partialJoinView,
propagatedClauseView: propagatedClauseView
propagatedClauseView: propagatedClauseView,
propagatedClauseAggrView: propagatedClauseAggrView
};
export const dataCtrlScenario: DataCtrlScenario = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment