diff --git a/src/function/built_in_vector_functions.cpp b/src/function/built_in_vector_functions.cpp index b8eb18b4463..c431c19eca3 100644 --- a/src/function/built_in_vector_functions.cpp +++ b/src/function/built_in_vector_functions.cpp @@ -448,6 +448,7 @@ void BuiltInVectorFunctions::registerStringFunctions() { vectorFunctions.insert({LCASE_FUNC_NAME, LowerVectorFunction::getDefinitions()}); vectorFunctions.insert({LEFT_FUNC_NAME, LeftVectorFunction::getDefinitions()}); vectorFunctions.insert({LENGTH_FUNC_NAME, LengthVectorFunction::getDefinitions()}); + vectorFunctions.insert({SIZE_FUNC_NAME, LengthVectorFunction::getDefinitions()}); vectorFunctions.insert({LOWER_FUNC_NAME, LowerVectorFunction::getDefinitions()}); vectorFunctions.insert({LPAD_FUNC_NAME, LpadVectorFunction::getDefinitions()}); vectorFunctions.insert({LTRIM_FUNC_NAME, LtrimVectorFunction::getDefinitions()}); diff --git a/src/include/common/expression_type.h b/src/include/common/expression_type.h index 52c03d50c9f..c9ed66c8880 100644 --- a/src/include/common/expression_type.h +++ b/src/include/common/expression_type.h @@ -174,6 +174,7 @@ const std::string REGEXP_MATCHES_FUNC_NAME = "REGEXP_MATCHES"; const std::string REGEXP_REPLACE_FUNC_NAME = "REGEXP_REPLACE"; const std::string REGEXP_EXTRACT_FUNC_NAME = "REGEXP_EXTRACT"; const std::string REGEXP_EXTRACT_ALL_FUNC_NAME = "REGEXP_EXTRACT_ALL"; +const std::string SIZE_FUNC_NAME = "SIZE"; // Date functions. const std::string DATE_PART_FUNC_NAME = "DATE_PART"; diff --git a/test/test_files/tinysnb/function/list.test b/test/test_files/tinysnb/function/list.test index cc56a0c12c4..018efc17242 100644 --- a/test/test_files/tinysnb/function/list.test +++ b/test/test_files/tinysnb/function/list.test @@ -42,7 +42,7 @@ Binder exception: Cannot bind LIST_CREATION with parameter type STRING and INT64 ---- error Binder exception: Cannot bind LIST_CREATION with parameter type INT64[] and STRING[]. --LOG NodeLISTStructuredPropertiesTest +-LOG NodeLISTPropertiesTest -STATEMENT MATCH (a:person) RETURN a.workedHours, a.usedNames, a.courseScoresPerTerm ---- 8 [1,9]|[Wolfeschlegelstein,Daniel]|[[7,4],[8,8],[9]] @@ -241,7 +241,7 @@ False 10 years 5 months 13:00:00.000024 3 years 2 days 13:02:00 --LOG ListExtractStructuredListOfListOfInts +-LOG ListExtractListOfListOfInts -STATEMENT MATCH (a:person) RETURN list_element(a.courseScoresPerTerm, 1) ---- 8 [10,8] @@ -253,7 +253,7 @@ False [10] [7] --LOG ListExtractStructuredList +-LOG ListExtractList -STATEMENT MATCH (a:person) RETURN a.usedNames[1] ---- 8 Aida @@ -306,7 +306,7 @@ ad ---- 1 是一个中 --LOG ListLenStructuredListOfInts +-LOG ListLenListOfInts -STATEMENT MATCH (a:person) RETURN len(a.workedHours) ---- 8 2 @@ -318,7 +318,19 @@ ad 1 8 --LOG ListConcatStructuredListOfInts +-LOG ListSize +-STATEMENT MATCH (a:person) RETURN len(a.courseScoresPerTerm) +---- 8 +2 +2 +1 +3 +3 +1 +1 +3 + +-LOG ListConcatListOfInts -STATEMENT MATCH (a:person) RETURN list_concat(a.workedHours, [a.age, a.gender]) ---- 8 [10,5,35,1] @@ -342,7 +354,7 @@ ad [1,3] [10,11,12,3,4,5,6,7,3] --LOG ListConcatStructuredListOfStrings +-LOG ListConcatListOfStrings -STATEMENT MATCH (a:person) RETURN array_concat(a.usedNames, [a.fName]) ---- 8 [Aida,Alice] @@ -354,7 +366,7 @@ ad [Grad,Greg] [Ad,De,Hi,Kye,Orlan,Hubert Blaine Wolfeschlegelsteinhausenbergerdorff] --LOG ListConcatStructuredListOfListOfInts +-LOG ListConcatListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_cat(a.courseScoresPerTerm, [[a.age, a.age], [a.gender]]) ---- 8 [[10,8],[6,7,8],[35,35],[1]] @@ -474,7 +486,7 @@ ad [1.600000,1.600000] [1.323000,1.323000] --LOG ListAppendStructuredListOfStrings +-LOG ListAppendListOfStrings -STATEMENT MATCH (a:person) RETURN array_append(a.usedNames, a.fName) ---- 8 [Aida,Alice] @@ -486,7 +498,7 @@ ad [Grad,Greg] [Ad,De,Hi,Kye,Orlan,Hubert Blaine Wolfeschlegelsteinhausenbergerdorff] --LOG ListAppendStructuredListOfListOfInts +-LOG ListAppendListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_push_back(a.courseScoresPerTerm, [a.age, a.age]) ---- 8 [[10,8],[6,7,8],[35,35]] @@ -498,7 +510,7 @@ ad [[10],[40,40]] [[7],[10],[6,7],[83,83]] --LOG ListAppendStructuredListOfBools +-LOG ListAppendListOfBools -STATEMENT MATCH (a:person) RETURN list_append([a.isStudent, a.isWorker], a.isStudent) ---- 8 [True,False,True] @@ -510,7 +522,7 @@ ad [False,False,False] [False,True,False] --LOG ListAppendStructuredListOfDoubles +-LOG ListAppendListOfDoubles -STATEMENT MATCH (a:person) RETURN list_append([a.eyeSight], a.eyeSight) ---- 8 [5.000000,5.000000] @@ -522,7 +534,7 @@ ad [4.900000,4.900000] [4.900000,4.900000] --LOG ListAppendStructuredListOfDates +-LOG ListAppendListOfDates -STATEMENT MATCH (a:person) RETURN list_append([a.birthdate], a.birthdate) ---- 8 [1900-01-01,1900-01-01] @@ -534,7 +546,7 @@ ad [1980-10-26,1980-10-26] [1990-11-27,1990-11-27] --LOG ListAppendStructuredListOfTimestamps +-LOG ListAppendListOfTimestamps -STATEMENT MATCH (a:person) RETURN list_append([a.registerTime], a.registerTime) ---- 8 [2011-08-20 11:25:30,2011-08-20 11:25:30] @@ -546,7 +558,7 @@ ad [1976-12-23 04:41:42,1976-12-23 04:41:42] [2023-02-21 13:25:30,2023-02-21 13:25:30] --LOG ListAppendStructuredListOfIntervals +-LOG ListAppendListOfIntervals -STATEMENT MATCH (a:person) RETURN list_append([a.lastJobDuration], a.lastJobDuration) ---- 8 [3 years 2 days 13:02:00,3 years 2 days 13:02:00] @@ -644,7 +656,7 @@ ad [1.600000,1.600000] [1.323000,1.323000] --LOG ListPrependStructuredListOfStrings +-LOG ListPrependListOfStrings -STATEMENT MATCH (a:person) RETURN array_prepend(a.usedNames, a.fName) ---- 8 [Alice,Aida] @@ -656,7 +668,7 @@ ad [Greg,Grad] [Hubert Blaine Wolfeschlegelsteinhausenbergerdorff,Ad,De,Hi,Kye,Orlan] --LOG ListPrependStructuredListOfBools +-LOG ListPrependListOfBools -STATEMENT MATCH (a:person) RETURN list_prepend([a.isStudent, a.isWorker], a.isStudent) ---- 8 [True,True,False] @@ -668,7 +680,7 @@ ad [False,False,False] [False,False,True] --LOG ListPrependStructuredListOfDoubles +-LOG ListPrependListOfDoubles -STATEMENT MATCH (a:person) RETURN list_prepend([a.eyeSight], a.eyeSight) ---- 8 [5.000000,5.000000] @@ -680,7 +692,7 @@ ad [4.900000,4.900000] [4.900000,4.900000] --LOG ListPrependStructuredListOfDates +-LOG ListPrependListOfDates -STATEMENT MATCH (a:person) RETURN list_prepend([a.birthdate], a.birthdate) ---- 8 [1900-01-01,1900-01-01] @@ -692,7 +704,7 @@ ad [1980-10-26,1980-10-26] [1990-11-27,1990-11-27] --LOG ListPrependStructuredListOfTimestamps +-LOG ListPrependListOfTimestamps -STATEMENT MATCH (a:person) RETURN list_prepend([a.registerTime], a.registerTime) ---- 8 [2011-08-20 11:25:30,2011-08-20 11:25:30] @@ -704,7 +716,7 @@ ad [1976-12-23 04:41:42,1976-12-23 04:41:42] [2023-02-21 13:25:30,2023-02-21 13:25:30] --LOG ListPrependStructuredListOfIntervals +-LOG ListPrependListOfIntervals -STATEMENT MATCH (a:person) RETURN list_prepend([a.lastJobDuration], a.lastJobDuration) ---- 8 [3 years 2 days 13:02:00,3 years 2 days 13:02:00] @@ -716,7 +728,7 @@ ad [10 years 5 months 13:00:00.000024,10 years 5 months 13:00:00.000024] [3 years 2 days 13:02:00,3 years 2 days 13:02:00] --LOG ListPrependStructuredListOfListOfInts +-LOG ListPrependListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_push_front(a.courseScoresPerTerm, [a.age, a.age]) ---- 8 [[35,35],[10,8],[6,7,8]] @@ -740,7 +752,7 @@ ad [0:6,0:6] [0:7,0:7] --LOG ListPositionStructuredListOfInts +-LOG ListPositionListOfInts -STATEMENT MATCH (a:person) RETURN list_position(a.workedHours, 5) ---- 8 2 @@ -752,7 +764,7 @@ ad 0 6 --LOG ListPositionStructuredListOfStrings +-LOG ListPositionListOfStrings -STATEMENT MATCH (a:person) RETURN array_position(a.usedNames, "Grad") ---- 8 0 @@ -771,7 +783,7 @@ ad 2 4 --LOG ListPositionStructuredListOfListOfInts +-LOG ListPositionListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_indexof(a.courseScoresPerTerm, [8]) ---- 8 0 @@ -879,7 +891,7 @@ ad 0 0 --LOG ListContainsStructuredListOfInts +-LOG ListContainsListOfInts -STATEMENT MATCH (a:person) RETURN list_contains(a.workedHours, 5) ---- 8 True @@ -897,7 +909,7 @@ True 7 8 --LOG ListContainsStructuredListOfStrings +-LOG ListContainsListOfStrings -STATEMENT MATCH (a:person) RETURN list_has(a.usedNames, "Grad") ---- 8 False @@ -909,7 +921,7 @@ False True False --LOG ListContainsStructuredListOfListOfInts +-LOG ListContainsListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_contains(a.courseScoresPerTerm, [8]) ---- 8 False @@ -935,7 +947,7 @@ True [7,9,10,20] [7,9,10,20,15,192] --LOG ListSliceStructuredListOfInts +-LOG ListSliceListOfInts -STATEMENT MATCH (a:person) RETURN list_slice(a.workedHours, 1, 2) ---- 8 [10] @@ -947,7 +959,7 @@ True [1] [10] --LOG ListSliceStructuredListOfListOfInts +-LOG ListSliceListOfListOfInts -STATEMENT MATCH (a:person) RETURN array_slice(a.usedNames, 1, 2) ---- 8 [Aida] @@ -959,7 +971,7 @@ True [Grad] [Ad] --LOG ListSliceStructuredListOfStrings +-LOG ListSliceListOfStrings -STATEMENT MATCH (a:person) RETURN list_slice(a.courseScoresPerTerm, 1, 2) ---- 8 [[10,8]] @@ -971,14 +983,14 @@ True [[10]] [[7]] --LOG ListSliceStructuredString +-LOG ListSliceString -STATEMENT MATCH (o:organisation) RETURN o.name[1:4] ---- 3 ABFs CsWo DEsW --LOG ListSliceStructuredStringRight +-LOG ListSliceStringRight -STATEMENT MATCH (a:person) RETURN a.fName[4:] ---- 8 ce @@ -990,7 +1002,7 @@ ooq g ert Blaine Wolfeschlegelsteinhausenbergerdorff --LOG ListSliceStructuredStringLeft +-LOG ListSliceStringLeft -STATEMENT MATCH (a:person) RETURN a.fName[:5] ---- 8 Alice @@ -1002,14 +1014,14 @@ Faroo Greg Huber --LOG ListSliceStructuredStringNull +-LOG ListSliceStringNull -STATEMENT MATCH (o:organisation) RETURN o.name[:] ---- 3 ABFsUni CsWork DEsWork --LOG ListSliceStructuredStringDoubleSlice +-LOG ListSliceStringDoubleSlice -STATEMENT MATCH (a:person) RETURN a.fName[3:][2:4] ---- 8 ce diff --git a/test/test_files/tinysnb/function/string.test b/test/test_files/tinysnb/function/string.test index 2f55c2d3ed6..d86244d13cd 100644 --- a/test/test_files/tinysnb/function/string.test +++ b/test/test_files/tinysnb/function/string.test @@ -90,12 +90,12 @@ ---- 1 1 --LOG DateVarAndStrVarConcatStructured +-LOG DateVarAndStrVarConcat -STATEMENT MATCH (a:person) WHERE '1900-01-01Alice' = concat(string(a.birthdate), a.fName) RETURN COUNT(*) ---- 1 1 --LOG TimestampVarAndStrVarConcatStructured +-LOG TimestampVarAndStrVarConcat -STATEMENT MATCH (a:person) WHERE '2011-08-20 11:25:30Alice' = concat(string(a.registerTime), a.fName) RETURN COUNT(*) ---- 1 1 @@ -151,7 +151,7 @@ False ---- 1 Carol --LOG LowerStructuredStr +-LOG LowerStr -STATEMENT MATCH (o:organisation) RETURN lower(o.name) ---- 3 abfsuni @@ -165,7 +165,7 @@ sóló cón tu párejâ the 😂😃🧘🏻‍♂️🌍🌦️🍞🚗 movie roma --LOG UpperStructuredStr +-LOG UpperStr -STATEMENT MATCH (o:organisation) RETURN upper(o.name) ---- 3 ABFSUNI @@ -179,28 +179,28 @@ SÓLÓ CÓN TU PÁREJÂ THE 😂😃🧘🏻‍♂️🌍🌦️🍞🚗 MOVIE ROMA --LOG TrimStructuredStr +-LOG TrimStr -STATEMENT MATCH (o:organisation) RETURN trim(o.name) ---- 3 ABFsUni CsWork DEsWork --LOG LtrimStructuredStr +-LOG LtrimStr -STATEMENT MATCH (o:organisation) RETURN ltrim(o.name) ---- 3 ABFsUni CsWork DEsWork --LOG RtrimStructuredStr +-LOG RtrimStr -STATEMENT MATCH (o:organisation) RETURN rtrim(o.name) ---- 3 ABFsUni CsWork DEsWork --LOG ReverseStructuredStr +-LOG ReverseStr -STATEMENT MATCH (o:organisation) RETURN reverse(o.name) ---- 3 inUsFBA @@ -214,21 +214,28 @@ kroWsED eivom 🚗🍞🌦️🌍🧘🏻‍♂️😃😂 ehT amoR --LOG LengthStructuredStr +-LOG LengthStr -STATEMENT MATCH (o:organisation) RETURN length(o.name) ---- 3 7 6 7 --LOG RepeatStructuredStr +-LOG SizeStr +-STATEMENT MATCH (:person)-[s:studyAt]->(:organisation) RETURN size(s.places[1]) +---- 3 +13 +14 +4 + +-LOG RepeatStr -STATEMENT MATCH (o:organisation) RETURN repeat(o.name, o.ID) ---- 3 ABFsUni CsWorkCsWorkCsWorkCsWork DEsWorkDEsWorkDEsWorkDEsWorkDEsWorkDEsWork --LOG LpadStructuredStrAndLiteralInt +-LOG LpadStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN lpad(p.fName, 5, "<") ---- 8 Alice @@ -266,7 +273,7 @@ Huber --LOG RpadStructuredStrAndLiteralInt +-LOG RpadStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN rpad(p.fName, 15, ">") ---- 8 Alice>>>>>>>>>> @@ -292,7 +299,7 @@ Romaâó😂😃🍞🚗âó😂😃🍞🚗âó😂😃🍞🚗âó😂😃🍞 --LOG RpadStructuredStrAndStructuredInt +-LOG RpadStrAndInt -STATEMENT MATCH (p:person) RETURN rpad(p.fName, p.ID, "<") ---- 8 @@ -311,7 +318,7 @@ Hubert Bla --LOG SubStrStructuredStrAndLiteralInt +-LOG SubStrStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN substr(p.fName, 2, 12) ---- 8 lice @@ -323,7 +330,7 @@ arooq reg ubert Blaine --LOG LeftPositiveIdxStructuredStrAndLiteralInt +-LOG LeftPositiveIdxStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN left(p.fName, 11) ---- 8 Alice @@ -342,14 +349,14 @@ Sóló c The 😂😃 Roma --LOG LeftPositiveIdxStructuredStrAndStructuredInt +-LOG LeftPositiveIdxStrAndInt -STATEMENT MATCH (o:organisation) RETURN left(o.name, o.ID) ---- 3 A CsWo DEsWor --LOG LeftNegativeIdxStructuredStrAndLiteralInt +-LOG LeftNegativeIdxStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN left(p.fName, -4) ---- 8 A @@ -367,7 +374,7 @@ Hubert Blaine Wolfeschlegelsteinhausenbergerd Sóló cón tu The 😂😃🧘🏻‍♂️🌍🌦️🍞 --LOG RightPositiveIdxStructuredStrAndLiteralInt +-LOG RightPositiveIdxStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN right(p.fName, 10) ---- 8 Alice @@ -386,14 +393,14 @@ ergerdorff movie Roma --LOG RightPositiveIdxStructuredStrAndStructuredInt +-LOG RightPositiveIdxStrAndInt -STATEMENT MATCH (o:organisation) RETURN right(o.name, o.ID) ---- 3 i Work EsWork --LOG RightNegativeIdxStructuredStrAndLiteralInt +-LOG RightNegativeIdxStrAndLiteralInt -STATEMENT MATCH (p:person) RETURN right(p.fName, -4) ---- 8 e @@ -412,14 +419,14 @@ rt Blaine Wolfeschlegelsteinhausenbergerdorff 😂😃🧘🏻‍♂️🌍🌦️🍞🚗 movie a --LOG ArrayExtractPositiveIdxStructuredStrAndStructuredInt +-LOG ArrayExtractPositiveIdxStrAndInt -STATEMENT MATCH (o:organisation) RETURN array_extract(o.name, o.ID + 2) ---- 3 F k k --LOG ArrayExtractNegativeIdxStructuredStrAndStructuredInt +-LOG ArrayExtractNegativeIdxStrAndInt -STATEMENT MATCH (o:organisation) RETURN array_extract(o.name, o.ID - 5) ---- 3 s @@ -447,7 +454,7 @@ R --LOG ListExtractStructuredString +-LOG ListExtractString -STATEMENT MATCH (o:organisation) RETURN o.name[2] ---- 3 B @@ -494,7 +501,7 @@ R --LOG SuffixStructuredStr +-LOG SuffixStr -STATEMENT MATCH (o:organisation) RETURN suffix(o.name, "Work") ---- 3 False