Safe Haskell | None |
---|---|
Language | GHC2024 |
Napkin.Untyped.Ops.BigQuery
Synopsis
- windowFn :: Ref Function -> [SExp] -> WOver -> SExp
- mkMod :: (a -> b) -> Maybe a -> [b]
- anyValue :: SExp -> Maybe WOver -> SExp
- arrayAgg :: SExp -> [FunModifier] -> SExp
- arrayConcatAgg :: SExp -> [Order] -> Maybe Int -> SExp
- bqAvg :: SExp -> Either Distinctness WOver -> SExp
- bitAnd :: SExp -> SExp
- bitOr :: SExp -> SExp
- bitXor :: SExp -> Distinctness -> SExp
- bqCount :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqCountDistinct :: SExp -> Maybe WOver -> SExp
- countIf :: SExp -> Maybe WOver -> SExp
- logicalAnd :: SExp -> SExp
- logicalOr :: SExp -> SExp
- bqMax :: SExp -> Maybe WOver -> SExp
- bqMin :: SExp -> Maybe WOver -> SExp
- bqSum :: SExp -> Distinctness -> Maybe WOver -> SExp
- corr :: SExp -> SExp -> SExp
- covarPop :: SExp -> SExp -> SExp
- covarSamp :: SExp -> SExp -> SExp
- bqStddevPop :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqStddevSamp :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqStddev :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqVarPop :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqVarSamp :: SExp -> Distinctness -> Maybe WOver -> SExp
- bqVariance :: SExp -> Distinctness -> Maybe WOver -> SExp
- approxCountDistinct :: SExp -> SExp
- approxQuantiles :: SExp -> Int -> Distinctness -> Maybe NullStrategy -> SExp
- approxTopCount :: SExp -> Int -> SExp
- approxTopSum :: SExp -> SExp -> Int -> SExp
- newtype HLLPrecision = HLLPrecision {}
- hllPrecision :: Int -> HLLPrecision
- hllInit :: [SExp] -> Maybe HLLPrecision -> SExp
- hllMerge :: SExp -> SExp
- hllMergePartial :: SExp -> SExp
- hllExtract :: SExp -> SExp
- rank :: WOver -> SExp
- denseRank :: WOver -> SExp
- percentRank :: WOver -> SExp
- rowNumber :: WOver -> SExp
- cumeDist :: WOver -> SExp
- ntile :: Int -> WOver -> SExp
- firstValue :: SExp -> WOver -> Maybe NullStrategy -> SExp
- lastValue :: SExp -> WOver -> Maybe NullStrategy -> SExp
- nthValue :: SExp -> Int -> WOver -> Maybe NullStrategy -> SExp
- lead :: SExp -> Int -> Maybe SExp -> WOver -> SExp
- lag :: SExp -> Int -> Maybe SExp -> WOver -> SExp
- percentileCont :: SExp -> Double -> [SExp] -> Maybe NullStrategy -> SExp
- percentileDisc :: SExp -> Double -> [SExp] -> Maybe NullStrategy -> SExp
- bitCount :: SExp -> SExp
- type UFunc = SExp -> SExp
- type BinFunc = SExp -> SExp -> SExp
- type NulFunc = SExp
- type MulFunc = [SExp] -> SExp
- isInf :: UFunc
- isNan :: UFunc
- ieeeDivide :: BinFunc
- rand :: NulFunc
- sqrt :: UFunc
- pow :: BinFunc
- power :: BinFunc
- exp :: UFunc
- ln :: UFunc
- log :: BinFunc
- log10 :: UFunc
- greatest :: MulFunc
- least :: MulFunc
- div :: BinFunc
- safeDiv :: BinFunc
- mod :: BinFunc
- round :: UFunc
- roundN :: SExp -> Int -> SExp
- trunc :: UFunc
- truncN :: Val a => SExp -> a -> SExp
- ceil :: UFunc
- floor :: UFunc
- cos :: UFunc
- cosh :: UFunc
- acos :: UFunc
- acosh :: UFunc
- sin :: UFunc
- sinh :: UFunc
- asin :: UFunc
- asinh :: UFunc
- tan :: UFunc
- tanh :: UFunc
- atan :: UFunc
- atanh :: UFunc
- atan2 :: BinFunc
- farmFingerprint :: UFunc
- md5 :: UFunc
- sha1 :: UFunc
- sha256 :: UFunc
- sha512 :: UFunc
- byteLength :: UFunc
- charLength :: UFunc
- codePointsToBytes :: UFunc
- codePointsToString :: UFunc
- concat :: MulFunc
- endsWith :: BinFunc
- format :: Text -> [SExp] -> SExp
- fromBase64 :: UFunc
- length :: UFunc
- lpad :: SExp -> Int -> Maybe Text -> SExp
- lower :: UFunc
- ltrim :: SExp -> Maybe Text -> SExp
- regexpContains :: SExp -> Text -> SExp
- regexpExtract :: SExp -> Text -> SExp
- regexpExtractAll :: SExp -> Text -> SExp
- regexpReplace :: SExp -> Text -> Text -> SExp
- replace :: SExp -> Text -> Text -> SExp
- repeat :: Val a => SExp -> a -> SExp
- reverse :: UFunc
- rpad :: SExp -> Int -> Maybe Text -> SExp
- rtrim :: SExp -> Maybe Text -> SExp
- safeConvertBytesToString :: UFunc
- safeCast :: SExp -> Type -> SExp
- split :: SExp -> Text -> SExp
- startsWith :: SExp -> SExp -> SExp
- strPos :: SExp -> SExp -> SExp
- substr :: SExp -> Int -> Maybe Int -> SExp
- toBase64 :: UFunc
- toCodePoints :: UFunc
- toHex :: UFunc
- trim :: SExp -> Maybe Text -> SExp
- upper :: UFunc
- data JSONPath
- jsonPath_key :: Text -> JSONPath
- jsonPath_index :: Int -> JSONPath
- renderJSONPath :: Ref Function -> [JSONPath] -> Text
- jsonFunction :: Ref Function -> SExp -> [JSONPath] -> SExp
- jsonExtract :: SExp -> [JSONPath] -> SExp
- jsonExtractScalar :: SExp -> [JSONPath] -> SExp
- jsonQuery :: SExp -> [JSONPath] -> SExp
- jsonValue :: SExp -> [JSONPath] -> SExp
- jsonExtractArray :: SExp -> [JSONPath] -> SExp
- jsonQueryArray :: SExp -> [JSONPath] -> SExp
- jsonExtractStringArray :: SExp -> [JSONPath] -> SExp
- jsonValueArray :: SExp -> [JSONPath] -> SExp
- parseJson :: SExp -> SExp
- toJson :: SExp -> SExp
- jsonLiteral :: SExp -> SExp
- toJsonString :: SExp -> Maybe Bool -> SExp
- jsonSafeString :: SExp -> SExp
- jsonSafeBool :: SExp -> SExp
- jsonSafeInt64 :: SExp -> SExp
- jsonSafeFloat64 :: SExp -> SExp
- arrayConcat :: NonEmpty SExp -> SExp
- arrayLength :: SExp -> SExp
- arrayToString :: SExp -> Text -> Maybe Text -> SExp
- generateArray :: SExp -> SExp -> Maybe SExp -> SExp
- generateDateArray :: SExp -> SExp -> Maybe IntInterval -> SExp
- arrayReverse :: SExp -> SExp
- offset :: Int -> SExp -> SExp
- ordinal :: Int -> SExp -> SExp
- currentDate :: Maybe Text -> SExp
- dateYMD :: SExp -> SExp -> SExp -> SExp
- dateTimestamp :: SExp -> Maybe SExp -> SExp
- dateAdd :: SExp -> IntInterval -> SExp
- dateSub :: SExp -> IntInterval -> SExp
- dateDiff :: DatePart -> SExp -> SExp -> SExp
- dateTrunc :: DatePart -> SExp -> SExp
- dateFromUnixDate :: SExp -> SExp
- formatDate :: SExp -> SExp -> SExp
- parseDate :: SExp -> SExp -> SExp
- unixDate :: SExp -> SExp
- currentDatetime :: Maybe SExp -> SExp
- dateTimeYMDHMS :: SExp -> SExp -> SExp -> SExp -> SExp -> SExp -> SExp
- dateTimeDateAndTime :: SExp -> SExp -> SExp
- dateTimeTimestamp :: SExp -> Maybe SExp -> SExp
- dateTimeAdd :: SExp -> IntInterval -> SExp
- dateTimeSub :: SExp -> IntInterval -> SExp
- dateTimeDiff :: DatePart -> SExp -> SExp -> SExp
- dateTimeTrunc :: DatePart -> SExp -> SExp
- formatDateTime :: SExp -> SExp -> SExp
- parseDateTime :: SExp -> SExp -> SExp
- currentTime :: SExp
- timeHMS :: SExp -> SExp -> SExp -> SExp
- timeTS :: SExp -> Maybe SExp -> SExp
- timeAdd :: SExp -> IntInterval -> SExp
- timeSub :: SExp -> IntInterval -> SExp
- timeDiff :: DatePart -> SExp -> SExp -> SExp
- timeTrunc :: DatePart -> SExp -> SExp
- bqFormatTime :: SExp -> SExp -> SExp
- bqParseTime :: SExp -> SExp -> SExp
- currentTimestamp :: SExp
- extract :: DatePart -> SExp -> Maybe SExp -> SExp
- string :: SExp -> Maybe SExp -> SExp
- timestamp :: SExp -> Maybe SExp -> SExp
- timestampAdd :: SExp -> IntInterval -> SExp
- timestampSub :: SExp -> IntInterval -> SExp
- timestampDiff :: DatePart -> SExp -> SExp -> SExp
- timestampTrunc :: DatePart -> SExp -> Maybe SExp -> SExp
- formatTimestamp :: SExp -> SExp -> Maybe SExp -> SExp
- parseTimestamp :: SExp -> SExp -> Maybe SExp -> SExp
- timestampSeconds :: SExp -> SExp
- timestampMillis :: SExp -> SExp
- timestampMicros :: SExp -> SExp
- unixSeconds :: SExp -> SExp
- unixMillis :: SExp -> SExp
- unixMicros :: SExp -> SExp
- sessionUser :: SExp
- netIPFromString :: SExp -> SExp
- netSafeIPFromString :: SExp -> SExp
- netIPToString :: SExp -> SExp
- netIPNetMask :: SExp -> SExp -> SExp
- netIPTrunc :: SExp -> SExp -> SExp
- netIPV4FromInt64 :: SExp -> SExp
- netIPV4ToInt64 :: SExp -> SExp
- netHost :: SExp -> SExp
- netPublicSuffix :: SExp -> SExp
- netRegDomain :: SExp -> SExp
- ifnull :: SExp -> SExp -> SExp
- nullif :: SExp -> SExp -> SExp
- like :: SExp -> SExp -> SExp
- between :: SExp -> SExp -> SExp -> SExp
- scope :: SExp -> SExp -> SExp
- scoped :: SExp -> SExp -> SExp
- inferAgg :: SExp -> AggLevel
- unitBoundary :: SExp -> [SExp]
- modifyUnitBoundary :: (SExp -> SExp) -> SExp -> SExp
- bigQueryMeta :: BackendFunctionMeta
- bigQueryAggs :: [(Ref Function, SExp)]
- textInfix :: SExp -> SExp -> SExp
- nullIfEmpty :: SExp -> SExp
- seekBackIgnoreNulls :: SExp -> Int -> WOver -> SExp
- seekForwardIgnoreNulls :: SExp -> Int -> WOver -> SExp
- lagIgnoreNulls :: SExp -> Int -> WOver -> SExp
- leadIgnoreNulls :: SExp -> Int -> WOver -> SExp
- denseAvg :: SExp -> SExp
- weightedAvg :: SExp -> SExp -> SExp
- nzAvg :: SExp -> SExp
- percentDiff :: SExp -> SExp -> SExp
- data SubQueryTransformState = SubQueryTransformState {}
- subqueryTransform :: Query -> Query
- humanAge :: SExp -> SExp -> SExp
- tableSample :: Int -> Q ()
Documentation
arrayAgg :: SExp -> [FunModifier] -> SExp #
bitXor :: SExp -> Distinctness -> SExp #
logicalAnd :: SExp -> SExp #
bqStddevPop :: SExp -> Distinctness -> Maybe WOver -> SExp #
bqStddevSamp :: SExp -> Distinctness -> Maybe WOver -> SExp #
bqVariance :: SExp -> Distinctness -> Maybe WOver -> SExp #
approxCountDistinct :: SExp -> SExp #
Approximate Aggregate Functions
approxQuantiles :: SExp -> Int -> Distinctness -> Maybe NullStrategy -> SExp #
approxTopCount :: SExp -> Int -> SExp #
hllPrecision :: Int -> HLLPrecision #
hllMergePartial :: SExp -> SExp #
hllExtract :: SExp -> SExp #
percentRank :: WOver -> SExp #
firstValue :: SExp -> WOver -> Maybe NullStrategy -> SExp #
percentileCont :: SExp -> Double -> [SExp] -> Maybe NullStrategy -> SExp #
ieeeDivide :: BinFunc #
Hash Functions
byteLength :: UFunc #
Text Functions
charLength :: UFunc #
fromBase64 :: UFunc #
regexpContains :: SExp -> Text -> SExp #
regexpExtract :: SExp -> Text -> SExp #
regexpExtractAll :: SExp -> Text -> SExp #
startsWith :: SExp -> SExp -> SExp #
toCodePoints :: UFunc #
JSON Functions
Constructors
JSONPath_Key Text | |
JSONPath_Index !Int |
jsonPath_key :: Text -> JSONPath #
jsonPath_index :: Int -> JSONPath #
jsonExtract :: SExp -> [JSONPath] -> SExp #
jsonExtractScalar :: SExp -> [JSONPath] -> SExp #
jsonExtractArray :: SExp -> [JSONPath] -> SExp #
jsonQueryArray :: SExp -> [JSONPath] -> SExp #
jsonExtractStringArray :: SExp -> [JSONPath] -> SExp #
jsonValueArray :: SExp -> [JSONPath] -> SExp #
jsonLiteral :: SExp -> SExp #
jsonSafeString :: SExp -> SExp #
jsonSafeBool :: SExp -> SExp #
jsonSafeInt64 :: SExp -> SExp #
jsonSafeFloat64 :: SExp -> SExp #
arrayConcat :: NonEmpty SExp -> SExp #
Array Functions
arrayLength :: SExp -> SExp #
generateDateArray :: SExp -> SExp -> Maybe IntInterval -> SExp #
arrayReverse :: SExp -> SExp #
currentDate :: Maybe Text -> SExp #
Date Functions
Arguments
:: SExp | Date expression |
-> IntInterval | |
-> SExp |
Arguments
:: SExp | Date expression |
-> IntInterval | |
-> SExp |
Arguments
:: SExp | Datetime expression |
-> IntInterval | |
-> SExp |
Arguments
:: SExp | Datetime expression |
-> IntInterval | |
-> SExp |
dateTimeTrunc :: DatePart -> SExp -> SExp #
currentTime :: SExp #
Time Functions
Arguments
:: SExp | Time expression |
-> IntInterval | |
-> SExp |
Arguments
:: SExp | Time expression |
-> IntInterval | |
-> SExp |
Timestamp Functions
timestampAdd :: SExp -> IntInterval -> SExp #
timestampSub :: SExp -> IntInterval -> SExp #
sessionUser :: SExp #
Security Functions
Like netIPFromString
but returns NULL rather than throwing on error.
scope :: SExp -> SExp -> SExp #
Use scopeGeneric
to push given predicate deeply under all aggregations
within the given expression.
unitBoundary :: SExp -> [SExp] #
bigQueryAggs :: [(Ref Function, SExp)] #
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.
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.
weightedAvg :: SExp -> SExp -> SExp #
percentDiff :: SExp -> SExp -> SExp #
percent difference of a
over b
with typecast to Double
data SubQueryTransformState #
Instances
subqueryTransform :: Query -> Query #
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)
tableSample :: Int -> Q () #
Uses BQ table sample system. This reduces the scope of the query to a percentage of blocks in the table set by the user. The sample chosen is random. This is used similarly to the limit_ function. Unlike limit_, this will reduce costs to only those blocks sampled; potentially reducing overall costs. Can not be used in a suqquery or against views.