From ef5d58deab950d3bc205cb0e4c6bc1ba3e6299f7 Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:17:39 -0400 Subject: [PATCH] refactor(mssql): simplify lpad and rpad ops (#10085) ## Description of changes Simplifying the previous implementation from `sge.Case(ifs...)` per https://github.com/ibis-project/ibis/pull/10060#discussion_r1752665235. --- ibis/backends/sql/compilers/mssql.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ibis/backends/sql/compilers/mssql.py b/ibis/backends/sql/compilers/mssql.py index 31cba1126d38..cadc8b30cc1b 100644 --- a/ibis/backends/sql/compilers/mssql.py +++ b/ibis/backends/sql/compilers/mssql.py @@ -525,18 +525,20 @@ def visit_EndsWith(self, op, *, arg, end): return arg.like(self.f.concat("%", end)) def visit_LPad(self, op, *, arg, length, pad): - return sge.Case( - ifs=[self.if_(length <= self.f.length(arg), arg)], - default=self.f.left( + return self.if_( + length <= self.f.length(arg), + arg, + self.f.left( self.f.concat(self.f.replicate(pad, length - self.f.length(arg)), arg), length, ), ) def visit_RPad(self, op, *, arg, length, pad): - return sge.Case( - ifs=[self.if_(length <= self.f.length(arg), arg)], - default=self.f.left( + return self.if_( + length <= self.f.length(arg), + arg, + self.f.left( self.f.concat(arg, self.f.replicate(pad, length - self.f.length(arg))), length, ),