Arrayfunktionen
| Name | Beschreibung |
ARRAY
|
Gibt ein ARRAY mit einem Element für jedes Eingabeargument zurück
|
ARRAY_CONCAT
|
Verkettet mehrere Arrays zu einem einzelnen ARRAY.
|
ARRAY_CONTAINS
|
Gibt TRUE zurück, wenn ein bestimmter ARRAY einen bestimmten Wert enthält.
|
ARRAY_CONTAINS_ALL
|
Gibt TRUE zurück, wenn alle Werte in ARRAY vorhanden sind.
|
ARRAY_CONTAINS_ANY
|
Gibt TRUE zurück, wenn einer der Werte in ARRAY vorhanden ist.
|
ARRAY_FILTER
|
Filtert Elemente aus einem ARRAY heraus, die ein Prädikat nicht erfüllen
|
ARRAY_FIRST
|
Gibt das erste Element in einem ARRAY zurück.
|
ARRAY_FIRST_N
|
Gibt die ersten n Elemente in einem ARRAY zurück
|
ARRAY_GET
|
Gibt das Element an einem bestimmten Index in einem ARRAY zurück.
|
ARRAY_INDEX_OF
|
Gibt den Index des ersten Vorkommens eines Werts in einem ARRAY zurück
|
ARRAY_INDEX_OF_ALL
|
Gibt alle Indexe eines Werts in einem ARRAY zurück
|
ARRAY_LENGTH
|
Gibt die Anzahl der Elemente in einem ARRAY zurück.
|
ARRAY_LAST
|
Gibt das letzte Element in einem ARRAY zurück.
|
ARRAY_LAST_N
|
Gibt die letzten n Elemente in einem ARRAY zurück
|
ARRAY_REVERSE
|
Kehrt die Reihenfolge der Elemente in einem ARRAY um
|
ARRAY_SLICE
|
Gibt ein Segment eines ARRAY zurück
|
ARRAY_TRANSFORM
|
Transformiert Elemente in einem ARRAY, indem ein Ausdruck auf jedes Element angewendet wird
|
MAXIMUM
|
Gibt den Maximalwert in einem ARRAY zurück.
|
MAXIMUM_N
|
Gibt die n größten Werte in einem ARRAY zurück
|
MINIMUM
|
Gibt den Mindestwert in einem ARRAY zurück.
|
MINIMUM_N
|
Gibt die n kleinsten Werte in einem ARRAY zurück
|
SUM
|
Gibt die Summe aller NUMERIC-Werte in einem ARRAY zurück.
|
JOIN
|
Erzeugt eine Verkettung der Elemente in einem ARRAY als STRING-Wert.
|
ARRAY
Syntax:
array(values: ANY...) -> ARRAY
Beschreibung:
Erstellt ein Array aus den angegebenen Elementen.
- Wenn ein Argument nicht vorhanden ist, wird es im resultierenden Array durch
NULLersetzt.
Beispiele:
| Werte | array(values) |
|---|---|
| () | [] |
| (1, 2, 3) | [1, 2, 3] |
| ("a", 1, true) | ["a", 1, true] |
| (1, null) | [1, null] |
| (1, [2, 3]) | [1, [2, 3]] |
ARRAY_CONCAT
Syntax:
array_concat(arrays: ARRAY...) -> ARRAY
Beschreibung:
Verkettet zwei oder mehr Arrays zu einem einzelnen ARRAY.
Beispiele:
| arrays | array_concat(arrays) |
|---|---|
| ([1, 2], [3, 4]) | [1, 2, 3, 4] |
| (["a", "b"], ["c"]) | ["a", "b", "c"] |
| ([1], [2], [3]) | [1, 2, 3] |
| ([], [1, 2]) | [1, 2] |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayConcat([field("subGenre")]).as("allGenres")) .execute();
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayConcat([Field("subGenre")]).as("allGenres")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayConcat(field("subGenre")).alias("allGenres")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayConcat(field("subGenre")).alias("allGenres")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_concat(Field.of("subGenre")).as_("allGenres")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayConcat(field("genre"), field("subGenre")).as("allGenres")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayConcat(firestore.FieldOf("genre"), firestore.FieldOf("subGenre")).As("allGenres"), )). Execute(ctx)
ARRAY_CONTAINS
Syntax:
array_contains(array: ARRAY, value: ANY) -> BOOLEAN
Beschreibung:
Gibt TRUE zurück, wenn value in array gefunden wird, andernfalls FALSE.
Beispiele:
| array | Wert | array_contains(array, value) |
|---|---|---|
| [1, 2, 3] | 2 | wahr |
| [[1, 2], [3]] | [1, 2] | wahr |
| [1, null] | null | wahr |
| "abc" | ALLE | Fehler |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayContains(constant("mystery")).as("isMystery")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayContains(constant("mystery")).as("isMystery")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayContains(Constant("mystery")).as("isMystery")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayContains("mystery").alias("isMystery")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayContains("mystery").alias("isMystery")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_contains("mystery").as_("isMystery")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayContains(field("genre"), "mystery").as("isMystery")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContains(firestore.FieldOf("genre"), "mystery").As("isMystery"), )). Execute(ctx)
ARRAY_CONTAINS_ALL
Syntax:
array_contains_all(array: ARRAY, search_values: ARRAY) -> BOOLEAN
Beschreibung:
Gibt TRUE zurück, wenn alle search_values in den array gefunden werden, andernfalls FALSE.
Beispiele:
| array | search_values | array_contains_all(array, search_values) |
|---|---|---|
| [1, 2, 3] | [1, 2] | wahr |
| [1, 2, 3] | [1, 4] | falsch |
| [1, null] | [null] | wahr |
| [NaN] | [NaN] | wahr |
| [] | [] | wahr |
| [1, 2, 3] | [] | wahr |
Node.js
const result = await db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll([constant("fantasy"), constant("adventure")]) .as("isFantasyAdventure") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll([constant("fantasy"), constant("adventure")]) .as("isFantasyAdventure") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("genre") .arrayContainsAll([Constant("fantasy"), Constant("adventure")]) .as("isFantasyAdventure") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll(listOf("fantasy", "adventure")) .alias("isFantasyAdventure") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll(Arrays.asList("fantasy", "adventure")) .alias("isFantasyAdventure") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("genre") .array_contains_all(["fantasy", "adventure"]) .as_("isFantasyAdventure") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAll(field("genre"), Arrays.asList("fantasy", "adventure")) .as("isFantasyAdventure")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContainsAll(firestore.FieldOf("genre"), []string{"fantasy", "adventure"}).As("isFantasyAdventure"), )). Execute(ctx)
ARRAY_CONTAINS_ANY
Syntax:
array_contains_any(array: ARRAY, search_values: ARRAY) -> BOOLEAN
Beschreibung:
Gibt TRUE zurück, wenn einer der search_values in array gefunden wird, andernfalls FALSE.
Beispiele:
| array | search_values | array_contains_any(array, search_values) |
|---|---|---|
| [1, 2, 3] | [4, 1] | wahr |
| [1, 2, 3] | [4, 5] | falsch |
| [1, 2, null] | [null] | wahr |
Node.js
const result = await db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny([constant("fantasy"), constant("nonfiction")]) .as("isMysteryOrFantasy") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny([constant("fantasy"), constant("nonfiction")]) .as("isMysteryOrFantasy") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("genre") .arrayContainsAny([Constant("fantasy"), Constant("nonfiction")]) .as("isMysteryOrFantasy") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny(listOf("fantasy", "nonfiction")) .alias("isMysteryOrFantasy") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny(Arrays.asList("fantasy", "nonfiction")) .alias("isMysteryOrFantasy") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("genre") .array_contains_any(["fantasy", "nonfiction"]) .as_("isMysteryOrFantasy") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAny(field("genre"), Arrays.asList("fantasy", "nonfiction")) .as("isMysteryOrFantasy")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContainsAny(firestore.FieldOf("genre"), []string{"fantasy", "nonfiction"}).As("isMysteryOrFantasy"), )). Execute(ctx)
ARRAY_FILTER
Syntax:
array_filter(array: ARRAY, predicate: (ANY) -> BOOLEAN) -> ARRAY
Beschreibung:
Filtert array mithilfe eines predicate-Ausdrucks und gibt ein neues Array mit nur den Elementen zurück, die das Prädikat erfüllen.
- Für jedes Element in
arraywirdpredicateausgewertet. Wenntruezurückgegeben wird, wird das Element in das Ergebnis aufgenommen. Andernfalls (wennfalseodernullzurückgegeben wird) wird es weggelassen. - Wenn
predicateals Wert ausgewertet wird, der weder ein boolescher Wert noch ein Nullwert ist, gibt die Funktion einen Fehler zurück.
Beispiele:
| array | predicate | array_filter(array, predicate) |
|---|---|---|
| [1, 2, 3] | x -> x > 1 | [2, 3] |
| [1, null, 3] | x -> x > 1 | [3] |
| ["a", "b", "c"] | x -> x != "b" | ["a", "c"] |
| [] | x -> true | [] |
ARRAY_GET
Syntax:
array_get(array: ARRAY, index: INT64) -> ANY
Beschreibung:
Gibt das Element am 0-basierten index in array zurück.
- Wenn
indexnegativ ist, wird auf Elemente ab dem Ende des Arrays zugegriffen, wobei-1das letzte Element ist. - Wenn
arraynicht vom TypARRAYund nichtnullist, wird ein Fehler zurückgegeben. - Wenn
indexaußerhalb des zulässigen Bereichs liegt, gibt die Funktion einen fehlenden Wert zurück. - Wenn
indexnicht vom TypINT64ist, gibt die Funktion einen Fehler zurück.
Beispiele:
| array | Index | array_get(array, index) |
|---|---|---|
| [1, 2, 3] | 0 | 1 |
| [1, 2, 3] | -1 | 3 |
| [1, 2, 3] | 3 | abwesend |
| [1, 2, 3] | -4 | abwesend |
| "abc" | 0 | Fehler |
| null | 0 | null |
Array |
„a“ | Fehler |
Array |
2 | Fehler |
ARRAY_LENGTH
Syntax:
array_length(array: ARRAY) -> INT64
Beschreibung:
Gibt die Anzahl der Elemente in array zurück.
Beispiele:
| array | array_length(array) |
|---|---|
| [1, 2, 3] | 3 |
| [] | 0 |
| [1, 1, 1] | 3 |
| [1, null] | 2 |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayLength().as("genreCount")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayLength().as("genreCount")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayLength().as("genreCount")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayLength().alias("genreCount")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayLength().alias("genreCount")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_length().as_("genreCount")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayLength(field("genre")).as("genreCount")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayLength(firestore.FieldOf("genre")).As("genreCount"), )). Execute(ctx)
ARRAY_REVERSE
Syntax:
array_reverse(array: ARRAY) -> ARRAY
Beschreibung:
Kehrt die angegebene array um.
Beispiele:
| array | array_reverse(array) |
|---|---|
| [1, 2, 3] | [3, 2, 1] |
| ["a", "b"] | ["b", "a"] |
| [1, 2, 2, 3] | [3, 2, 2, 1] |
Node.js
const result = await db.pipeline() .collection("books") .select(arrayReverse(field("genre")).as("reversedGenres")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayReverse().as("reversedGenres")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayReverse().as("reversedGenres")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayReverse().alias("reversedGenres")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayReverse().alias("reversedGenres")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_reverse().as_("reversedGenres")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayReverse(field("genre")).as("reversedGenres")) .execute() .get();
Go
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayReverse(firestore.FieldOf("genre")).As("reversedGenres"), )). Execute(ctx)
ARRAY_FIRST
Syntax:
array_first(array: ARRAY) -> ANY
Beschreibung:
Gibt das erste Element in array zurück. Dies entspricht array_get(array, 0).
- Wenn
arrayleer ist, wird ein fehlender Wert zurückgegeben.
Beispiele:
| array | array_first(array) |
|---|---|
| [1, 2, 3] | 1 |
| [] | abwesend |
ARRAY_FIRST_N
Syntax:
array_first_n(array: ARRAY, n: INT64) -> ARRAY
Beschreibung:
Gibt die ersten n Elemente von array zurück. Dies entspricht array_slice(array, 0, n).
- Wenn
nnegativ ist, wird ein Fehler zurückgegeben.
Beispiele:
| array | n | array_first_n(array, n) |
|---|---|---|
| [1, 2, 3, 4, 5] | 3 | [1, 2, 3] |
| [1, 2] | 3 | [1, 2] |
| [1, 2, 3] | 0 | [] |
ARRAY_INDEX_OF
Syntax:
array_index_of(array: ARRAY, value: ANY) -> INT64
Beschreibung:
Gibt den 0-basierten Index des ersten Vorkommens von value in array zurück. Gibt -1 zurück, wenn value nicht gefunden wird.
Beispiele:
| array | Wert | array_index_of(array, value) |
|---|---|---|
| [1, 2, 3, 2] | 2 | 1 |
| [1, 2, 3] | 4 | -1 |
| [1, null, 3] | null | 1 |
ARRAY_INDEX_OF_ALL
Syntax:
array_index_of_all(array: ARRAY, value: ANY) -> ARRAY<INT64>
Beschreibung:
Gibt ein Array mit den 0-basierten Indexen aller Vorkommen von value in array zurück. Gibt [] zurück, wenn value nicht gefunden wird.
Beispiele:
| array | Wert | array_index_of_all(array, value) |
|---|---|---|
| [1, 2, 3, 2] | 2 | [1, 3] |
| [1, 2, 3] | 4 | [] |
| [1, null, 3, null] | null | [1, 3] |
ARRAY_LAST
Syntax:
array_last(array: ARRAY) -> ANY
Beschreibung:
Gibt das letzte Element in array zurück. Dies entspricht array_get(array, -1).
- Wenn
arrayleer ist, wird ein fehlender Wert zurückgegeben.
Beispiele:
| array | array_last(array) |
|---|---|
| [1, 2, 3] | 3 |
| [] | abwesend |
ARRAY_LAST_N
Syntax:
array_last_n(array: ARRAY, n: INT64) -> ARRAY
Beschreibung:
Gibt die letzten n Elemente von array zurück.
- Wenn
nnegativ ist, wird ein Fehler zurückgegeben.
Beispiele:
| array | n | array_last_n(array, n) |
|---|---|---|
| [1, 2, 3, 4, 5] | 3 | [3, 4, 5] |
| [1, 2] | 3 | [1, 2] |
| [1, 2, 3] | 0 | [] |
ARRAY_SLICE
Syntax:
array_slice(array: ARRAY, offset: INT64, length: INT64) -> ARRAY
Beschreibung:
Gibt eine Teilmenge von array zurück, beginnend mit dem 0-basierten Index offset und einschließlich length Elementen.
- Wenn
offsetnegativ ist, gibt es die Startposition ab dem Ende des Arrays an, wobei-1das letzte Element ist. - Wenn
lengthgrößer ist als die Anzahl der Elemente, die nachoffsetim Array verbleiben, erstreckt sich das Ergebnis bis zum Ende des Arrays. lengthdarf nicht negativ sein, andernfalls wird ein Fehler zurückgegeben.
Beispiele:
| array | offset | Länge | array_slice(array, offset, length) |
|---|---|---|---|
| [1, 2, 3, 4, 5] | 1 | 3 | [2, 3, 4] |
| [1, 2, 3, 4, 5] | -2 | 2 | [4, 5] |
| [1, 2, 3] | 1 | 5 | [2, 3] |
| [1, 2, 3] | 3 | 2 | [] |
ARRAY_TRANSFORM
Syntax:
array_transform(array: ARRAY, expression: (ANY) -> ANY) -> ARRAY
array_transform(array: ARRAY, expression: (ANY, INT64) -> ANY) -> ARRAY
Beschreibung:
Transformiert array, indem expression auf jedes Element angewendet wird, und gibt ein neues Array mit transformierten Elementen zurück. Das Ausgabearray hat immer dieselbe Größe wie das Eingabearray.
expressionkann eine unäre Funktionelement -> resultoder eine binäre Funktion(element, index) -> resultsein.- Wenn
expressionunär ist, wird es mit jedem Element vonarrayaufgerufen. - Wenn
expressionbinär ist, wird sie mit jedem Element vonarrayund dem entsprechenden nullbasierten Index aufgerufen.
Beispiele:
| array | Ausdruck | array_transform(array, expression) |
|---|---|---|
| [1, 2, 3] | x -> x * 2 | [2, 4, 6] |
| [1, 2, 3] | x -> x + 1 | [2, 3, 4] |
| [10, 20] | (x, i) -> x + i | [10, 21] |
| [] | x -> 1 | [] |
MAXIMAL
Syntax:
maximum(array: ARRAY) -> ANY
Beschreibung:
Gibt den Maximalwert in array zurück.
NULL-Werte werden beim Vergleich ignoriert.- Wenn
arrayleer ist oder nurNULL-Werte enthält, wirdNULLzurückgegeben.
Beispiele:
| array | maximum(array) |
|---|---|
| [1, 5, 2] | 5 |
| [1, null, 5] | 5 |
| ["a", "c", "b"] | "c" |
| [null, null] | null |
| [] | null |
MAXIMUM_N
Syntax:
maximum_n(array: ARRAY, n: INT64) -> ARRAY
Beschreibung:
Gibt ein Array der n größten Werte in array in absteigender Reihenfolge zurück.
NULL-Werte werden ignoriert.- Wenn
nnegativ ist, wird ein Fehler zurückgegeben.
Beispiele:
| array | n | maximum_n(array, n) |
|---|---|---|
| [1, 5, 2, 4, 3] | 3 | [5, 4, 3] |
| [1, null, 5] | 3 | [5, 1] |
MINIMUM
Syntax:
minimum(array: ARRAY) -> ANY
Beschreibung:
Gibt den Mindestwert in array zurück.
NULL-Werte werden beim Vergleich ignoriert.- Wenn
arrayleer ist oder nurNULL-Werte enthält, wirdNULLzurückgegeben.
Beispiele:
| array | minimum(array) |
|---|---|
| [1, 5, 2] | 1 |
| [5, null, 1] | 1 |
| ["a", "c", "b"] | „a“ |
| [null, null] | null |
| [] | null |
MINIMUM_N
Syntax:
minimum_n(array: ARRAY, n: INT64) -> ARRAY
Beschreibung:
Gibt ein Array der n kleinsten Werte in array in aufsteigender Reihenfolge zurück.
NULL-Werte werden ignoriert.- Wenn
nnegativ ist, wird ein Fehler zurückgegeben.
Beispiele:
| array | n | minimum_n(array, n) |
|---|---|---|
| [1, 5, 2, 4, 3] | 3 | [1, 2, 3] |
| [5, null, 1] | 3 | [1, 5] |
SUM
Syntax:
sum(array: ARRAY) -> INT64 | FLOAT64
Beschreibung:
Gibt die Summe aller NUMERIC-Werte in einem ARRAY zurück.
- Nicht numerische Werte im Array werden ignoriert.
- Wenn ein numerischer Wert im Array
NaNist, gibt die FunktionNaNzurück. - Der Rückgabetyp wird durch den breitesten numerischen Typ im Array bestimmt:
INT64<FLOAT64. - Wenn ein 64-Bit-Ganzzahlüberlauf auftritt, bevor ein Gleitkommawert summiert wird, wird ein Fehler zurückgegeben. Wenn Gleitkommawerte summiert werden, führt ein Überlauf zu +/- unendlich.
- Wenn das Array überhaupt keine numerischen Werte enthält, gibt die Funktion
NULLzurück.
Beispiele:
| array | sum(array) |
|---|---|
| [1, 2, 3] | 6L |
| [1L, 2L, 3L] | 6L |
| [2000000000, 2000000000] | 4000000000L |
| [10, 20.5] | 30,5 |
| [1, "a", 2] | 3L |
| [INT64.MAX_VALUE, 1] | Fehler |
| [INT64.MAX_VALUE, 1, -1.0] | Fehler |
| [INT64.MAX_VALUE, 1.0] | 9.223372036854776e+18 |
Beitreten
Syntax:
join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T) -> STRING
join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T, null_text: T) -> STRING
Beschreibung:
Gibt eine Verkettung der Elemente in array als STRING zurück. array kann den Datentyp STRING oder BYTES haben.
- Alle Elemente in
array,delimiterundnull_textmüssen vom selben Typ sein, also entweder alleSTRINGoder alleBYTES. - Wenn
null_textangegeben ist, werden alleNULL-Werte inarraydurchnull_textersetzt. - Wenn
null_textnicht angegeben ist, werdenNULL-Werte inarrayim Ergebnis weggelassen.
Beispiele:
Wenn null_text nicht angegeben ist:
| array | delimiter | join(array, delimiter) |
|---|---|---|
| ["a", "b", "c"] | "," | "a,b,c" |
| ["a", null, "c"] | "," | "a,c" |
| [b'a', b'b', b'c'] | b',' | b'a,b,c' |
| ["a", b'c'] | "," | Fehler |
| ["a", "c"] | b',' | Fehler |
| [b'a', b'c'] | "," | Fehler |
Wenn null_text angegeben wurde, geschieht Folgendes:
| array | delimiter | null_text | join(array, delimiter, null_text) |
|---|---|---|---|
| ["a", null, "c"] | "," | „MISSING“ | "a,MISSING,c" |
| [b'a', null, b'c'] | b',' | b'NULL' | b'a,NULL,c' |
| [null, "b", null] | "," | „MISSING“ | "MISSING,b,MISSING" |
| [b'a', null, null] | b',' | b'NULL' | b'a,NULL,NULL' |
| ["a", null] | "," | b'N' | Fehler |
| [b'a', null] | b',' | "N" | Fehler |