Skip to content

Commit

Permalink
add functions. fix #250
Browse files Browse the repository at this point in the history
  • Loading branch information
kitta65 committed Dec 29, 2023
1 parent fc8d671 commit 7ec9bbf
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions server/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ SELECT POWER(2, 3) -- 8.0`,
EXP(0), -- 1.0
EXP(1), -- 2.718281828459045`,
},
{
ident: "EUCLIDEAN_DISTANCE",
example: `SELECT
-- 1.4142135623730951
EUCLIDEAN_DISTANCE([0.0, 0,0], [1.0, 1.0]),`,
},
{ ident: "LN", example: `SELECT LN(2.718281828459045) -- 1.0` },
{ ident: "LOG", example: `SELECT LOG(8, 2) -- 3.0` },
{ ident: "LOG10", example: `SELECT LOG10(100) -- 2.0` },
Expand Down Expand Up @@ -581,6 +587,12 @@ SELECT POWER(2, 3) -- 8.0`,
example: `SELECT COS(0) -- 1.0`,
},
"COSH",
{
ident: "COSINE_DISTANCE",
example: `SELECT
-- 1.0
COSINE_DISTANCE([1.0, 0.0], [0.0, 1.0])`,
},
"ACOS",
"ACOSH",
{ ident: "SIN", example: `SELECT SIN(0) -- 0.0` },
Expand Down Expand Up @@ -830,6 +842,11 @@ SELECT CHARACTER_LENGTH('ABC') -- 3`,
-- true
CONTAINS_SUBSTR([1, 2], '1')`,
},
{
ident: "EDIT_DISTANCE",
example: `SELECT
EDIT_DISTANCE('aaa', 'abc'), -- 2`,
},
{
ident: "ENDS_WITH",
example: `SELECT
Expand Down Expand Up @@ -1800,6 +1817,27 @@ SELECT
'2020-01-01 00:00:00'
) -- DATETIME '2020-01-01 00:00:00'`,
},
// ----- text analysis functions -----
{
ident: "BAG_OF_WORDS",
example: `SELECT
-- ARRAY<STRUCT<term string, count int64>>[
-- ("gain", 1), ("no", 2), ("pain", 1)
-- ]
BAG_OF_WORDS([
"no",
"pain",
"no",
"gain"
])`,
},
{
ident: "TEXT_ANALYZE",
example: `SELECT
-- ["no", "pain", "no", "gain"]
TEXT_ANALYZE(["no pain, no gain"])`,
},
"TF_IDF",
// ----- time functions -----
{
ident: "CURRENT_TIME",
Expand Down

0 comments on commit 7ec9bbf

Please sign in to comment.