GQL icon indicating copy to clipboard operation
GQL copied to clipboard

Implement SQL String functions with documentations

Open AmrDeveloper opened this issue 2 years ago • 28 comments

Implement string function in our engine, one per pull request.

Steps:

  • Choose unimplemented function and write I am on <function_name>.
  • Then start implement the function in crates/gitql-ast/function.rs.
  • Add docs for it in docs/function/function.md.
  • Make sure everything is formatted and submit a Pull Request.
  • Don't forget to mention issue number in pull request title.

Text Functions

  • [x] ASCII
  • [x] CHAR
  • [x] CHARINDEX
  • [x] CONCAT
  • [x] DATALENGTH
  • [ ] DIFFERENCE
  • [ ] FORMAT
  • [x] LEFT
  • [x] LEN
  • [x] LOWER
  • [x] LTRIM
  • [x] NCHAR
  • [ ] PATINDEX
  • [x] QUOTENAME
  • [x] REPLACE
  • [x] REPLICATE
  • [x] REVERSE
  • [x] RIGHT
  • [x] RTRIM
  • [x] SOUNDEX
  • [x] SPACE
  • [ ] STR
  • [x] STUFF
  • [x] SUBSTRING
  • [x] TRANSLATE
  • [x] TRIM
  • [x] UNICODE
  • [x] UPPER

For more information about implementation and description check https://www.w3schools.com/sql/sql_ref_sqlserver.asp

Note: You can only open max 3 PR at the time

AmrDeveloper avatar Sep 07 '23 17:09 AmrDeveloper

I am on ASCII

Lilit0x avatar Sep 07 '23 19:09 Lilit0x

I am on CHAR

Lilit0x avatar Sep 07 '23 19:09 Lilit0x

@AmrDeveloper , the CHARINDEX function might be tricky since the last argument is optional, but the condition checks if the specified arguments match, I mean here .

Lilit0x avatar Sep 07 '23 20:09 Lilit0x

I am on DATALENGTH. Also, you made a typo for DATALENGTH in the list

Lilit0x avatar Sep 07 '23 20:09 Lilit0x

@AmrDeveloper , the CHARINDEX function might be tricky since the last argument is optional, but the condition checks if the specified arguments match, I mean here .

You are right some functions we will delay them until do some improvements in type system

AmrDeveloper avatar Sep 07 '23 21:09 AmrDeveloper

I am on LEFT

Lilit0x avatar Sep 07 '23 23:09 Lilit0x

@AmrDeveloper, is there a difference between the implementation of NCHAR and CHAR at least in Rust, since all characters are just u32s under the hood and just casting from the number will be the same.

Lilit0x avatar Sep 07 '23 23:09 Lilit0x

NCHAR

You are right, we can ignore it for now and maybe if needed we can pass the the char function to it

AmrDeveloper avatar Sep 08 '23 08:09 AmrDeveloper

NCHAR

You are right, we can ignore it for now and maybe if needed we can pass the the char function to it

Yeahh, that was I planned on doing, wanted to get your approval on it.

Lilit0x avatar Sep 08 '23 08:09 Lilit0x

I am on PATINDEX

Lilit0x avatar Sep 08 '23 16:09 Lilit0x

NCHAR

You are right, we can ignore it for now and maybe if needed we can pass the the char function to it

Yeahh, that was I planned on doing, wanted to get your approval on it.

I faced the same problem in Date functions too we need to decide if we should duplicate them or take only one

AmrDeveloper avatar Sep 09 '23 12:09 AmrDeveloper

NCHAR

You are right, we can ignore it for now and maybe if needed we can pass the the char function to it

Yeahh, that was I planned on doing, wanted to get your approval on it.

I faced the same problem in Date functions too we need to decide if we should duplicate them or take only one

We could just use different names for them but they'll still be the same function. What I mean is:

  map.insert("char", text_char);
  map.insert("nchar", text_char);

And we do the same in the PROTOTYPES hashmap too

Lilit0x avatar Sep 09 '23 18:09 Lilit0x

I am on REPLACE

Lilit0x avatar Sep 09 '23 18:09 Lilit0x

I am on RIGHT

Lilit0x avatar Sep 09 '23 19:09 Lilit0x

I am on STUFF

Lilit0x avatar Sep 09 '23 19:09 Lilit0x

I am on SUBSTRING

Lilit0x avatar Sep 09 '23 20:09 Lilit0x

I am on TRANSLATE

Lilit0x avatar Sep 13 '23 15:09 Lilit0x

@Lilit0x Lets keep next PR one by one it will be fast to review and merge

AmrDeveloper avatar Sep 13 '23 15:09 AmrDeveloper

Okay, got it.

Lilit0x avatar Sep 13 '23 15:09 Lilit0x

I am on SOUNDEX

Lilit0x avatar Sep 13 '23 19:09 Lilit0x

I am on CONCAT

tbro avatar Sep 14 '23 15:09 tbro

I am on UNICODE

tbro avatar Sep 14 '23 17:09 tbro

I am on CHARINDEX

mobley-trent avatar Dec 20 '23 08:12 mobley-trent

Hello @AmrDeveloper how do we handle optional arguments ?

mobley-trent avatar Dec 20 '23 08:12 mobley-trent

@mobley-trent Optional type is not implemented yet, i just implemented Variant and will implement Option soon

AmrDeveloper avatar Dec 20 '23 17:12 AmrDeveloper

@mobley-trent Now support Optional and varargs types

AmrDeveloper avatar Dec 21 '23 18:12 AmrDeveloper

@AmrDeveloper NCHAR is already implemented but it's not marked as complete in the task list.

2024-02-26T04:57:57,788529872+03:00

frectonz avatar Feb 26 '24 02:02 frectonz

I am on QUOTENAME

frectonz avatar Feb 26 '24 19:02 frectonz