@@ -291,6 +291,10 @@ def _build_sort_array_desc(args: t.List) -> exp.Expression:
291291 return exp .SortArray (this = seq_get (args , 0 ), asc = exp .false ())
292292
293293
294+ def _build_array_prepend (args : t .List ) -> exp .Expression :
295+ return exp .ArrayPrepend (this = seq_get (args , 1 ), expression = seq_get (args , 0 ))
296+
297+
294298def _build_date_diff (args : t .List ) -> exp .Expression :
295299 return exp .DateDiff (this = seq_get (args , 2 ), expression = seq_get (args , 1 ), unit = seq_get (args , 0 ))
296300
@@ -971,6 +975,7 @@ class Parser(parser.Parser):
971975 FUNCTIONS = {
972976 ** parser .Parser .FUNCTIONS ,
973977 "ANY_VALUE" : lambda args : exp .IgnoreNulls (this = exp .AnyValue .from_arg_list (args )),
978+ "ARRAY_PREPEND" : _build_array_prepend ,
974979 "ARRAY_REVERSE_SORT" : _build_sort_array_desc ,
975980 "ARRAY_SORT" : exp .SortArray .from_arg_list ,
976981 "BIT_AND" : exp .BitwiseAndAgg .from_arg_list ,
@@ -995,12 +1000,14 @@ class Parser(parser.Parser):
9951000 "JSON" : exp .ParseJSON .from_arg_list ,
9961001 "JSON_EXTRACT_PATH" : parser .build_extract_json_with_path (exp .JSONExtract ),
9971002 "JSON_EXTRACT_STRING" : parser .build_extract_json_with_path (exp .JSONExtractScalar ),
1003+ "LIST_APPEND" : exp .ArrayAppend .from_arg_list ,
9981004 "LIST_CONTAINS" : exp .ArrayContains .from_arg_list ,
9991005 "LIST_COSINE_DISTANCE" : exp .CosineDistance .from_arg_list ,
10001006 "LIST_DISTANCE" : exp .EuclideanDistance .from_arg_list ,
10011007 "LIST_FILTER" : exp .ArrayFilter .from_arg_list ,
10021008 "LIST_HAS" : exp .ArrayContains .from_arg_list ,
10031009 "LIST_HAS_ANY" : exp .ArrayOverlaps .from_arg_list ,
1010+ "LIST_PREPEND" : _build_array_prepend ,
10041011 "LIST_REVERSE_SORT" : _build_sort_array_desc ,
10051012 "LIST_SORT" : exp .SortArray .from_arg_list ,
10061013 "LIST_TRANSFORM" : exp .Transform .from_arg_list ,
@@ -1279,9 +1286,11 @@ class Generator(generator.Generator):
12791286 [transforms .inherit_struct_field_names ],
12801287 generator = inline_array_unless_query ,
12811288 ),
1289+ exp .ArrayAppend : rename_func ("LIST_APPEND" ),
12821290 exp .ArrayFilter : rename_func ("LIST_FILTER" ),
12831291 exp .ArrayRemove : remove_from_array_using_filter ,
12841292 exp .ArraySort : _array_sort_sql ,
1293+ exp .ArrayPrepend : lambda self , e : self .func ("LIST_PREPEND" , e .expression , e .this ),
12851294 exp .ArraySum : rename_func ("LIST_SUM" ),
12861295 exp .ArrayUniqueAgg : lambda self , e : self .func (
12871296 "LIST" , exp .Distinct (expressions = [e .this ])
0 commit comments