Skip to content

Commit 52e16db

Browse files
authored
feat(hierarchy): LimitedRank (#1268)
1 parent eaca855 commit 52e16db

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

db-service/lib/cqn2sql.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class CQN2SQLRenderer {
324324
DistanceFromRoot: { xpr: [{ ref: ['HIERARCHY_LEVEL'] }, '-', { val: 1, param: false }], as: 'DistanceFromRoot' },
325325
DrillState: false,
326326
LimitedDescendantCount: { xpr: [{ ref: ['HIERARCHY_TREE_SIZE'] }, '-', { val: 1, param: false }], as: 'LimitedDescendantCount' },
327+
LimitedRank: { xpr: [{ func: 'row_number', args: [], xpr: ['OVER', { list: [] }] }, '-', { val: 1, param: false }], as: 'LimitedRank' }
327328
}
328329

329330
const columnsFiltered = columns
@@ -1176,7 +1177,7 @@ class CQN2SQLRenderer {
11761177
.map((x, i) => {
11771178
if (x in { LIKE: 1, like: 1 } && is_regexp(xpr[i + 1]?.val)) return this.operator('regexp')
11781179
if (typeof x === 'string') return this.operator(x, i, xpr)
1179-
if (x.xpr) return `(${this.xpr(x)})`
1180+
if (x.xpr && !x.func) return `(${this.xpr(x)})`
11801181
else return this.expr(x)
11811182
})
11821183
.join(' ')

0 commit comments

Comments
 (0)