分享方式:


對應資料流中的資料轉換運算式

適用於:Azure Data Factory Azure Synapse Analytics

提示

試用 Microsoft Fabric 中的 Data Factory,這是適用於企業的全方位分析解決方案。 Microsoft Fabric 涵蓋從資料移動到資料科學、即時分析、商業智慧和報告的所有項目。 了解如何免費啟動新的試用版

Azure Data Factory 和 Azure Synapse Pipelines 中均可使用資料流。 本文適用於對應資料流。 如果您不熟悉轉換作業,請參閱簡介文章使用對應資料流轉換資料

下列文章提供對應資料流中 Azure Data Factory 和 Azure Synapse Analytics 所支援所有運算式和函式的使用方式詳細資料。 如需支援的每種函式類型摘要,請參考下列文章:

所有函式的依字母順序排列的清單

以下是對應資料流中,可用所有函式的依字母順序排列的清單。

A

abs

abs(<value1> : number) => number

數字的絕對值。

  • abs(-20) -> 20
  • abs(10) -> 10

acos

acos(<value1> : number) => double

計算反餘弦值。

  • acos(1) -> 0.0

add

add(<value1> : any, <value2> : any) => any

新增一對字串或數字。 將日期新增至天數。 將持續時間新增至時間戳記。 對某個陣列附加類似類型的另一個陣列。 相當於 + 運算子。

  • add(10, 20) -> 30
  • 10 + 20 -> 30
  • add('ice', 'cream') -> 'icecream'
  • 'ice' + 'cream' + ' cone' -> 'icecream cone'
  • add(toDate('2012-12-12'), 3) -> toDate('2012-12-15')
  • toDate('2012-12-12') + 3 -> toDate('2012-12-15')
  • [10, 20] + [30, 40] -> [10, 20, 30, 40]
  • toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS') + (days(1) + hours(2) - seconds(10)) -> toTimestamp('2019-02-04 07:19:18.871', 'yyyy-MM-dd HH:mm:ss.SSS')

addDays

addDays(<date/timestamp> : datetime, <days to add> : integral) => datetime

在日期或時間戳記中增加天數。 相當於日期的 + 運算子。

  • addDays(toDate('2016-08-08'), 1) -> toDate('2016-08-09')

addMonths

addMonths(<date/timestamp> : datetime, <months to add> : integral, [<value3> : string]) => datetime

在日期或時間戳記中增加月數。 您可以選擇性地傳遞時區。

  • addMonths(toDate('2016-08-31'), 1) -> toDate('2016-09-30')
  • addMonths(toTimestamp('2016-09-30 10:10:10'), -1) -> toTimestamp('2016-08-31 10:10:10')

and

and(<value1> : boolean, <value2> : boolean) => boolean

邏輯 AND 運算子。 相當於 &&。

  • and(true, false) -> false
  • true && false -> false

approxDistinctCount

approxDistinctCount(<value1> : any, [ <value2> : double ]) => long

取得資料行相異值的近似彙總計數。 選擇性的第二個參數是控制估計錯誤。

  • approxDistinctCount(ProductID, .05) => long

array

array([<value1> : any], ...) => array

建立項目陣列。 所有項目都應該是相同的類型。 如果未指定任何項目,則預設值為空字串陣列。 相當於 [] 建立運算子。

  • array('Seattle', 'Washington')
  • ['Seattle', 'Washington']
  • ['Seattle', 'Washington'][1]
  • 'Washington'

ascii

ascii(<Input> : string) => number

傳回輸入字元的數值。 如果輸入字串有多個字元,則會傳回第一個字元的數值

  • ascii('A') -> 65
  • ascii('a') -> 97

asin

asin(<value1> : number) => double

計算反正弦值。

  • asin(0) -> 0.0

assertErrorMessages

assertErrorMessages() => map

傳回資料列的所有錯誤訊息對應,其判斷提示識別碼為索引鍵。

範例

  • assertErrorMessages() => ['assert1': 'This row failed on assert1.', 'assert2': 'This row failed on assert2.']. In this example, at(assertErrorMessages(), 'assert1') would return 'This row failed on assert1.'

associate

reassociate(<value1> : map, <value2> : binaryFunction) => map

建立索引鍵/值的對應。 所有索引鍵和值都應該為相同類型。 如果未指定任何項目,則會預設為字串與字串類型的對應。 相當於[ -> ]建立運算子。 索引鍵和值應該能彼此替代。

  • associate('fruit', 'apple', 'vegetable', 'carrot' )=> ['fruit' -> 'apple', 'vegetable' -> 'carrot']

at

at(<value1> : array/map, <value2> : integer/key type) => array

尋找陣列索引的元素。 以 1 起始的索引。 超出索引範圍會產生 Null 值。 在指定索引鍵的對應中尋找值。 如果找不到索引鍵,會傳回 Null。

  • at(['apples', 'pears'], 1) => 'apples'
  • at(['fruit' -> 'apples', 'vegetable' -> 'carrot'], 'fruit') => 'apples'

atan

atan(<value1> : number) => double

計算反正切值。

  • atan(0) -> 0.0

atan2

atan2(<value1> : number, <value2> : number) => double

傳回平面的正 X 軸與座標指定點之間的角度 (以弧度為單位)。

  • atan2(0, 0) -> 0.0

avg

avg(<value1> : number) => number

取得資料行的平均值。

  • avg(sales)

avgIf

avgIf(<value1> : boolean, <value2> : number) => number

根據條件取得資料行的平均值。

  • avgIf(region == 'West', sales)

B

between

between(<value1> : any, <value2> : any, <value3> : any) => boolean

檢查第一個值是否內含在兩個其他值之間。 可以比較數值、字串和日期時間值

  • between(10, 5, 24)
  • true
  • between(currentDate(), currentDate() + 10, currentDate() + 20)
  • false

bitwiseAnd

bitwiseAnd(<value1> : integral, <value2> : integral) => integral

整數類型的位元 And 運算子。 相當於 & 運算子

  • bitwiseAnd(0xf4, 0xef)
  • 0xe4
  • (0xf4 & 0xef)
  • 0xe4

bitwiseOr

bitwiseOr(<value1> : integral, <value2> : integral) => integral

整數類型的位元 Or 運算子。 相當於 | 運算子

  • bitwiseOr(0xf4, 0xef)
  • 0xff
  • (0xf4 | 0xef)
  • 0xff

bitwiseXor

bitwiseXor(<value1> : any, <value2> : any) => any

整數類型的位元 Or 運算子。 相當於 | 運算子

  • bitwiseXor(0xf4, 0xef)
  • 0x1b
  • (0xf4 ^ 0xef)
  • 0x1b
  • (true ^ false)
  • true
  • (true ^ true)
  • false

blake2b

blake2b(<value1> : integer, <value2> : any, ...) => string

以指定的位元長度為不同基本資料類型的一組資料行計算 Blake2 摘要,值只能是 8 與 512 之間 8 的倍數。 這可以用來計算資料列的指紋

  • blake2b(256, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4'))
  • 'c9521a5080d8da30dffb430c50ce253c345cc4c4effc315dab2162dac974711d'

blake2bBinary

blake2bBinary(<value1> : integer, <value2> : any, ...) => binary

以指定的位元長度為不同基本資料類型的一組資料行計算 Blake2 摘要,值只能是 8 與 512 之間 8 的倍數。 這可以用來計算資料列的指紋

  • blake2bBinary(256, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4'))
  • unHex('c9521a5080d8da30dffb430c50ce253c345cc4c4effc315dab2162dac974711d')

byItem

byItem(<parent column> : any, <column name> : string) => any

在結構或結構陣列內尋找子項目。 如有多個相符項目,則傳回第一個相符項目。 如果沒有相符項目,則會傳回 Null 值。 傳回的值必須是由其中一個類型轉換動作 (? date、? string...) 所轉換的類型。在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換

  • byItem( byName('customer'), 'orderItems') ? (itemName as string, itemQty as integer)
  • byItem( byItem( byName('customer'), 'orderItems'), 'itemName') ? string

byName

byName(<column name> : string, [<stream name> : string]) => any

依名稱選取資料流中的資料行值。 您可以傳遞選擇性資料流名稱作為第二個引數。 如有多個相符項目,則傳回第一個相符項目。 如果沒有相符項目,則會傳回 Null 值。 傳回的值必須是由其中一個類型轉換函數 (TO_DATE、TO_STRING ...) 所轉換的類型。在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換。

  • toString(byName('parent'))
  • toLong(byName('income'))
  • toBoolean(byName('foster'))
  • toLong(byName($debtCol))
  • toString(byName('Bogus Column'))
  • toString(byName('Bogus Column', 'DeriveStream'))

byNames

byNames(<column names> : array, [<stream name> : string]) => any

在資料流中依名稱選取資料行陣列。 您可以傳遞選擇性資料流名稱作為第二個引數。 如有多個相符項目,則傳回第一個相符項目。 如果資料行沒有相符項目,則整個輸出會是 NULL 值。 所傳回的值需要類型轉換函數 (toDate、toString...)。在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換。

  • toString(byNames(['parent', 'child']))
  • byNames(['parent']) ? string
  • toLong(byNames(['income']))
  • byNames(['income']) ? long
  • toBoolean(byNames(['foster']))
  • toLong(byNames($debtCols))
  • toString(byNames(['a Column']))
  • toString(byNames(['a Column'], 'DeriveStream'))
  • byNames(['orderItem']) ? (itemName as string, itemQty as integer)

byOrigin

byOrigin(<column name> : string, [<origin stream name> : string]) => any

依名稱選取原始資料流中的資料行值。 第二個引數是原始資料流名稱。 如有多個相符項目,則傳回第一個相符項目。 如果沒有相符項目,則會傳回 Null 值。 傳回的值必須是由其中一個類型轉換函數 (TO_DATE、TO_STRING ...) 所轉換的類型。在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換。

  • toString(byOrigin('ancestor', 'ancestorStream'))

byOrigins

byOrigins(<column names> : array, [<origin stream name> : string]) => any

在資料流中依名稱選取資料行陣列。 第二個引數是其源自的資料流。 如有多個相符項目,則傳回第一個相符項目。 如果沒有相符項目,則會傳回 Null 值。 傳回的值必須是由其中一個類型轉換函數 (TO_DATE、TO_STRING...) 所轉換的類型在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換。

  • toString(byOrigins(['ancestor1', 'ancestor2'], 'ancestorStream'))

byPath

byPath(<value1> : string, [<streamName> : string]) => any

依名稱在資料流中尋找階層式路徑。 您可以傳遞選擇性資料流名稱作為第二個引數。 如果找不到這類路徑,則會傳回 Null。 在設計階段已知的資料行名稱/路徑,應該只依據其名稱或點標記法路徑來處理。 不支援計算的輸入,但您可使用參數替換。

  • byPath('grandpa.parent.child') => column

byPosition

byPosition(<position> : integer) => any

依其在資料流中的相對位置 (從 1 開始) 來選取資料行值。 如果位置超出範圍,則會傳回 NULL 值。 傳回的值必須是由其中一個類型轉換函數 (TO_DATE、TO_STRING...) 所轉換的類型不支援計算的輸入,但您可使用參數替換。

  • toString(byPosition(1))
  • toDecimal(byPosition(2), 10, 2)
  • toBoolean(byName(4))
  • toString(byName($colName))
  • toString(byPosition(1234))

C

case

case(<condition> : boolean, <true_expression> : any, <false_expression> : any, ...) => any

根據替代條件套用一個值或另一個值。 如果輸入偶數個項目,則最後一個條件的另一個值預設為 NULL。

  • case(10 + 20 == 30, 'dumbo', 'gumbo') -> 'dumbo'
  • case(10 + 20 == 25, 'bojjus', 'do' < 'go', 'gunchus') -> 'gunchus'
  • isNull(case(10 + 20 == 25, 'bojjus', 'do' > 'go', 'gunchus')) -> true
  • case(10 + 20 == 25, 'bojjus', 'do' > 'go', 'gunchus', 'dumbo') -> 'dumbo'

cbrt

cbrt(<value1> : number) => double

計算數字的立方根。

  • cbrt(8) -> 2.0

ceil

ceil(<value1> : number) => number

傳回不小於某數字的最小整數。

  • ceil(-0.1) -> 0

char

char(<Input> : number) => string

傳回輸入數字所代表的 ascii 字元。 如果數字大於 256,則結果相當於 char (number % 256)

  • char(65) -> 'A'
  • char(97) -> 'a'

coalesce

coalesce(<value1> : any, ...) => any

從一組輸入傳回第一個非 null 值。 所有輸入應該是相同的類型。

  • coalesce(10, 20) -> 10
  • coalesce(toString(null), toString(null), 'dumbo', 'bo', 'go') -> 'dumbo'

collect

collect(<value1> : any) => array

將彙總群組中運算式的所有值收集到陣列中。 在此過程中,可以收集結構並將其轉換成替代結構。 項目數會等於該群組中的資料列數,而且可包含 Null 值。 收集的項目數應該很小。

  • collect(salesPerson)
  • collect(firstName + lastName))
  • collect(@(name = salesPerson, sales = salesAmount) )

collectUnique

collectUnique(<value1> : any) => array

將彙總群組中運算式的所有值收集到唯一陣列中。 在此過程中,可以收集結構並將其轉換成替代結構。 項目數會等於該群組中的資料列數,而且可包含 Null 值。 收集的項目數應該很小。

  • collect(salesPerson)
  • collect(firstName + lastName))
  • collect(@(name = salesPerson, sales = salesAmount) )

columnNames

columnNames(<value1>columnNames( : string, i><value1> : boolean) => array

取得資料流的所有輸出資料行名稱。 您可以傳遞選擇性資料流名稱做為第一個引數。 第二個引數也是選用的,預設值為 false。 如果您將第二個引數設定為 true(),ADF 只會傳回透過結構描述漂移進行漂移的資料行。

  • columnNames()
  • columnNames('DeriveStream')
  • columnNames('DeriveStream', true())
  • columnNames('', true())

columns

columns([<stream name> : string]) => any

取得資料流的所有輸出資料行值。 您可以傳遞選擇性資料流名稱作為第二個引數。

  • columns()
  • columns('DeriveStream')

compare

compare(<value1> : any, <value2> : any) => integer

比較相同類型的兩個值。 如果 value1 < value2,則會傳回負整數,如果 value1 == value2,則會傳回 0,如果 value1 > value2,則會傳回正值。

  • (compare(12, 24) < 1) -> true
  • (compare('dumbo', 'dum') > 0) -> true

concat

concat(<this> : string, <that> : string, ...) => string

將任意數目的字串串連在一起。 相當於 + 運算子加上字串。

  • concat('dataflow', 'is', 'awesome') -> 'dataflowisawesome'
  • 'dataflow' + 'is' + 'awesome' -> 'dataflowisawesome'
  • isNull('sql' + null) -> true

concatWS

concatWS(<separator> : string, <this> : string, <that> : string, ...) => string

以分隔符號將任意數目的字串串連在一起。 第一個參數為分隔符號。

  • concatWS(' ', 'dataflow', 'is', 'awesome') -> 'dataflow is awesome'
  • isNull(concatWS(null, 'dataflow', 'is', 'awesome')) -> true
  • concatWS(' is ', 'dataflow', 'awesome') -> 'dataflow is awesome'

contains

contains(<value1> : array, <value2> : unaryfunction) => boolean

如果所提供陣列中的任何元素在所提供的述詞中評估為 true,則傳回 true。 Contains 預期述詞函式中某個元素的參考為 #item。

  • contains([1, 2, 3, 4], #item == 3) -> true
  • contains([1, 2, 3, 4], #item > 5) -> false

cos

cos(<value1> : number) => double

計算餘弦值。

  • cos(10) -> -0.8390715290764524

cosh

cosh(<value1> : number) => double

計算某值的雙曲餘弦值。

  • cosh(0) -> 1.0

count

count([<value1> : any]) => long

取得值的彙總計數。 如果已指定選用的資料行,則會忽略計數中的 NULL 值。

  • count(custId)
  • count(custId, custName)
  • count()
  • count(iif(isNull(custId), 1, NULL))

countAll

countAll([<value1> : any]) => long

取得值的彙總計數 (包括 Null)。

  • countAll(custId)
  • countAll()

countDistinct

countDistinct(<value1> : any, [<value2> : any], ...) => long

取得一組資料行的相異值彙總計數。

  • countDistinct(custId, custName)

countAllDistinct

countAllDistinct(<value1> : any, [<value2> : any], ...) => long

取得一組資料行相異值的彙總計數 (包括 Null)。

  • countAllDistinct(custId, custName)

countIf

countIf(<value1> : boolean, [<value2> : any]) => long

根據條件取得值的彙總計數。 如果指定了選擇性資料行,則會忽略計數中的 NULL 值。

  • countIf(state == 'CA' && commission < 10000, name)

covariancePopulation

covariancePopulation(<value1> : number, <value2> : number) => double

取得兩個資料行之間的母體共變數。

  • covariancePopulation(sales, profit)

covariancePopulationIf

covariancePopulationIf(<value1> : boolean, <value2> : number, <value3> : number) => double

根據條件取得兩個資料行的母體共變數。

  • covariancePopulationIf(region == 'West', sales)

covarianceSample

covarianceSample(<value1> : number, <value2> : number) => double

取得兩個資料行的樣本共變數。

  • covarianceSample(sales, profit)

covarianceSampleIf

covarianceSampleIf(<value1> : boolean, <value2> : number, <value3> : number) => double

根據條件取得兩個資料行的樣本共變數。

  • covarianceSampleIf(region == 'West', sales, profit)

crc32

crc32(<value1> : any, ...) => long

以指定的位元長度為不同基本資料類型的一組資料行計算 CRC32 雜湊,值只能是 0(256)、224、256、384、512。 這可以用來計算資料列的指紋。

  • crc32(256, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4')) -> 3630253689L

cumeDist

cumeDist() => integer

CumeDist 函式會計算某個值與分割區中所有值的相對位置。 依照分割區的排序,將目前資料列 (含此列) 之前的列數,除以視窗分割區中的總列數,即為結果。 排序中的任何相等值都會評估為相同的位置。

  • cumeDist()

currentDate

currentDate([<value1> : string]) => date

在此作業開始執行時取得目前的日期。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 系統會將資料處理站資料中心/區域的當地時區作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • currentDate() == toDate('2250-12-31') -> false
  • currentDate('PST') == toDate('2250-12-31') -> false
  • currentDate('America/New_York') == toDate('2250-12-31') -> false

currentTimestamp

currentTimestamp() => timestamp

在作業開始執行時,以當地時區為準取得目前的時間戳記。

  • currentTimestamp() == toTimestamp('2250-12-31 12:12:12') -> false

currentUTC

currentUTC([<value1> : string]) => timestamp

取得 UTC 格式的目前時間戳記。 如果您想要將目前時間轉譯成與您的叢集時區不同的時區,可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性時區。 其預設值為目前的時區。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html. 若要將 UTC 時間轉換成不同的時區,請使用 fromUTC()

  • currentUTC() == toTimestamp('2050-12-12 19:18:12') -> false
  • currentUTC() != toTimestamp('2050-12-12 19:18:12') -> true
  • fromUTC(currentUTC(), 'Asia/Seoul') != toTimestamp('2050-12-12 19:18:12') -> true

D

dayOfMonth

dayOfMonth(<value1> : datetime) => integer

取得指定日期是當月第幾天。

  • dayOfMonth(toDate('2018-06-08')) -> 8

dayOfWeek

dayOfWeek(<value1> : datetime) => integer

取得指定日期的星期日期。 1 - 星期日、2 - 星期一...、7 - 星期六。

  • dayOfWeek(toDate('2018-06-08')) -> 6

dayOfYear

dayOfYear(<value1> : datetime) => integer

取得指定日期的年中日期。

  • dayOfYear(toDate('2016-04-09')) -> 100

days

days(<value1> : integer) => long

天數的持續時間 (以毫秒為單位)。

  • days(2) -> 172800000L

decode

decode(<Input> : any, <Charset> : string) => binary

根據指定的字元集將編碼的輸入資料解碼為字串。 第二個 (選擇性) 引數可用來指定要使用哪個字元集 - 'US-ASCII'、'ISO-8859-1'、'UTF-8' (預設值)、'UTF-16BE'、'UTF-16LE'、'UTF-16'

  • decode(array(toByte(97),toByte(98),toByte(99)), 'US-ASCII') -> abc

degrees

degrees(<value1> : number) => double

將弧度轉換為度。

  • degrees(3.141592653589793) -> 180

denseRank

denseRank() => integer

在視窗的 order by 子句中指定的值群組中,計算某個值的順位。 依照分割區的排序,將目前資料列 (含此列) 之前的列數加一,即為結果。 這些值不會在序列中產生間距。 即使資料未排序,也可進行密集排名,並且尋找值的變化。

  • denseRank()

distinct

distinct(<value1> : array) => array

從陣列傳回項目的不同集合。

  • distinct([10, 20, 30, 10]) => [10, 20, 30]

divide

divide(<value1> : any, <value2> : any) => any

將數字配對相除。 相當於 / 運算子。

  • divide(20, 10) -> 2
  • 20 / 10 -> 2

dropLeft

dropLeft(<value1> : string, <value2> : integer) => string

移除字串左邊任意數目的字元。 如果要求的置放超過字串的長度,則會傳回空字串。

  • dropLeft('bojjus', 2) => 'jjus'
  • dropLeft('cake', 10) => ''

dropRight

dropRight(<value1> : string, <value2> : integer) => string

移除字串右邊任意數目的字元。 如果要求的置放超過字串的長度,則會傳回空字串。

  • dropRight('bojjus', 2) => 'bojj'
  • dropRight('cake', 10) => ''

E

encode

encode(<Input> : string, <Charset> : string) => binary

根據字元集將輸入字串資料編碼為二進位檔。 第二個 (選擇性) 引數可用來指定要使用哪個字元集 - 'US-ASCII'、'ISO-8859-1'、'UTF-8' (預設值)、'UTF-16BE'、'UTF-16LE'、'UTF-16'

  • encode('abc', 'US-ASCII') -> array(toByte(97),toByte(98),toByte(99))

輸入字串:string, Charset: string) => binary

endsWith

endsWith(<string> : string, <substring to check> : string) => boolean

檢查字串是否以提供的字串結尾。

  • endsWith('dumbo', 'mbo') -> true

equals

equals(<value1> : any, <value2> : any) => boolean

「等於」比較運算子。 相當於 == 運算子。

  • equals(12, 24) -> false
  • 12 == 24 -> false
  • 'bad' == 'bad' -> true
  • isNull('good' == toString(null)) -> true
  • isNull(null == null) -> true

equalsIgnoreCase

equalsIgnoreCase(<value1> : string, <value2> : string) => boolean

忽略大小寫的「等於」比較運算子。 相當於 <=> 運算子。

  • 'abc'<=>'Abc' -> true
  • equalsIgnoreCase('abc', 'Abc') -> true

escape

escape(<string_to_escape> : string, <format> : string) => string

根據格式逸出字串。 可接受的格式常值是 'json'、'xml'、'ecmascript'、'html'、'java'。


except

except(<value1> : array, <value2> : array) => array

從另一個卸除的重複項傳回一個陣列的差異集合。

  • except([10, 20, 30], [20, 40]) => [10, 30]

expr

expr(<expr> : string) => any

從字串產生運算式。 這與以非常值形式撰寫此運算式相同。 這可用來以字串表示法傳遞參數。

  • expr('price * discount') => any

F

factorial

factorial(<value1> : number) => long

計算數字的階乘。

  • factorial(5) -> 120

false

false() => boolean

一律傳回 false 值。 如果有名為 'false' 的資料行,則使用函式 syntax(false())

  • (10 + 20 > 30) -> false
  • (10 + 20 > 30) -> false()

filter

filter(<value1> : array, <value2> : unaryfunction) => array

從陣列中篩選出不符合所提供述詞的元素。 Filter 預期述詞函式中某個元素的參考為 #item。

  • filter([1, 2, 3, 4], #item > 2) -> [3, 4]
  • filter(['a', 'b', 'c', 'd'], #item == 'a' || #item == 'b') -> ['a', 'b']

find

find(<value1> : array, <value2> : unaryfunction) => any

從符合條件的陣列中尋找第一個項目。 它會採用篩選函式,您可以在其中以 #item 處理陣列中的項目。 如需深度巢狀對應,您可以使用 #item_n(#item_1, #item_2...) 標記法來參考上層對應。

  • find([10, 20, 30], #item > 10) -> 20
  • find(['azure', 'data', 'factory'], length(#item) > 4) -> 'azure'
  • find([ @( name = 'Daniel', types = [ @(mood = 'jovial', behavior = 'terrific'), @(mood = 'grumpy', behavior = 'bad') ] ), @( name = 'Mark', types = [ @(mood = 'happy', behavior = 'awesome'), @(mood = 'calm', behavior = 'reclusive') ] ) ], contains(#item.types, #item.mood=='happy') /*Filter out the happy kid*/ )
  • @( name = 'Mark', types = [ @(mood = 'happy', behavior = 'awesome'), @(mood = 'calm', behavior = 'reclusive') ] )

first

first(<value1> : any, [<value2> : boolean]) => any

取得資料行群組的第一個值。 如果省略第二個參數 ignoreNulls,則假設為 false。

  • first(sales)
  • first(sales, false)

flatten

flatten(<array> : array, <value2> : array ..., <value2> : boolean) => array

將一或多個陣列壓平合併成單一陣列。 會原封不動傳回不可部分完成項目的陣列。 最後一個引數是選用的,預設為 false,以遞迴方式壓平合併超過一層深度。

  • flatten([['bojjus', 'girl'], ['gunchus', 'boy']]) => ['bojjus', 'girl', 'gunchus', 'boy']
  • flatten([[['bojjus', 'gunchus']]] , true) => ['bojjus', 'gunchus']

floor

floor(<value1> : number) => number

傳回不大於某數字的最大整數。

  • floor(-0.1) -> -1

fromBase64

fromBase64(<value1> : string, <encoding type> : string) => string

解碼指定的 base64 編碼字串。 您可以選擇性地傳遞編碼類型。

  • fromBase64('Z3VuY2h1cw==') -> 'gunchus'
  • fromBase64('SGVsbG8gV29ybGQ=', 'Windows-1252') -> 'Hello World'

fromUTC

fromUTC(<value1> : timestamp, [<value2> : string]) => timestamp

從 UTC 轉換成時間戳記。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的形式選擇性傳遞時區。 其預設值為目前的時區。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • fromUTC(currentTimestamp()) == toTimestamp('2050-12-12 19:18:12') -> false
  • fromUTC(currentTimestamp(), 'Asia/Seoul') != toTimestamp('2050-12-12 19:18:12') -> true

G

greater

greater(<value1> : any, <value2> : any) => boolean

「大於」比較運算子。 相當於 > 運算子。

  • greater(12, 24) -> false
  • ('dumbo' > 'dum') -> true
  • (toTimestamp('2019-02-05 08:21:34.890', 'yyyy-MM-dd HH:mm:ss.SSS') > toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS')) -> true

greaterOrEqual

greaterOrEqual(<value1> : any, <value2> : any) => boolean

「大於或等於」比較運算子。 相當於 >= 運算子。

  • greaterOrEqual(12, 12) -> true
  • ('dumbo' >= 'dum') -> true

greatest

greatest(<value1> : any, ...) => any

傳回值清單中的最大值作為輸入 (跳過 Null 值)。 如果所有輸入皆為 Null,則傳回 Null。

  • greatest(10, 30, 15, 20) -> 30
  • greatest(10, toInteger(null), 20) -> 20
  • greatest(toDate('2010-12-12'), toDate('2011-12-12'), toDate('2000-12-12')) -> toDate('2011-12-12')
  • greatest(toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS'), toTimestamp('2019-02-05 08:21:34.890', 'yyyy-MM-dd HH:mm:ss.SSS')) -> toTimestamp('2019-02-05 08:21:34.890', 'yyyy-MM-dd HH:mm:ss.SSS')

H

hasColumn

hasColumn(<column name> : string, [<stream name> : string]) => boolean

依名稱檢查資料流中的資料行值。 您可以傳遞選擇性資料流名稱作為第二個引數。 在設計階段已知的資料行名稱,應該只依據其名稱來處理。 不支援計算的輸入,但您可使用參數替換。

  • hasColumn('parent')

hasError

hasError([<value1> : string]) => boolean

檢查具有所提供識別碼的判斷提示是否標示為錯誤。

範例

  • hasError('assert1')
  • hasError('assert2')

hasPath

hasPath(<value1> : string, [<streamName> : string]) => boolean

檢查資料流中是否有特定階層式路徑存在。 您可以傳遞選擇性資料流名稱作為第二個引數。 在設計階段已知的資料行名稱/路徑,應該只依據其名稱或點標記法路徑來處理。 不支援計算的輸入,但您可使用參數替換。

  • hasPath('grandpa.parent.child') => boolean

hex

hex(<value1>: binary) => string

傳回二進位值的十六進位字串表示法

  • hex(toBinary([toByte(0x1f), toByte(0xad), toByte(0xbe)])) -> '1fadbe'

hour

hour(<value1> : timestamp, [<value2> : string]) => integer

取得時間戳記的小時值。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 當地時區會作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • hour(toTimestamp('2009-07-30 12:58:59')) -> 12
  • hour(toTimestamp('2009-07-30 12:58:59'), 'PST') -> 12

hours

hours(<value1> : integer) => long

時數的持續時間 (以毫秒為單位)。

  • hours(2) -> 7200000L

I

iif

iif(<condition> : boolean, <true_expression> : any, [<false_expression> : any]) => any

根據條件套用一個值或另一個值。 如果未指定其他值,則會將其視為 NULL。 這兩個值必須相容 (數字、字串...)。

  • iif(10 + 20 == 30, 'dumbo', 'gumbo') -> 'dumbo'
  • iif(10 > 30, 'dumbo', 'gumbo') -> 'gumbo'
  • iif(month(toDate('2018-12-01')) == 12, 345.12, 102.67) -> 345.12

iifNull

iifNull(<value1> : any, [<value2> : any], ...) => any

假設有兩個或多個輸入,則會傳回第一個非 Null 項目。 此函式相當於 coalesce。

  • iifNull(10, 20) -> 10
  • iifNull(null, 20, 40) -> 20
  • iifNull('azure', 'data', 'factory') -> 'azure'
  • iifNull(null, 'data', 'factory') -> 'data'

in

in(<array of items> : array, <item to find> : any) => boolean

檢查陣列中是否有某個項目。

  • in([10, 20, 30], 10) -> true
  • in(['good', 'kid'], 'bad') -> false

initCap

initCap(<value1> : string) => string

將每個單字的第一個字母轉換成大寫。 多個單字會以空格分隔。

  • initCap('cool iceCREAM') -> 'Cool Icecream'

instr

instr(<string> : string, <substring to find> : string) => integer

尋找子字串在字串中的位置 (從 1 開始)。 如果找不到,則傳回 0。

  • instr('dumbo', 'mbo') -> 3
  • instr('microsoft', 'o') -> 5
  • instr('good', 'bad') -> 0

intersect

intersect(<value1> : array, <value2> : array) => array

傳回 2 個陣列中不同項目的交集集合。

  • intersect([10, 20, 30], [20, 40]) => [20]

isBitSet

isBitSet (<value1> : array, <value2>:integer ) => boolean

檢查此 bitset 中是否已設定位元位置

  • isBitSet(toBitSet([10, 32, 98]), 10) => true

isBoolean

isBoolean(<value1>: string) => boolean

根據 toBoolean() 規則,檢查字串值是否為布林值

  • isBoolean('true') -> true
  • isBoolean('no') -> true
  • isBoolean('microsoft') -> false

isByte

isByte(<value1> : string) => boolean

根據 toByte() 規則,檢查字串值是否為已知選用格式的值

  • isByte('123') -> true
  • isByte('chocolate') -> false

isDate

isDate (<value1> : string, [<format>: string]) => boolean

使用選擇性輸入日期格式,檢查輸入日期字串是否為日期。 如需可用的格式,請參閱 Java 的 SimpleDateFormat。 如果省略輸入日期格式,則預設格式為 yyyy-[M]M-[d]d。 接受的格式為 [ yyyy, yyyy-[M]M, yyyy-[M]M-[d]d, yyyy-[M]M-[d]dT* ]

  • isDate('2012-8-18') -> true
  • isDate('12/18--234234' -> 'MM/dd/yyyy') -> false

isDecimal

isDecimal (<value1> : string) => boolean

根據 toDecimal() 規則,檢查字串值是否為已知選用格式的小數值

  • isDecimal('123.45') -> true
  • isDecimal('12/12/2000') -> false

isDelete

isDelete([<value1> : integer]) => boolean

檢查資料列是否有刪除標示。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isDelete()
  • isDelete(1)

isDistinct

isDistinct(<value1> : any , <value1> : any) => boolean

尋找資料行或一組資料行是否相異。 它不會將 Null 視為相異值

  • isDistinct(custId, custName) => boolean

isDouble

isDouble (<value1> : string, [<format>: string]) => boolean

根據 toDouble() 規則,檢查字串值是否為已知選用格式的雙精確度值

  • isDouble('123') -> true
  • isDouble('$123.45' -> '$###.00') -> true
  • isDouble('icecream') -> false

isError

isError([<value1> : integer]) => boolean

檢查資料列是否標示為錯誤。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isError()
  • isError(1)

isFloat

isFloat (<value1> : string, [<format>: string]) => boolean

根據 toFloat() 規則,檢查字串值是否為已知選用格式的浮點值

  • isFloat('123') -> true
  • isFloat('$123.45' -> '$###.00') -> true
  • isFloat('icecream') -> false

isIgnore

isIgnore([<value1> : integer]) => boolean

檢查資料列是否標示為要忽略。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isIgnore()
  • isIgnore(1)

isInsert

isInsert([<value1> : integer]) => boolean

檢查資料列是否有插入標示。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isInsert()
  • isInsert(1)

isInteger

isInteger (<value1> : string, [<format>: string]) => boolean

根據 toInteger() 規則,檢查字串值是否為已知選用格式的整數值

  • isInteger('123') -> true
  • isInteger('$123' -> '$###') -> true
  • isInteger('microsoft') -> false

isLong

isLong (<value1> : string, [<format>: string]) => boolean

根據 toLong() 規則,檢查字串值是否為已知選用格式的長數值

  • isLong('123') -> true
  • isLong('$123' -> '$###') -> true
  • isLong('gunchus') -> false

isMatch

isMatch([<value1> : integer]) => boolean

檢查在查閱時是否比對資料列。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isMatch()
  • isMatch(1)

isNan

isNan (<value1> : integral) => boolean

檢查這是否為數字。

  • isNan(10.2) => false

isNull

isNull(<value1> : any) => boolean

檢查值是否為 NULL。

  • isNull(NULL()) -> true
  • isNull('') -> false

isShort

isShort (<value1> : string, [<format>: string]) => boolean

根據 toShort() 規則,檢查字串值是否為已知選用格式的短數值

  • isShort('123') -> true
  • isShort('$123' -> '$###') -> true
  • isShort('microsoft') -> false

isTimestamp

isTimestamp (<value1> : string, [<format>: string]) => boolean

使用選用輸入時間戳記格式,檢查輸入日期字串是否為時間戳記。 如需可用的格式,請參閱 Java 的 SimpleDateFormat。 如果省略時間戳記,則會使用預設模式 yyyy-[M]M-[d]d hh:mm:ss[.f...]。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 時間戳記支援的精確度最多到毫秒,值為 999。請參閱 Java 的 SimpleDateFormat,以了解可用格式。

  • isTimestamp('2016-12-31 00:12:00') -> true
  • isTimestamp('2016-12-31T00:12:00' -> 'yyyy-MM-dd\\'T\\'HH:mm:ss' -> 'PST') -> true
  • isTimestamp('2012-8222.18') -> false

isUpdate

isUpdate([<value1> : integer]) => boolean

檢查資料列是否有更新標示。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isUpdate()
  • isUpdate(1)

isUpsert

isUpsert([<value1> : integer]) => boolean

檢查資料列是否有插入標示。 對於取用多個輸入資料流的轉換,您可傳遞資料流 (從 1 開始) 的索引。 資料流索引應為 1 或 2,且預設值為 1。

  • isUpsert()
  • isUpsert(1)

J

jaroWinkler

jaroWinkler(<value1> : string, <value2> : string) => double

取得兩個字串之間的 JaroWinkler 距離。

  • jaroWinkler('frog', 'frog') => 1.0

K

keyValues

keyValues(<value1> : array, <value2> : array) => map

建立索引鍵/值的對應。 第一個參數是索引鍵的陣列,第二個則是值的陣列。 這兩個陣列的長度應該相等。

  • keyValues(['bojjus', 'appa'], ['gunchus', 'ammi']) => ['bojjus' -> 'gunchus', 'appa' -> 'ammi']

kurtosis

kurtosis(<value1> : number) => double

取得資料行的峰態。

  • kurtosis(sales)

kurtosisIf

kurtosisIf(<value1> : boolean, <value2> : number) => double

根據準則,取得資料行的峰態。

  • kurtosisIf(region == 'West', sales)

L

lag

lag(<value> : any, [<number of rows to look before> : number], [<default value> : any]) => any

取得第一個參數對目前資料列之前的 n 個資料列評估的值。 第二個參數是要回溯查看的資料列數目,預設值為 1。 如果沒有那麼多資料列,則會傳回 Null 值,除非已指定預設值。

  • lag(amount, 2)
  • lag(amount, 2000, 100)

last

last(<value1> : any, [<value2> : boolean]) => any

取得資料行群組的最後一個值。 如果省略第二個參數 ignoreNulls,則假設為 false。

  • last(sales)
  • last(sales, false)

lastDayOfMonth

lastDayOfMonth(<value1> : datetime) => date

取得指定日期的最後一個月中日期。

  • lastDayOfMonth(toDate('2009-01-12')) -> toDate('2009-01-31')

lead

lead(<value> : any, [<number of rows to look after> : number], [<default value> : any]) => any

取得第一個參數對目前資料列之後的 n 個資料列評估的值。 第二個參數是要正向查看的資料列數目,預設值為 1。 如果沒有那麼多資料列,則會傳回 Null 值,除非已指定預設值。

  • lead(amount, 2)
  • lead(amount, 2000, 100)

least

least(<value1> : any, ...) => any

「小於或等於」比較運算子。 相當於 <= 運算子。

  • least(10, 30, 15, 20) -> 10
  • least(toDate('2010-12-12'), toDate('2011-12-12'), toDate('2000-12-12')) -> toDate('2000-12-12')

left

left(<string to subset> : string, <number of characters> : integral) => string

從索引 1 處開始擷取含特定字元數的子字串。 相當於 SUBSTRING(str, 1, n)。

  • left('bojjus', 2) -> 'bo'
  • left('bojjus', 20) -> 'bojjus'

length

length(<value1> : string) => integer

傳回字串的長度。

  • length('dumbo') -> 5

lesser

lesser(<value1> : any, <value2> : any) => boolean

「小於」比較運算子。 相當於 < 運算子。

  • lesser(12, 24) -> true
  • ('abcd' < 'abc') -> false
  • (toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS') < toTimestamp('2019-02-05 08:21:34.890', 'yyyy-MM-dd HH:mm:ss.SSS')) -> true

lesserOrEqual

lesserOrEqual(<value1> : any, <value2> : any) => boolean

「小於或等於」比較運算子。 相當於 <= 運算子。

  • lesserOrEqual(12, 12) -> true
  • ('dumbo' <= 'dum') -> false

levenshtein

levenshtein(<from string> : string, <to string> : string) => integer

取得兩個字串之間的 levenshtein 距離。

  • levenshtein('boys', 'girls') -> 4

like

like(<string> : string, <pattern match> : string) => boolean

此模式是字面上相符的字串。 例外狀況是下列特殊符號:_ 會比對輸入中的任何一個字元 (類似 posix 規則運算式中的 . ) % 會比對輸入中的零或多個字元 (類似 posix 規則運算式中的 .* )。 逸出字元為 ''。 如果特殊符號或另一個逸出字元前面有逸出字元,就會逐字比對下列字元。 逸出任何其他字元的動作是無效的。

  • like('icecream', 'ice%') -> true

locate

locate(<substring to find> : string, <string> : string, [<from index - 1-based> : integral]) => integer

尋找子字串在字串中從特定位置起算的位置 (從 1 開始)。 如果省略位置,則視為字串的開頭。 如果找不到,則傳回 0。

  • locate('mbo', 'dumbo') -> 3
  • locate('o', 'microsoft', 6) -> 7
  • locate('bad', 'good') -> 0

log

log(<value1> : number, [<value2> : number]) => double

計算對數值。 可以提供選擇性的底數,否則使用歐拉數。

  • log(100, 10) -> 2

log10

log10(<value1> : number) => double

計算以 10 為底數的對數值。

  • log10(100) -> 2

lookup

lookup(key, key2, ...) => complex[]

使用符合快取接收索引鍵的指定索引鍵,從快取接收查詢第一個資料列。

  • cacheSink#lookup(movieId)

lower

lower(<value1> : string) => string

將字串變成小寫。

  • lower('GunChus') -> 'gunchus'

lpad

lpad(<string to pad> : string, <final padded length> : integral, <padding> : string) => string

從左側為字串填補提供的填補內容,直到達到特定長度。 如果字串大於或等於該長度,則會修剪為該長度。

  • lpad('dumbo', 10, '-') -> '-----dumbo'
  • lpad('dumbo', 4, '-') -> 'dumb'

ltrim

ltrim(<string to trim> : string, [<trim characters> : string]) => string

從左側修剪開頭字元的字串。 若未指定第二個參數,則會修剪空白字元。 否則會修剪第二個參數中指定的任何字元。

  • ltrim(' dumbo ') -> 'dumbo '
  • ltrim('!--!du!mbo!', '-!') -> 'du!mbo!'

map

map(<value1> : array, <value2> : unaryfunction) => any

使用所提供的運算式,將陣列的每個元素對應至新的元素。 Map 預期運算式函式中某個元素的參考為 #item。

  • map([1, 2, 3, 4], #item + 2) -> [3, 4, 5, 6]
  • map(['a', 'b', 'c', 'd'], #item + '_processed') -> ['a_processed', 'b_processed', 'c_processed', 'd_processed']

mapAssociation

mapAssociation(<value1> : map, <value2> : binaryFunction) => array

將索引鍵與新值建立關聯,藉以轉換對應。 傳回陣列。 它會採用對應函式,您可以在其中以 #key 處理項目,並以 #key 處理目前的值。

  • mapAssociation(['bojjus' -> 'gunchus', 'appa' -> 'ammi'], @(key = #key, value = #value)) => [@(key = 'bojjus', value = 'gunchus'), @(key = 'appa', value = 'ammi')]

mapIf

mapIf (<value1> : array, <value2> : binaryfunction, <value3>: binaryFunction) => any

有條件地將陣列對應至長度相同或較短的另一個陣列。 這些值可以是任何資料類型,包括 structTypes 在內。 它會採用對應函式,您可以在其中以 #item 處理陣列中的項目,並以 #index 處理目前索引。 如需深度巢狀對應,您可以使用 #item_[n](#item_1, #index_1...) 標記法來參考上層對應。

  • mapIf([10, 20, 30], #item > 10, #item + 5) -> [25, 35]
  • mapIf(['icecream', 'cake', 'soda'], length(#item) > 4, upper(#item)) -> ['ICECREAM', 'CAKE']

mapIndex

mapIndex(<value1> : array, <value2> : binaryfunction) => any

使用所提供的運算式,將陣列的每個元素對應至新的元素。 Map 預期運算式函式中某個元素的參考為 #item,而元素索引的參考為 #index。

  • mapIndex([1, 2, 3, 4], #item + 2 + #index) -> [4, 6, 8, 10]

mapLoop

mapLoop(<value1> : integer, <value2> : unaryfunction) => any

透過從 1 到長度的迴圈,建立該長度的陣列。 它會採用對應函式,您可以在其中以 #index 稱呼陣列中的索引。 如需深度巢狀對應,您可以使用 #index_n(#index_1, #index_2...) 標記法來參考上層對應。

  • mapLoop(3, #index * 10) -> [10, 20, 30]

max

max(<value1> : any) => any

取得資料行的最大值。

  • max(sales)

maxIf

maxIf(<value1> : boolean, <value2> : any) => any

根據準則,取得資料行的最大值。

  • maxIf(region == 'West', sales)

md5

md5(<value1> : any, ...) => string

為不同基本資料類型的一組資料行計算 MD5 摘要,並傳回 32 個字元的十六進位字串。 這可以用來計算資料列的指紋。

  • md5(5, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4')) -> '4ce8a880bd621a1ffad0bca905e1bc5a'

mean

mean(<value1> : number) => number

取得資料行的平均值。 相當於 AVG。

  • mean(sales)

meanIf

meanIf(<value1> : boolean, <value2> : number) => number

根據條件取得資料行的平均值。 相當於 avgIf。

  • meanIf(region == 'West', sales)

millisecond

millisecond(<value1> : timestamp, [<value2> : string]) => integer

取得日期的毫秒值。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 當地時區會作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • millisecond(toTimestamp('2009-07-30 12:58:59.871', 'yyyy-MM-dd HH:mm:ss.SSS')) -> 871

milliseconds

milliseconds(<value1> : integer) => long

毫秒數的持續時間 (以毫秒為單位)。

  • milliseconds(2) -> 2L

min

min(<value1> : any) => any

取得資料行的最小值。

  • min(sales)

minIf

minIf(<value1> : boolean, <value2> : any) => any

根據準則,取得資料行的最小值。

  • minIf(region == 'West', sales)

minus

minus(<value1> : any, <value2> : any) => any

減去數字。 從日期中減去天數。 從時間戳記減去持續時間。 減去兩個時間戳記來取得差異 (以毫秒為單位)。 相當於 - 運算子。

  • minus(20, 10) -> 10
  • 20 - 10 -> 10
  • minus(toDate('2012-12-15'), 3) -> toDate('2012-12-12')
  • toDate('2012-12-15') - 3 -> toDate('2012-12-12')
  • toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS') + (days(1) + hours(2) - seconds(10)) -> toTimestamp('2019-02-04 07:19:18.871', 'yyyy-MM-dd HH:mm:ss.SSS')
  • toTimestamp('2019-02-03 05:21:34.851', 'yyyy-MM-dd HH:mm:ss.SSS') - toTimestamp('2019-02-03 05:21:36.923', 'yyyy-MM-dd HH:mm:ss.SSS') -> -2072

minute

minute(<value1> : timestamp, [<value2> : string]) => integer

取得時間戳記的分鐘值。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 當地時區會作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • minute(toTimestamp('2009-07-30 12:58:59')) -> 58
  • minute(toTimestamp('2009-07-30 12:58:59'), 'PST') -> 58

minutes

minutes(<value1> : integer) => long

分鐘數的持續時間 (以毫秒為單位)。

  • minutes(2) -> 120000L

mlookup

mlookup(key, key2, ...) => complex[]

使用符合快取接收索引鍵的指定索引鍵,從快取接收查詢所有相符的資料列。

  • cacheSink#mlookup(movieId)

mod

mod(<value1> : any, <value2> : any) => any

數字配對的模數。 相當於 % 運算子。

  • mod(20, 8) -> 4
  • 20 % 8 -> 4

month

month(<value1> : datetime) => integer

取得日期或時間戳記的月份值。

  • month(toDate('2012-8-8')) -> 8

monthsBetween

monthsBetween(<from date/timestamp> : datetime, <to date/timestamp> : datetime, [<roundoff> : boolean], [<time zone> : string]) => double

取得兩個日期之間的月數。 您可以四捨五入計算。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 當地時區會作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • monthsBetween(toTimestamp('1997-02-28 10:30:00'), toDate('1996-10-30')) -> 3.94959677

multiply

multiply(<value1> : any, <value2> : any) => any

將數字配對相乘。 相當於 * 運算子。

  • multiply(20, 10) -> 200
  • 20 * 10 -> 200

negate

negate(<value1> : number) => number

將數字轉換為負數。 將正數轉換為負數,或反向轉換。

  • negate(13) -> -13

nextSequence

nextSequence() => long

傳回下一個唯一序列。 數字在分割區內才會連續,且具有 partitionId 前置詞。

  • nextSequence() == 12313112 -> false

normalize

normalize(<String to normalize> : string) => string

將字串值正規化,以區分重音的 unicode 字元。

  • regexReplace(normalize('bo²s'), `\p{M}`, '') -> 'boys'

not

not(<value1> : boolean) => boolean

邏輯負運算子。

  • not(true) -> false
  • not(10 == 20) -> true

notEquals

notEquals(<value1> : any, <value2> : any) => boolean

「不等於」比較運算子。 相當於 != 運算子。

  • 12 != 24 -> true
  • 'bojjus' != 'bo' + 'jjus' -> false

nTile

nTile([<value1> : integer]) => integer

NTile 函式會將每個視窗分割區中的資料列分成 n 個貯體,範圍從 1 到 n。 貯體值的最大差異為 1。 如果分割區中的資料列數目無法平均分成貯體數,其餘值將會逐一均分給各個貯體,從第一個貯體開始。 在計算 tertiles、四分位數、十分位數和其他常見的摘要統計資料時,NTile 函式很有用。 此函數會在初始化期間計算兩個變數:一般貯體的大小將會新增一個額外的資料列。 這兩個變數都是以目前分割區的大小為基礎。 在計算過程中,此函式會追蹤目前的資料列數目、目前的貯體數目,和貯體將有所變更的資料列號碼 (bucketThreshold)。 當目前的資料列數目達到貯體閾值時,貯體值將會加一,而閾值會依貯體大小增加 (如果目前的貯體已填補,則額外再加一)。

  • nTile()
  • nTile(numOfBuckets)

null

null() => null

傳回 NULL 值。 如果有名為「null」的資料行,則使用函數 syntax(null())。 任何使用此函數的作業都將導致 NULL。

  • isNull('dumbo' + null) -> true
  • isNull(10 * null) -> true
  • isNull('') -> false
  • isNull(10 + 20) -> false
  • isNull(10/0) -> true

O

or

or(<value1> : boolean, <value2> : boolean) => boolean

邏輯 OR 運算子。 相當於 ||。

  • or(true, false) -> true
  • true || false -> true

originColumns

originColumns(<streamName> : string) => any

取得建立資料行之來源資料流的所有輸出資料行。 必須以另一個函式括住。

  • array(toString(originColumns('source1')))

output

output() => any

傳回快取接收結果的第一個資料列

  • cacheSink#output()

outputs

output() => any

傳回快取接收結果的整個輸出資料列集

  • cacheSink#outputs()

P

partitionId

partitionId() => integer

傳回輸入資料列所在的目前分割區識別碼。

  • partitionId()

pMod

pMod(<value1> : any, <value2> : any) => any

數字配對的正模數。

  • pmod(-20, 8) -> 4

power

power(<value1> : number, <value2> : number) => double

以一數為底數、另一數為乘冪求值。

  • power(10, 2) -> 100

R

radians

radians(<value1> : number) => double

將度數轉換為弧度

  • radians(180) => 3.141592653589793

random

random(<value1> : integral) => long

傳回資料分割內已知選用種子的亂數。 種子應該是固定值,並搭配使用 partitionId 以產生隨機值

  • random(1) == 1 -> false

rank

rank() => integer

在視窗的 order by 子句中指定的值群組中,計算某個值的順位。 依照分割區的排序,將目前資料列 (含此列) 之前的列數加一,即為結果。 這些值會在序列中產生間距。 即使資料未排序,也可進行密集排名,並且尋找值的變化。

  • rank()

reassociate

reassociate(<value1> : map, <value2> : binaryFunction) => map

將索引鍵與新值建立關聯,藉以轉換對應。 它會採用對應函式,您可以在其中以 #key 處理項目,並以 #key 處理目前的值。

  • reassociate(['fruit' -> 'apple', 'vegetable' -> 'tomato'], substring(#key, 1, 1) + substring(#value, 1, 1)) => ['fruit' -> 'fa', 'vegetable' -> 'vt']

reduce

reduce(<value1> : array, <value2> : any, <value3> : binaryfunction, <value4> : unaryfunction) => any

累加陣列中的元素。 Reduce 預期第一個運算式函式中的累加器和一個元素的參考為 #acc 和 #item,而且其預期所產生的值為要在第二個運算式函式中使用的 #result。

  • toString(reduce(['1', '2', '3', '4'], '0', #acc + #item, #result)) -> '01234'

regexExtract

regexExtract(<string> : string, <regex to find> : string, [<match group 1-based index> : integral]) => string

擷取指定規則運算式模式的相符子字串。 最後一個參數會識別比對群組,如果省略則預設為 1。 使用 <regex> (反引號) 比對字串 (不逸出)。 索引 0 會傳回所有相符項目。 如果沒有相符的群組,索引 1 以上將不會傳回任何結果。

  • regexExtract('Cost is between 600 and 800 dollars', '(\\d+) and (\\d+)', 2) -> '800'
  • regexExtract('Cost is between 600 and 800 dollars', `(\d+) and (\d+)`, 2) -> '800'

regexMatch

regexMatch(<string> : string, <regex to match> : string) => boolean

檢查字串是否符合指定的規則運算式模式。 使用 <regex> (反引號) 比對字串 (不逸出)。

  • regexMatch('200.50', '(\\d+).(\\d+)') -> true
  • regexMatch('200.50', `(\d+).(\d+)`) -> true

regexReplace

regexReplace(<string> : string, <regex to find> : string, <substring to replace> : string) => string

將指定字串中出現的某個規則運算式模式全部取代為另一個 substring。使用 <regex> (反引號) 比對字串 (不逸出)。

  • regexReplace('100 and 200', '(\\d+)', 'bojjus') -> 'bojjus and bojjus'
  • regexReplace('100 and 200', `(\d+)`, 'gunchus') -> 'gunchus and gunchus'

regexSplit

regexSplit(<string to split> : string, <regex expression> : string) => array

根據分隔符號和規則運算式分割字串,並傳回字串陣列。

  • regexSplit('bojjusAgunchusBdumbo', `[CAB]`) -> ['bojjus', 'gunchus', 'dumbo']
  • regexSplit('bojjusAgunchusBdumboC', `[CAB]`) -> ['bojjus', 'gunchus', 'dumbo', '']
  • (regexSplit('bojjusAgunchusBdumboC', `[CAB]`)[1]) -> 'bojjus'
  • isNull(regexSplit('bojjusAgunchusBdumboC', `[CAB]`)[20]) -> true

replace

replace(<string> : string, <substring to find> : string, [<substring to replace> : string]) => string

將指定字串中出現的某個子字串全部取代為另一個子字串。 如果省略最後一個參數,則預設為空字串。

  • replace('doggie dog', 'dog', 'cat') -> 'catgie cat'
  • replace('doggie dog', 'dog', '') -> 'gie '
  • replace('doggie dog', 'dog') -> 'gie '

reverse

reverse(<value1> : string) => string

反轉字串。

  • reverse('gunchus') -> 'suhcnug'

right(<string to subset> : string, <number of characters> : integral) => string

從右側擷取含特定字元數的子字串。 相當於 SUBSTRING(str, LENGTH(str) - n, n)。

  • right('bojjus', 2) -> 'us'
  • right('bojjus', 20) -> 'bojjus'

rlike

rlike(<string> : string, <pattern match> : string) => boolean

檢查字串是否符合指定的規則運算式模式。

  • rlike('200.50', `(\d+).(\d+)`) -> true
  • rlike('bogus', `M[0-9]+.*`) -> false

round

round(<number> : number, [<scale to round> : number], [<rounding option> : integral]) => double

以指定的選擇性小數位數和選擇性的捨入模式將數字捨入進位。 如果省略小數位數,則預設為 0。 如果省略捨入模式,則預設為 ROUND_HALF_UP(5)。 四捨五入的值包括

  1. ROUND_UP - 四捨五入模式,以從零四捨五入。
  2. ROUND_DOWN - 四捨五入模式,以四捨五入為零。
  3. ROUND_CEILING - 四捨五入模式,以四捨五入為無限大的正數。 [如果輸入為正數,則相當於 ROUND_UP。 如果為負數,則相當於 ROUND_DOWN。 例如 = -1.1 在使用 ROUND_CEILING 時是 -1.0,使用 ROUND_UP 時是 -2]
  4. ROUND_FLOOR - 四捨五入模式,以四捨五入為無限大的負數。 [如果輸入為正數,則相當於 ROUND_DOWN。 如果為負數,則相當於 ROUND_UP]
  5. ROUND_HALF_UP - 四捨五入模式,除非兩個鄰近項目相等,否則會四捨五入為「最接近的鄰近項目」,在此情況下為 ROUND_UP。 [資料流程的最常見值 + 預設值]。
  6. ROUND_HALF_DOWN - 四捨五入模式,除非兩個鄰近項目相等,否則會四捨五入為「最接近的鄰近項目」,在此情況下為 ROUND_DOWN。
  7. ROUND_HALF_EVEN - 四捨五入模式,除非兩個鄰近項目相等,否則會四捨五入為「最接近的鄰近項目」,在此情況下,會四捨五入為偶數鄰近項目。
  8. ROUND_UNNECESSARY - 四捨五入模式,以判斷四捨五入運算具有確切的結果,因此不需要四捨五入。
  • round(100.123) -> 100.0
  • round(2.5, 0) -> 3.0
  • round(5.3999999999999995, 2, 7) -> 5.40

rowNumber

rowNumber() => integer

為視窗中的資料列指派循序的資料列編號,從 1 開始。

  • rowNumber()

rpad

rpad(<string to pad> : string, <final padded length> : integral, <padding> : string) => string

從右側為字串填補提供的填補內容,直到達到特定長度。 如果字串大於或等於該長度,則會修剪為該長度。

  • rpad('dumbo', 10, '-') -> 'dumbo-----'
  • rpad('dumbo', 4, '-') -> 'dumb'
  • rpad('dumbo', 8, '<>') -> 'dumbo<><'

rtrim

rtrim(<string to trim> : string, [<trim characters> : string]) => string

從右側修剪後置字元的字串。 若未指定第二個參數,則會修剪空白字元。 否則會修剪第二個參數中指定的任何字元。

  • rtrim(' dumbo ') -> ' dumbo'
  • rtrim('!--!du!mbo!', '-!') -> '!--!du!mbo'

S

second

second(<value1> : timestamp, [<value2> : string]) => integer

取得日期的秒值。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 當地時區會作為預設值。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • second(toTimestamp('2009-07-30 12:58:59')) -> 59

seconds

seconds(<value1> : integer) => long

秒數的持續時間 (以毫秒為單位)。

  • seconds(2) -> 2000L

setBitSet

setBitSet (<value1>: array, <value2>:array) => array

設定此 bitset 中的位元位置

  • setBitSet(toBitSet([10, 32]), [98]) => [4294968320L, 17179869184L]

sha1

sha1(<value1> : any, ...) => string

為不同基本資料類型的一組資料行計算 SHA-1 摘要,並傳回 40 個字元的十六進位字串。 這可以用來計算資料列的指紋。

  • sha1(5, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4')) -> '46d3b478e8ec4e1f3b453ac3d8e59d5854e282bb'

sha2

sha2(<value1> : integer, <value2> : any, ...) => string

以指定的位元長度為不同基本資料類型的一組資料行計算 SHA-2 摘要,值只能是 0(256)、224、256、384、512。 這可以用來計算資料列的指紋。

  • sha2(256, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4')) -> 'afe8a553b1761c67d76f8c31ceef7f71b66a1ee6f4e6d3b5478bf68b47d06bd3'

sin

sin(<value1> : number) => double

計算正弦值。

  • sin(2) -> 0.9092974268256817

sinh

sinh(<value1> : number) => double

計算雙曲正弦值。

  • sinh(0) -> 0.0

size

size(<value1> : any) => integer

尋找陣列或對應類型的大小

  • size(['element1', 'element2']) -> 2
  • size([1,2,3]) -> 3

skewness

skewness(<value1> : number) => double

取得資料行的偏態。

  • skewness(sales)

skewnessIf

skewnessIf(<value1> : boolean, <value2> : number) => double

根據條件取得資料行的偏態。

  • skewnessIf(region == 'West', sales)

slice

slice(<array to slice> : array, <from 1-based index> : integral, [<number of items> : integral]) => array

從某個位置擷取陣列的子集。 位置從 1 開始。 如果省略長度,則預設為字串的結尾處。

  • slice([10, 20, 30, 40], 1, 2) -> [10, 20]
  • slice([10, 20, 30, 40], 2) -> [20, 30, 40]
  • slice([10, 20, 30, 40], 2)[1] -> 20
  • isNull(slice([10, 20, 30, 40], 2)[0]) -> true
  • isNull(slice([10, 20, 30, 40], 2)[20]) -> true
  • slice(['a', 'b', 'c', 'd'], 8) -> []

sort

sort(<value1> : array, <value2> : binaryfunction) => array

使用所提供的述詞函式來排序陣列。 Sort 需要運算式函式中兩個連續元素的參考為 #item1 和 #item2。

  • sort([4, 8, 2, 3], compare(#item1, #item2)) -> [2, 3, 4, 8]
  • sort(['a3', 'b2', 'c1'], iif(right(#item1, 1) >= right(#item2, 1), 1, -1)) -> ['c1', 'b2', 'a3']

soundex

soundex(<value1> : string) => string

取得字串的 soundex 代碼。

  • soundex('genius') -> 'G520'

split

split(<string to split> : string, <split characters> : string) => array

根據分隔符號分割字串,並傳回字串陣列。

  • split('bojjus,guchus,dumbo', ',') -> ['bojjus', 'guchus', 'dumbo']
  • split('bojjus,guchus,dumbo', '|') -> ['bojjus,guchus,dumbo']
  • split('bojjus, guchus, dumbo', ', ') -> ['bojjus', 'guchus', 'dumbo']
  • split('bojjus, guchus, dumbo', ', ')[1] -> 'bojjus'
  • isNull(split('bojjus, guchus, dumbo', ', ')[0]) -> true
  • isNull(split('bojjus, guchus, dumbo', ', ')[20]) -> true
  • split('bojjusguchusdumbo', ',') -> ['bojjusguchusdumbo']

sqrt

sqrt(<value1> : number) => double

計算數字的平方根。

  • sqrt(9) -> 3

startsWith

startsWith(<string> : string, <substring to check> : string) => boolean

檢查字串是否以提供的字串開頭。

  • startsWith('dumbo', 'du') -> true

stddev

stddev(<value1> : number) => double

取得資料行的標準差。

  • stdDev(sales)

stddevIf

stddevIf(<value1> : boolean, <value2> : number) => double

根據準則,取得資料行的標準差。

  • stddevIf(region == 'West', sales)

stddevPopulation

stddevPopulation(<value1> : number) => double

取得資料行的母體標準差。

  • stddevPopulation(sales)

stddevPopulationIf

stddevPopulationIf(<value1> : boolean, <value2> : number) => double

根據條件取得資料行的母體標準差。

  • stddevPopulationIf(region == 'West', sales)

stddevSample

stddevSample(<value1> : number) => double

取得資料行的樣本標準差。

  • stddevSample(sales)

stddevSampleIf

stddevSampleIf(<value1> : boolean, <value2> : number) => double

根據準則,取得資料行的樣本標準差。

  • stddevSampleIf(region == 'West', sales)

subDays

subDays(<date/timestamp> : datetime, <days to subtract> : integral) => datetime

從日期或時間戳記中減去天數。 相當於日期的 - 運算子。

  • subDays(toDate('2016-08-08'), 1) -> toDate('2016-08-07')

subMonths

subMonths(<date/timestamp> : datetime, <months to subtract> : integral) => datetime

從日期或時間戳記中減去月數。

  • subMonths(toDate('2016-09-30'), 1) -> toDate('2016-08-31')

substring

substring(<string to subset> : string, <from 1-based index> : integral, [<number of characters> : integral]) => string

從某個位置擷取特定長度的子字串。 位置從 1 開始。 如果省略長度,則預設為字串的結尾處。

  • substring('Cat in the hat', 5, 2) -> 'in'
  • substring('Cat in the hat', 5, 100) -> 'in the hat'
  • substring('Cat in the hat', 5) -> 'in the hat'
  • substring('Cat in the hat', 100, 100) -> ''

substringIndex

substringIndex(<string to subset><delimiter>substringIndex( : string, : string, <count of delimiter occurences> : integral]) => string

在分隔符號的 count 出現之前擷取子字串。 如果 count 為正數,則會傳回最後一個分隔符號左邊的所有內容 (從左計數)。 如果 count 為負數,則會傳回最後一個分隔符號右邊的所有內容 (從右計數)。

  • substringIndex('111-222-333', '-', 1) -> '111'
  • substringIndex('111-222-333', '-', 2) -> '111-222'
  • substringIndex('111-222-333', '-', -1) -> '333'
  • substringIndex('111-222-333', '-', -2) -> '222-333'

sum

sum(<value1> : number) => number

取得數值資料行的彙總總和。

  • sum(col)

sumDistinct

sumDistinct(<value1> : number) => number

取得數值資料行的相異值彙總總和。

  • sumDistinct(col)

sumDistinctIf

sumDistinctIf(<value1> : boolean, <value2> : number) => number

根據條件取得數值資料行的彙總總和。 條件可依據任何資料行。

  • sumDistinctIf(state == 'CA' && commission < 10000, sales)
  • sumDistinctIf(true, sales)

sumIf

sumIf(<value1> : boolean, <value2> : number) => number

根據條件取得數值資料行的彙總總和。 條件可依據任何資料行。

  • sumIf(state == 'CA' && commission < 10000, sales)
  • sumIf(true, sales)

T

tan

tan(<value1> : number) => double

計算正切值。

  • tan(0) -> 0.0

tanh

tanh(<value1> : number) => double

計算雙曲正切值。

  • tanh(0) -> 0.0

toBase64

toBase64(<value1> : string, <encoding type> : string]) => string

以 base64 編碼指定的字串。 您可以選擇性地傳遞編碼類型

  • toBase64('bojjus') -> 'Ym9qanVz'
  • toBase64('± 25000, € 5.000,- |', 'Windows-1252') -> 'sSAyNTAwMCwggCA1LjAwMCwtIHw='

toBinary

toBinary(<value1> : any) => binary

將任何數值/日期/時間戳記/字串轉換為二進位表示法。

  • toBinary(3) -> [0x11]

toBoolean

toBoolean(<value1> : string) => boolean

將 ('t', 'true', 'y', 'yes', '1') 值轉換為 true,並將 ('f', 'false', 'n', 'no', '0') 值轉換為 false,而任何其他值皆為 NULL。

  • toBoolean('true') -> true
  • toBoolean('n') -> false
  • isNull(toBoolean('truthy')) -> true

toByte

toByte(<value> : any, [<format> : string], [<locale> : string]) => byte

將任何數值或字串轉換為位元組值。 可使用選擇性的 Java 十進位格式進行轉換。

  • toByte(123)
  • 123
  • toByte(0xFF)
  • -1
  • toByte('123')
  • 123

toDate

toDate(<string> : any, [<date format> : string]) => date

使用選擇性輸入日期格式,將輸入日期字串轉換為日期。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 如果省略輸入日期格式,則預設格式為 yyyy-[M]M-[d]d。 接受的格式為:[ yyyy, yyyy-[M]M, yyyy-[M]M-[d]d, yyyy-[M]M-[d]dT* ]。

  • toDate('2012-8-18') -> toDate('2012-08-18')
  • toDate('12/18/2012', 'MM/dd/yyyy') -> toDate('2012-12-18')

toDecimal

toDecimal(<value> : any, [<precision> : integral], [<scale> : integral], [<format> : string], [<locale> : string]) => decimal(10,0)

將任何數值或字串轉換為小數值。 如果未指定精確度和小數位數,則會預設為 (10,2)。 可使用選擇性的 Java 十進位格式進行轉換。 採用 BCP47 語言形式的選擇性地區設定格式,例如 en-US、de、zh-CN。

  • toDecimal(123.45) -> 123.45
  • toDecimal('123.45', 8, 4) -> 123.4500
  • toDecimal('$123.45', 8, 4,'$###.00') -> 123.4500
  • toDecimal('Ç123,45', 10, 2, 'Ç###,##', 'de') -> 123.45

toDouble

toDouble(<value> : any, [<format> : string], [<locale> : string]) => double

將任何數值或字串轉換為雙精準數值。 可使用選擇性的 Java 十進位格式進行轉換。 採用 BCP47 語言形式的選擇性地區設定格式,例如 en-US、de、zh-CN。

  • toDouble(123.45) -> 123.45
  • toDouble('123.45') -> 123.45
  • toDouble('$123.45', '$###.00') -> 123.45
  • toDouble('Ç123,45', 'Ç###,##', 'de') -> 123.45

toFloat

toFloat(<value> : any, [<format> : string], [<locale> : string]) => float

將任何數值或字串轉換為浮點值。 可使用選擇性的 Java 十進位格式進行轉換。 截斷任何 double。

  • toFloat(123.45) -> 123.45f
  • toFloat('123.45') -> 123.45f
  • toFloat('$123.45', '$###.00') -> 123.45f

toInteger

toInteger(<value> : any, [<format> : string], [<locale> : string]) => integer

將任何數值或字串轉換為整數值。 可使用選擇性的 Java 十進位格式進行轉換。 截斷任何長數值、浮點數、雙精確度。

  • toInteger(123) -> 123
  • toInteger('123') -> 123
  • toInteger('$123', '$###') -> 123

toLong

toLong(<value> : any, [<format> : string], [<locale> : string]) => long

將任何數值或字串轉換為長值。 可使用選擇性的 Java 十進位格式進行轉換。 截斷任何浮點數、雙精度浮點數。

  • toLong(123) -> 123
  • toLong('123') -> 123
  • toLong('$123', '$###') -> 123

topN

topN(<column/expression> : any, <count> : long, <n> : integer) => array

根據 count 引數取得這個資料行的前 N 個值。

  • topN(custId, count, 5)
  • topN(productId, num_sales, 10)

toShort

toShort(<value> : any, [<format> : string], [<locale> : string]) => short

將任何數值或字串轉換為短值。 可使用選擇性的 Java 十進位格式進行轉換。 截斷任何整數、長數值、浮點數、雙精確度。

  • toShort(123) -> 123
  • toShort('123') -> 123
  • toShort('$123', '$###') -> 123

toString

toString(<value> : any, [<number format/date format> : string], [<date locale> : string]) => string

將基本資料類型轉換為字串。 針對數字和日期,可以指定格式。 若未指定,則會選擇系統預設值。對於數字會使用 Java 十進位格式。 如需所有可能的日期格式,請參閱 Java SimpleDateFormat。預設格式為 yyyy-mm-dd。 對於日期或時間戳記,可以選擇性地指定地區設定。

  • toString(10) -> '10'
  • toString('engineer') -> 'engineer'
  • toString(123456.789, '##,###.##') -> '123,456.79'
  • toString(123.78, '000000.000') -> '000123.780'
  • toString(12345, '##0.#####E0') -> '12.345E3'
  • toString(toDate('2018-12-31')) -> '2018-12-31'
  • isNull(toString(toDate('2018-12-31', 'MM/dd/yy'))) -> true
  • toString(4 == 20) -> 'false'
  • toString(toDate('12/31/18', 'MM/dd/yy', 'es-ES'), 'MM/dd/yy', 'de-DE')

toTimestamp

toTimestamp(<string> : any, [<timestamp format> : string], [<time zone> : string]) => timestamp

以指定的選擇性時間戳記格式將字串轉換為時間戳記。 如果省略時間戳記,則會使用預設模式 yyyy-[M]M-[d]d hh:mm:ss[.f...]。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 時間戳記支援的精確度高達毫秒,值為 999。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • toTimestamp('2016-12-31 00:12:00') -> toTimestamp('2016-12-31 00:12:00')
  • toTimestamp('2016-12-31T00:12:00', 'yyyy-MM-dd\'T\'HH:mm:ss', 'PST') -> toTimestamp('2016-12-31 00:12:00')
  • toTimestamp('12/31/2016T00:12:00', 'MM/dd/yyyy\'T\'HH:mm:ss') -> toTimestamp('2016-12-31 00:12:00')
  • millisecond(toTimestamp('2019-02-03 05:19:28.871', 'yyyy-MM-dd HH:mm:ss.SSS')) -> 871

toUTC

toUTC(<value1> : timestamp, [<value2> : string]) => timestamp

將時間戳記轉換為 UTC。 您可以用 'GMT'、'PST'、'UTC'、'America/Cayman' 的格式傳遞選擇性的時區。 其預設值為目前的時區。 請參閱 Java 的 SimpleDateFormat 類別,以了解可用的格式。 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

  • toUTC(currentTimestamp()) == toTimestamp('2050-12-12 19:18:12') -> false
  • toUTC(currentTimestamp(), 'Asia/Seoul') != toTimestamp('2050-12-12 19:18:12') -> true

translate

translate(<string to translate> : string, <lookup characters> : string, <replace characters> : string) => string

將字串中的一組字元取代為另一組字元。 字元的取代是 1 對 1。

  • translate('(bojjus)', '()', '[]') -> '[bojjus]'
  • translate('(gunchus)', '()', '[') -> '[gunchus'

trim

trim(<string to trim> : string, [<trim characters> : string]) => string

修剪開頭和結尾字元的字串。 若未指定第二個參數,則會修剪空白字元。 否則會修剪第二個參數中指定的任何字元。

  • trim(' dumbo ') -> 'dumbo'
  • trim('!--!du!mbo!', '-!') -> 'dumbo'

true

true() => boolean

一律傳回 true 值。 如果有名為 'true' 的資料行,則使用函式 syntax(true())

  • (10 + 20 == 30) -> true
  • (10 + 20 == 30) -> true()

typeMatch

typeMatch(<type> : string, <base type> : string) => boolean

比對資料行的類型。 只能在模式運算式中使用。number 會比對出短數值、整數、長數值、雙精確度、浮點數或小數,integral 會比對出短數值、整數、長數值,fractional 會比對出雙精準數、浮點數、小數,datetime 會比對出日期或時間戳記類型。

  • typeMatch(type, 'number')
  • typeMatch('date', 'datetime')

U

unescape

unescape(<string_to_escape> : string, <format> : string) => string

根據格式取消逸出字串。 可接受的格式常值是 'json'、'xml'、'ecmascript'、'html'、'java'。

  • unescape('{\\\\\"value\\\\\": 10}', 'json')
  • '{\\\"value\\\": 10}'

unfold

unfold (<value1>: array) => any

將陣列展開成一組資料列,並重複每個資料列中其餘資料行的值。

  • unfold(addresses) => any
  • unfold( @(name = salesPerson, sales = salesAmount) ) => any

unhex

unhex(<value1>: string) => binary

取消其字串表示法的二進位值。 這可以與 sha2、md5 搭配使用,以從字串轉換成二進位表示法

  • unhex('1fadbe') -> toBinary([toByte(0x1f), toByte(0xad), toByte(0xbe)])
  • unhex(md5(5, 'gunchus', 8.2, 'bojjus', true, toDate('2010-4-4'))) -> toBinary([toByte(0x4c),toByte(0xe8),toByte(0xa8),toByte(0x80),toByte(0xbd),toByte(0x62),toByte(0x1a),toByte(0x1f),toByte(0xfa),toByte(0xd0),toByte(0xbc),toByte(0xa9),toByte(0x05),toByte(0xe1),toByte(0xbc),toByte(0x5a)])

union

union(<value1>: array, <value2> : array) => array

傳回 2 個陣列中不同項目的聯集集合。

  • union([10, 20, 30], [20, 40]) => [10, 20, 30, 40]

upper

upper(<value1> : string) => string

將字串變成大寫。

  • upper('bojjus') -> 'BOJJUS'

uuid

uuid() => string

傳回產生的 UUID。

  • uuid()

V

variance

variance(<value1> : number) => double

取得資料行的變異數。

  • variance(sales)

varianceIf

varianceIf(<value1> : boolean, <value2> : number) => double

根據條件取得資料行的變異數。

  • varianceIf(region == 'West', sales)

variancePopulation

variancePopulation(<value1> : number) => double

取得資料行的母體變異數。

  • variancePopulation(sales)

variancePopulationIf

variancePopulationIf(<value1> : boolean, <value2> : number) => double

根據條件取得資料行的母體變異數。

  • variancePopulationIf(region == 'West', sales)

varianceSample

varianceSample(<value1> : number) => double

取得資料行的無偏變異數。

  • varianceSample(sales)

varianceSampleIf

varianceSampleIf(<value1> : boolean, <value2> : number) => double

根據條件取得資料行的無偏變異數。

  • varianceSampleIf(region == 'West', sales)

星期三

weekOfYear

weekOfYear(<value1> : datetime) => integer

取得指定日期的年中周次。

  • weekOfYear(toDate('2008-02-20')) -> 8

weeks

weeks(<value1> : integer) => long

週數的持續時間 (以毫秒為單位)。

  • weeks(2) -> 1209600000L

X

xor

xor(<value1> : boolean, <value2> : boolean) => boolean

邏輯 XOR 運算子。 相當於 ^ 運算子。

  • xor(true, false) -> true
  • xor(true, true) -> false
  • true ^ false -> true

Y

year

year(<value1> : datetime) => integer

取得日期的年份值。

  • year(toDate('2012-8-8')) -> 2012