Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push orderby criteria to data cube index queries. #185

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<option value="flights-10m">Flights 10M</option>
<option value="gaia">Gaia Star Catalog</option>
<option value="hexbin">Hexbin</option>
<option value="highlight-cube">Highlight Cube</option>
<option value="highlight-toggle">Highlight Toggle</option>
<option value="images">Images</option>
<option value="links">Links</option>
Expand Down
46 changes: 46 additions & 0 deletions dev/yaml/highlight-cube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
data:
athletes: { file: data/athletes.csv }
params:
query: { select: crossfilter }
selectNationality: { select: single }
selectSport: { select: single }
vconcat:
- plot:
- mark: barX
data: { from: athletes, filterBy: $query }
x: { count: }
y: nationality
order: nationality
sort: {
y: '-x',
limit: 10
}
- select: highlight
by: $selectNationality
- select: toggleY
as: $selectNationality
- select: toggleY
as: $query
width: 600
height: 400
marginLeft: 80
- vspace: 10
- plot:
- mark: barX
data: { from: athletes, filterBy: $query }
x: { count: }
y: sport
order: sport
sort: {
y: '-x',
limit: 10
}
- select: highlight
by: $selectSport
- select: toggleY
as: $selectSport
- select: toggleY
as: $query
width: 600
height: 400
marginLeft: 80
11 changes: 8 additions & 3 deletions packages/core/src/DataCubeIndexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ export class DataCubeIndexer {
subqueryPushdown(subq, cols);
}

// push orderby criteria to later cube queries
const order = query.orderby();
query.query.orderby = [];

const sql = query.toString();
const id = (fnv_hash(sql) >>> 0).toString(16);
const table = `cube_index_${id}`;
const result = mc.exec(create(table, sql, { temp }));
indices.set(client, { table, result, ...index });
indices.set(client, { table, result, order, ...index });
}
}

Expand All @@ -111,12 +115,13 @@ export class DataCubeIndexer {
filter = this.activeView.predicate(this.selection.active.predicate);
}

const { table, dims, aggr } = index;
const { table, dims, aggr, order = [] } = index;
const query = Query
.select(dims, aggr)
.from(table)
.groupby(dims)
.where(filter);
.where(filter)
.orderby(order);
return this.mc.updateClient(client, query);
}
}
Expand Down