Skip to content

Commit 75bf3fb

Browse files
committed
Core: Respect ClickHouse ORDER BY Clause default behavior
1 parent b651fb2 commit 75bf3fb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clickhouse-core/src/main/scala/xenon/clickhouse/expr/Expressions.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ case class FuncExpr(name: String, args: List[Expr]) extends Expr {
3737
override def sql: String = s"$name(${args.map(_.sql).mkString(",")})"
3838
}
3939

40-
case class OrderExpr(expr: Expr, asc: Boolean = true, nullFirst: Boolean = true) extends Expr {
40+
// If the direction is not specified, ASC is assumed ...
41+
// By default or with the NULLS LAST modifier: first the values, then NaN, then NULL ...
42+
// https://clickhouse.com/docs/en/sql-reference/statements/select/order-by
43+
case class OrderExpr(expr: Expr, asc: Boolean = true, nullFirst: Boolean = false) extends Expr {
4144
override def sql: String = s"$expr ${if (asc) "ASC" else "DESC"} NULLS ${if (nullFirst) "FIRST" else "LAST"}"
4245
}
4346

0 commit comments

Comments
 (0)