Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ object FunctionRegistry {
expression[Log1p]("log1p"),
expression[Log2]("log2"),
expression[Log]("ln"),
expression[Remainder]("mod"),
expression[UnaryMinus]("negative"),
expression[Pi]("pi"),
expression[Pmod]("pmod"),
Expand Down Expand Up @@ -300,6 +301,7 @@ object FunctionRegistry {
expression[StringTrimLeft]("ltrim"),
expression[JsonTuple]("json_tuple"),
expression[ParseUrl]("parse_url"),
expression[StringLocate]("position"),
expression[FormatString]("printf"),
expression[RegExpExtract]("regexp_extract"),
expression[RegExpReplace]("regexp_replace"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ case class SubstringIndex(strExpr: Expression, delimExpr: Expression, countExpr:
""",
extended = """
Examples:
> SELECT _FUNC_('bar', 'foobarbar');
4
> SELECT _FUNC_('bar', 'foobarbar', 5);
7
""")
Expand Down
3 changes: 3 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/operators.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ select ceiling(1234567890123456);
select floor(0);
select floor(1);
select floor(1234567890123456);

-- mod
select mod(7, 2), mod(7, 0), mod(0, 2), mod(7, null), mod(null, 2), mod(null, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the function description of Remainder . The example does not show this syntax.

Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ select replace('abc', 'b');

-- uuid
select length(uuid()), (uuid() <> uuid());

-- position
select position('bar', 'foobarbar'), position('bar', 'foobarbar', 5), position(null, 'foobarbar'), position('aaads', null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax of position is POSITION(substr IN str). It is different from LOCATE. You need to change the parser to support it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check what we did for remainder and the others in Parser supports.

10 changes: 9 additions & 1 deletion sql/core/src/test/resources/sql-tests/results/operators.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 45
-- Number of queries: 46


-- !query 0
Expand Down Expand Up @@ -372,3 +372,11 @@ select floor(1234567890123456)
struct<FLOOR(1234567890123456):bigint>
-- !query 44 output
1234567890123456


-- !query 45
select mod(7, 2), mod(7, 0), mod(0, 2), mod(7, null), mod(null, 2), mod(null, null)
-- !query 45 schema
struct<(7 % 2):int,(7 % 0):int,(0 % 2):int,(7 % CAST(NULL AS INT)):int,(CAST(NULL AS INT) % 2):int,(CAST(NULL AS DOUBLE) % CAST(NULL AS DOUBLE)):double>
-- !query 45 output
1 NULL 0 NULL NULL NULL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 7
-- Number of queries: 8


-- !query 0
Expand Down Expand Up @@ -78,3 +78,11 @@ select length(uuid()), (uuid() <> uuid())
struct<length(uuid()):int,(NOT (uuid() = uuid())):boolean>
-- !query 6 output
36 true


-- !query 7
select position('bar', 'foobarbar'), position('bar', 'foobarbar', 5), position(null, 'foobarbar'), position('aaads', null)
-- !query 7 schema
struct<locate(bar, foobarbar, 1):int,locate(bar, foobarbar, 5):int,locate(CAST(NULL AS STRING), foobarbar, 1):int,locate(aaads, CAST(NULL AS STRING), 1):int>
-- !query 7 output
4 7 NULL NULL