Commit 08f26ed4 authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira

Merge branch 'issue/47' into 'master'

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

See merge request !37
parents 13e28770 b16fd1ee
Pipeline #12242 passed with stage
in 43 seconds
...@@ -376,4 +376,23 @@ describe("postgres adapter", () => { ...@@ -376,4 +376,23 @@ describe("postgres adapter", () => {
done(); 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 { ...@@ -201,7 +201,9 @@ export class PostgresAdapter extends Adapter {
notCoveredClauses.push(clausesToCover[j]); 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) { if (dims.length < partialJoin[i].dimensions.length || coveredClauses.length > 0) {
const partial = new View({ const partial = new View({
metrics: partialJoin[i].metrics, metrics: partialJoin[i].metrics,
......
...@@ -55,6 +55,7 @@ interface AdapterScenario { ...@@ -55,6 +55,7 @@ interface AdapterScenario {
unMaterializebleView: View; unMaterializebleView: View;
partialJoinView: View; partialJoinView: View;
propagatedClauseView: View; propagatedClauseView: View;
propagatedClauseAggrView: View;
} }
interface DataCtrlScenario { interface DataCtrlScenario {
...@@ -364,6 +365,15 @@ const propagatedClauseView = new View({ ...@@ -364,6 +365,15 @@ const propagatedClauseView = new View({
clauses: [clauses.view7dim5, clauses.view6dim4] 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 = { export const engineScenario: EngineScenario = {
metrics: mets, metrics: mets,
dimensions: dims, dimensions: dims,
...@@ -391,7 +401,8 @@ export const adapterScenario: AdapterScenario = { ...@@ -391,7 +401,8 @@ export const adapterScenario: AdapterScenario = {
notOriginCount: notOriginCount, notOriginCount: notOriginCount,
unMaterializebleView: unMaterializebleView, unMaterializebleView: unMaterializebleView,
partialJoinView: partialJoinView, partialJoinView: partialJoinView,
propagatedClauseView: propagatedClauseView propagatedClauseView: propagatedClauseView,
propagatedClauseAggrView: propagatedClauseAggrView
}; };
export const dataCtrlScenario: DataCtrlScenario = { 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