napkin-0.5.13
Copyright(c) Soostone Inc 2020
LicenseAllRightsReserved
MaintainerOzgun Ataman
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Napkin.Untyped.Ops.BigQuery

Description

Implements functions defined on functions-and-operators

Synopsis

Documentation

mkMod :: (a -> b) -> Maybe a -> [b] #

arrayConcatAgg #

Arguments

:: SExp 
-> [Order] 
-> Maybe Int

Limit

-> SExp 

corr :: SExp -> SExp -> SExp #

Statistical Aggregate Functions

approxCountDistinct :: SExp -> SExp #

Approximate Aggregate Functions

newtype HLLPrecision #

HyperLogLog++ Functions

Constructors

HLLPrecision 

Fields

rank :: WOver -> SExp #

Analytic (Window) Functions

ntile :: Int -> WOver -> SExp #

lead :: SExp -> Int -> Maybe SExp -> WOver -> SExp #

lag :: SExp -> Int -> Maybe SExp -> WOver -> SExp #

percentileDisc #

Arguments

:: SExp

Value being percentiled

-> Double

Percentile boundary

-> [SExp]

Partition clause

-> Maybe NullStrategy 
-> SExp 

bitCount :: SExp -> SExp #

Bit Functions

type UFunc = SExp -> SExp #

Math Functions

type BinFunc = SExp -> SExp -> SExp #

type NulFunc = SExp #

type MulFunc = [SExp] -> SExp #

roundN :: SExp -> Int -> SExp #

truncN :: Val a => SExp -> a -> SExp #

farmFingerprint :: UFunc #

Hash Functions

byteLength :: UFunc #

String Functions

format :: String -> [SExp] -> SExp #

lpad :: SExp -> Int -> Maybe String -> SExp #

repeat :: Val a => SExp -> a -> SExp #

rpad :: SExp -> Int -> Maybe String -> SExp #

split :: SExp -> Text -> SExp #

strPos :: SExp -> SExp -> SExp #

substr :: SExp -> Int -> Maybe Int -> SExp #

data JSONPath #

JSON Functions

Instances

Instances details
Eq JSONPath # 
Instance details

Defined in Napkin.Untyped.Ops.BigQuery

Ord JSONPath # 
Instance details

Defined in Napkin.Untyped.Ops.BigQuery

Show JSONPath # 
Instance details

Defined in Napkin.Untyped.Ops.BigQuery

toJsonString #

Arguments

:: SExp 
-> Maybe Bool

Pretty print

-> SExp 

arrayConcat :: NonEmpty SExp -> SExp #

Array Functions

arrayToString #

Arguments

:: SExp 
-> String

Delimiter

-> Maybe String

Null text

-> SExp 

generateArray #

Arguments

:: SExp

Start exp

-> SExp

End exp

-> Maybe SExp

Step exp

-> SExp 

offset :: Int -> SExp -> SExp #

ordinal :: Int -> SExp -> SExp #

currentDate :: Maybe String -> SExp #

Date Functions

dateYMD #

Arguments

:: SExp

Year

-> SExp

Month

-> SExp

Day

-> SExp 

dateTimestamp #

Arguments

:: SExp

Timestamp exp

-> Maybe SExp

Timezone exp

-> SExp 

dateAdd #

Arguments

:: SExp

Date expression

-> IntInterval 
-> SExp 

dateSub #

Arguments

:: SExp

Date expression

-> IntInterval 
-> SExp 

dateFromUnixDate #

Arguments

:: SExp

Int64 expr

-> SExp 

formatDate #

Arguments

:: SExp

Format string

-> SExp

Date expr

-> SExp 

parseDate #

Arguments

:: SExp

Format string

-> SExp

Date expr

-> SExp 

unixDate #

Arguments

:: SExp

Date expr

-> SExp 

currentDatetime #

Arguments

:: Maybe SExp

Timezone

-> SExp 

DateTime Functions

dateTimeYMDHMS #

Arguments

:: SExp

Year

-> SExp

Month

-> SExp

Day

-> SExp

Hour

-> SExp

Minute

-> SExp

Second

-> SExp 

dateTimeDateAndTime #

Arguments

:: SExp

Date expression

-> SExp

Time expression

-> SExp 

dateTimeTimestamp #

Arguments

:: SExp

Timestamp expression

-> Maybe SExp

Timezone expression

-> SExp 

dateTimeAdd #

Arguments

:: SExp

Datetime expression

-> IntInterval 
-> SExp 

dateTimeSub #

Arguments

:: SExp

Datetime expression

-> IntInterval 
-> SExp 

formatDateTime #

Arguments

:: SExp

Format string

-> SExp

Datetime expression

-> SExp 

parseDateTime #

Arguments

:: SExp

Format string

-> SExp

Datetime expression

-> SExp 

currentTime :: SExp #

Time Functions

timeHMS #

Arguments

:: SExp

Hour

-> SExp

Minute

-> SExp

Second

-> SExp 

timeTS #

Arguments

:: SExp

Timestamp

-> Maybe SExp

Time zone

-> SExp 

timeAdd #

Arguments

:: SExp

Time expression

-> IntInterval 
-> SExp 

timeSub #

Arguments

:: SExp

Time expression

-> IntInterval 
-> SExp 

bqFormatTime #

Arguments

:: SExp

Format string

-> SExp

Time object

-> SExp 

bqParseTime #

Arguments

:: SExp

Format string

-> SExp

Time object

-> SExp 

currentTimestamp :: SExp #

Timestamp Functions

extract #

Arguments

:: DatePart 
-> SExp

Timestamp expression

-> Maybe SExp

Time zone spec

-> SExp 

string #

Arguments

:: SExp

Timestamp expression

-> Maybe SExp

Time zone

-> SExp 

timestamp #

Arguments

:: SExp

string, date, or datetime expression

-> Maybe SExp

Time zone

-> SExp 

timestampTrunc #

Arguments

:: DatePart 
-> SExp

Timestamp expression

-> Maybe SExp

Time zone

-> SExp 

formatTimestamp #

Arguments

:: SExp

Format string

-> SExp

Timestamp

-> Maybe SExp

Time zone

-> SExp 

parseTimestamp #

Arguments

:: SExp

Format string

-> SExp

Timestamp

-> Maybe SExp

Time zone

-> SExp 

timestampSeconds #

Arguments

:: SExp

Int64 expression

-> SExp 

timestampMillis #

Arguments

:: SExp

Int64 expression

-> SExp 

timestampMicros #

Arguments

:: SExp

Int64 expression

-> SExp 

unixSeconds #

Arguments

:: SExp

Timestamp expression

-> SExp 

unixMillis #

Arguments

:: SExp

Timestamp expression

-> SExp 

unixMicros #

Arguments

:: SExp

Timestamp expression

-> SExp 

sessionUser :: SExp #

Security Functions

netIPFromString #

Arguments

:: SExp

Addr string

-> SExp 

Net Functions

netSafeIPFromString #

Arguments

:: SExp

Addr string

-> SExp 

Like netIPFromString but returns NULL rather than throwing on error.

netIPToString #

Arguments

:: SExp

Addr binary

-> SExp 

netIPNetMask #

Arguments

:: SExp

Num output bytes

-> SExp

Prefix length

-> SExp 

netIPTrunc #

Arguments

:: SExp

Addr binary

-> SExp

Prefix length

-> SExp 

netIPV4FromInt64 #

Arguments

:: SExp 
-> SExp

Addr binary

netIPV4ToInt64 #

Arguments

:: SExp

Addr binary

-> SExp 

netHost #

Arguments

:: SExp

URL

-> SExp 

netPublicSuffix #

Arguments

:: SExp

URL

-> SExp 

netRegDomain #

Arguments

:: SExp

URL

-> SExp 

coalesce :: [SExp] -> SExp #

Conditional Expressions

ifnull #

Arguments

:: SExp

Expressoin

-> SExp

Null result

-> SExp 

nullif #

Arguments

:: SExp

Expression

-> SExp

Expression to match

-> SExp 

like :: SExp -> SExp -> SExp #

Comparison operators

between :: SExp -> SExp -> SExp -> SExp #

scope :: SExp -> SExp -> SExp #

Higher level combinators

scoped :: SExp -> SExp -> SExp #

textInfix :: SExp -> SExp -> SExp #

Is text a contained in text b?

nullIfEmpty :: SExp -> SExp #

Replace empty string with NULL

seekBackIgnoreNulls :: SExp -> Int -> WOver -> SExp #

Use nthValue under the hood with IgnoreNulls, set window frame to start at current row (so nth-value can index) and flip the ordering in given OVER clause so that it semantically behaves like lag but with ignore nulls functionality.

It will start with current row, so setting to 1 will just return current row's value.

seekForwardIgnoreNulls :: SExp -> Int -> WOver -> SExp #

Same deal as lagIgnorenulls but doesn't need to flip the ordering in OVER clause as lead and nthValue both naturally operate in ascending order.

lagIgnoreNulls :: SExp -> Int -> WOver -> SExp #

BigQuery can't ignore nulls while lagging/leading. Use the seekBackignorenulls machinery intelligently to mimic a proper lag with ignore nulls.

percentDiff :: SExp -> SExp -> SExp #

percent difference of a over b with typecast to Double

humanAge :: SExp -> SExp -> SExp #

Calculates the year-based human age given a "current date" and a date in the past. Returns float-based age. DATE_DIFF(CURRENT_DATE, cast('1990-01-01' as date), YEAR) + IF(EXTRACT(DAYOFYEAR FROM CURRENT_DATE) < EXTRACT(DAYOFYEAR FROM cast('1990-01-01' as date)), -1, 0)