Skip to content

Commit

Permalink
feat(api): add nulls_first=False argument to order_by (#9385)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Cloud <[email protected]>
  • Loading branch information
ncclementi and cpcloud authored Jun 26, 2024
1 parent 1c6eb5c commit ce9011e
Show file tree
Hide file tree
Showing 55 changed files with 290 additions and 78 deletions.
17 changes: 16 additions & 1 deletion ibis/backends/dask/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,25 @@ def visit(cls, op: ops.Sort, parent, keys):
# 2. sort the dataframe using those columns
# 3. drop the sort key columns
ascending = [key.ascending for key in op.keys]
nulls_first = [key.nulls_first for key in op.keys]

if all(nulls_first):
na_position = "first"
elif not any(nulls_first):
na_position = "last"
else:
raise ValueError(
"dask does not support specifying null ordering for individual columns"
)

newcols = {gen_name("sort_key"): col for col in keys}
names = list(newcols.keys())
df = parent.assign(**newcols)
df = df.sort_values(by=names, ascending=ascending)
df = df.sort_values(
by=names,
ascending=ascending,
na_position=na_position,
)
return df.drop(names, axis=1)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
FIRST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC NULLS LAST) AS `First(double_col)`
FIRST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC) AS `First(double_col)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LAG(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col, 2)`
LAG(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC) AS `Lag(string_col, 2)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LAG(`t0`.`string_col`) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col)`
LAG(`t0`.`string_col`) OVER (ORDER BY NULL ASC) AS `Lag(string_col)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LAG(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lag(string_col, 0)`
LAG(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC) AS `Lag(string_col, 0)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LAST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC NULLS LAST) AS `Last(double_col)`
LAST_VALUE(`t0`.`double_col`) OVER (ORDER BY `t0`.`id` ASC) AS `Last(double_col)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LEAD(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col, 2)`
LEAD(`t0`.`string_col`, 2) OVER (ORDER BY NULL ASC) AS `Lead(string_col, 2)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LEAD(`t0`.`string_col`) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col)`
LEAD(`t0`.`string_col`) OVER (ORDER BY NULL ASC) AS `Lead(string_col)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LEAD(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC NULLS LAST) AS `Lead(string_col, 0)`
LEAD(`t0`.`string_col`, 1, 0) OVER (ORDER BY NULL ASC) AS `Lead(string_col, 0)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
NTILE(3) OVER (ORDER BY `t0`.`double_col` ASC NULLS LAST) - 1 AS `NTile(3)`
NTILE(3) OVER (ORDER BY `t0`.`double_col` ASC) - 1 AS `NTile(3)`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
PERCENT_RANK() OVER (ORDER BY `t0`.`double_col` ASC NULLS LAST) AS `PercentRank()`
PERCENT_RANK() OVER (ORDER BY `t0`.`double_col` ASC) AS `PercentRank()`
FROM `functional_alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT * FROM (SELECT `t1`.`col`, COUNT(*) OVER (ORDER BY NULL ASC NULLS LAST) AS `analytic` FROM (SELECT `t0`.`col`, NULL AS `filter` FROM `x` AS `t0` WHERE NULL IS NULL) AS `t1`) AS `t2`
SELECT * FROM (SELECT `t1`.`col`, COUNT(*) OVER (ORDER BY NULL ASC) AS `analytic` FROM (SELECT `t0`.`col`, NULL AS `filter` FROM `x` AS `t0` WHERE NULL IS NULL) AS `t1`) AS `t2`
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT `t0`.`one`, `t0`.`two`, `t0`.`three`, SUM(`t0`.`two`) OVER (PARTITION BY `t0`.`three` ORDER BY `t0`.`one` ASC NULLS LAST) AS `four` FROM `my_data` AS `t0`
SELECT `t0`.`one`, `t0`.`two`, `t0`.`three`, SUM(`t0`.`two`) OVER (PARTITION BY `t0`.`three` ORDER BY `t0`.`one` ASC) AS `four` FROM `my_data` AS `t0`
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ SELECT
`t0`.`i`,
`t0`.`j`,
`t0`.`k`,
LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `lag`,
LEAD(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) - `t0`.`f` AS `fwd_diff`,
FIRST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `first`,
LAST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `last`,
LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`d` ASC NULLS LAST) AS `lag2`
LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) AS `lag`,
LEAD(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) - `t0`.`f` AS `fwd_diff`,
FIRST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) AS `first`,
LAST_VALUE(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) AS `last`,
LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`d` ASC) AS `lag2`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ SELECT
`t0`.`i`,
`t0`.`j`,
`t0`.`k`,
`t0`.`f` / SUM(`t0`.`f`) OVER (ORDER BY NULL ASC NULLS LAST) AS `normed_f`
`t0`.`f` / SUM(`t0`.`f`) OVER (ORDER BY NULL ASC) AS `normed_f`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
MAX(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
AVG(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
MIN(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC NULLS LAST) AS `foo`
SUM(`t0`.`f`) OVER (ORDER BY `t0`.`d` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
`t0`.`g`,
SUM(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) - SUM(`t0`.`f`) OVER (ORDER BY NULL ASC NULLS LAST) AS `result`
SUM(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) - SUM(`t0`.`f`) OVER (ORDER BY NULL ASC) AS `result`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
LAG(`t0`.`f` - LAG(`t0`.`f`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST)) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo`
LAG(`t0`.`f` - LAG(`t0`.`f`) OVER (ORDER BY `t0`.`f` ASC)) OVER (ORDER BY `t0`.`f` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
`t0`.`f`,
ROW_NUMBER() OVER (ORDER BY `t0`.`f` DESC) - 1 AS `revrank`
ROW_NUMBER() OVER (ORDER BY `t0`.`f` DESC NULLS LAST) - 1 AS `revrank`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT
LAG(`t0`.`d`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC) AS `foo`,
MAX(`t0`.`a`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC) AS `Max(a)`
LAG(`t0`.`d`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC NULLS LAST) AS `foo`,
MAX(`t0`.`a`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` DESC NULLS LAST) AS `Max(a)`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
SELECT
LAG(
`t0`.`f` - LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST)
) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo`
LAG(`t0`.`f` - LAG(`t0`.`f`) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC)) OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
`t0`.`g`,
RANK() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `minr`,
DENSE_RANK() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `denser`
RANK() OVER (ORDER BY `t0`.`f` ASC) - 1 AS `minr`,
DENSE_RANK() OVER (ORDER BY `t0`.`f` ASC) - 1 AS `denser`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ SELECT
`t0`.`i`,
`t0`.`j`,
`t0`.`k`,
ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC NULLS LAST) AS `foo`
ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY NULL ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ SELECT
`t0`.`i`,
`t0`.`j`,
`t0`.`k`,
ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC NULLS LAST) - 1 AS `foo`
ROW_NUMBER() OVER (PARTITION BY `t0`.`g` ORDER BY `t0`.`f` ASC) - 1 AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ SELECT
`t0`.`j`,
`t0`.`k`,
(
ROW_NUMBER() OVER (ORDER BY `t0`.`f` ASC NULLS LAST) - 1
ROW_NUMBER() OVER (ORDER BY `t0`.`f` ASC) - 1
) / 2 AS `new`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 10 preceding AND 5 preceding) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 10 preceding AND 5 preceding) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND 2 following) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND 2 following) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN CURRENT ROW AND 2 following) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN CURRENT ROW AND 2 following) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 following AND 10 following) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 5 following AND 10 following) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND UNBOUNDED FOLLOWING) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 5 preceding AND UNBOUNDED FOLLOWING) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND CURRENT ROW) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 5 preceding AND CURRENT ROW) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 5 preceding AND 2 following) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 5 preceding AND 2 following) AS `foo`
FROM `alltypes` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC NULLS LAST ROWS BETWEEN 10 preceding AND CURRENT ROW) AS `foo`
SUM(`t0`.`d`) OVER (ORDER BY `t0`.`f` ASC ROWS BETWEEN 10 preceding AND CURRENT ROW) AS `foo`
FROM `alltypes` AS `t0`
19 changes: 17 additions & 2 deletions ibis/backends/pandas/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def visit(cls, op: ops.Alias, arg, name):
return arg

@classmethod
def visit(cls, op: ops.SortKey, expr, ascending):
def visit(cls, op: ops.SortKey, expr, ascending, nulls_first):
return expr

@classmethod
Expand Down Expand Up @@ -593,11 +593,26 @@ def visit(cls, op: ops.Sort, parent, keys):
# 2. sort the dataframe using those columns
# 3. drop the sort key columns
ascending = [key.ascending for key in op.keys]
nulls_first = [key.nulls_first for key in op.keys]

if all(nulls_first):
na_position = "first"
elif not any(nulls_first):
na_position = "last"
else:
raise ValueError(
"pandas does not support specifying null ordering for individual columns"
)

newcols = {gen_name("sort_key"): col for col in keys}
names = list(newcols.keys())
df = parent.assign(**newcols)
df = df.sort_values(
by=names, ascending=ascending, ignore_index=True, kind="mergesort"
by=names,
ascending=ascending,
na_position=na_position,
ignore_index=True,
kind="mergesort",
)
return df.drop(columns=names)

Expand Down
7 changes: 3 additions & 4 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ def sort(op, **kw):

by = list(newcols.keys())
descending = [key.descending for key in op.keys]
try:
lf = lf.sort(by, descending=descending, nulls_last=True)
except TypeError: # pragma: no cover
lf = lf.sort(by, reverse=descending, nulls_last=True) # pragma: no cover
nulls_last = [not key.nulls_first for key in op.keys]

lf = lf.sort(by, descending=descending, nulls_last=nulls_last)

return lf.drop(*by)

Expand Down
4 changes: 2 additions & 2 deletions ibis/backends/sql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,8 @@ def visit_Coalesce(self, op, *, arg):

### Ordering and window functions

def visit_SortKey(self, op, *, expr, ascending: bool):
return sge.Ordered(this=expr, desc=not ascending)
def visit_SortKey(self, op, *, expr, ascending: bool, nulls_first: bool):
return sge.Ordered(this=expr, desc=not ascending, nulls_first=nulls_first)

def visit_ApproxMedian(self, op, *, arg, where):
return self.agg.approx_quantile(arg, 0.5, where=where)
Expand Down
4 changes: 4 additions & 0 deletions ibis/backends/sql/dialects.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ class Tokenizer(Hive.Tokenizer):


class Impala(Hive):
NULL_ORDERING = "nulls_are_large"

class Generator(Hive.Generator):
TRANSFORMS = Hive.Generator.TRANSFORMS.copy() | {
sge.ApproxDistinct: rename_func("ndv"),
Expand Down Expand Up @@ -336,6 +338,8 @@ def _create_sql(self, expression: sge.Create) -> str:
return self.create_sql(expression)


# hack around https://github.com/tobymao/sqlglot/issues/3684
Oracle.NULL_ORDERING = "nulls_are_large"
Oracle.Generator.TRANSFORMS |= {
sge.LogicalOr: rename_func("max"),
sge.LogicalAnd: rename_func("min"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
WITH `t1` AS (
SELECT
`t0`.`street`,
ROW_NUMBER() OVER (ORDER BY `t0`.`street` ASC NULLS LAST) - 1 AS `key`
ROW_NUMBER() OVER (ORDER BY `t0`.`street` ASC) - 1 AS `key`
FROM `data` AS `t0`
), `t7` AS (
SELECT
`t6`.`street`,
ROW_NUMBER() OVER (ORDER BY `t6`.`street` ASC NULLS LAST) - 1 AS `key`
ROW_NUMBER() OVER (ORDER BY `t6`.`street` ASC) - 1 AS `key`
FROM (
SELECT
`t3`.`street`,
Expand Down
Loading

0 comments on commit ce9011e

Please sign in to comment.