Skip to content

Commit

Permalink
feat(binder): support some alternate names for existing exprs (rising…
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu authored Apr 4, 2023
1 parent 29c4185 commit 731f211
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/frontend/src/binder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ impl Binder {
// "power" is the function name used in PG.
("power", raw_call(ExprType::Pow)),
("ceil", raw_call(ExprType::Ceil)),
("ceiling", raw_call(ExprType::Ceil)),
("floor", raw_call(ExprType::Floor)),
("abs", raw_call(ExprType::Abs)),
("exp", raw_call(ExprType::Exp)),
Expand Down Expand Up @@ -382,6 +383,7 @@ impl Binder {
rewrite(ExprType::ConcatWs, Binder::rewrite_concat_to_concat_ws),
),
("concat_ws", raw_call(ExprType::ConcatWs)),
("translate", raw_call(ExprType::Translate)),
("split_part", raw_call(ExprType::SplitPart)),
("char_length", raw_call(ExprType::CharLength)),
("character_length", raw_call(ExprType::CharLength)),
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/binder/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ impl Binder {
let func_type = match op {
UnaryOperator::Not => ExprType::Not,
UnaryOperator::Minus => ExprType::Neg,
UnaryOperator::PGAbs => ExprType::Abs,
UnaryOperator::PGBitwiseNot => ExprType::BitwiseNot,
UnaryOperator::Plus => {
return self.rewrite_positive(expr);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/regress/data/sql/float4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
SELECT * FROM FLOAT4_TBL;

-- test the unary float4abs operator
--@ SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;

UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
Expand Down
6 changes: 3 additions & 3 deletions src/tests/regress/data/sql/float8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ SELECT f.f1, f.f1 - '-10' AS x
--@ FROM FLOAT8_TBL f where f.f1 = '1004.3';

-- absolute value
--@ SELECT f.f1, @f.f1 AS abs_f1
--@ FROM FLOAT8_TBL f;
SELECT f.f1, @f.f1 AS abs_f1
FROM FLOAT8_TBL f;

-- truncate
--@ SELECT f.f1, trunc(f.f1) AS trunc_f1
Expand All @@ -94,7 +94,7 @@ SELECT f.f1, round(f.f1) AS round_f1

-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
--@ select ceiling(f1) as ceiling_f1 from float8_tbl f;
select ceiling(f1) as ceiling_f1 from float8_tbl f;

-- floor
select floor(f1) as floor_f1 from float8_tbl f;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/regress/data/sql/strings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,8 @@ SELECT rpad('hi', 5, '');

SELECT ltrim('zzzytrim', 'xyz');

--@ SELECT translate('', '14', 'ax');
--@ SELECT translate('12345', '14', 'ax');
SELECT translate('', '14', 'ax');
SELECT translate('12345', '14', 'ax');

SELECT ascii('x');
SELECT ascii('');
Expand Down

0 comments on commit 731f211

Please sign in to comment.