graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Backends.BigQuery.Execute

Description

Execute a Select query against the BigQuery REST API.

Synopsis

Documentation

data RecordSet Source #

A set of records produced by the database. These are joined together. There are all sorts of optimizations possible here, from using a matrix/flat vector, unboxed sums for Value, etc. Presently we choose a naive implementation in the interest of getting other work done.

Constructors

RecordSet 

Fields

Instances

Instances details
Show RecordSet Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

newtype FieldNameText Source #

As opposed to BigQuery.FieldName which is a qualified name, this is just the unqualified text name itself.

Constructors

FieldNameText Text 

Instances

Instances details
Eq FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Ord FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Show FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

IsString FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Hashable FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

FromJSON FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

parseJSON :: Value -> Parser FieldNameText

parseJSONList :: Value -> Parser [FieldNameText]

ToJSONKey FieldNameText Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

toJSONKey :: ToJSONKeyFunction FieldNameText

toJSONKeyList :: ToJSONKeyFunction [FieldNameText]

data OutputValue Source #

Instances

Instances details
Eq OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Show OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Generic OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Associated Types

type Rep OutputValue :: Type -> Type #

Hashable OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

ToJSON OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

toJSON :: OutputValue -> Value

toEncoding :: OutputValue -> Encoding

toJSONList :: [OutputValue] -> Value

toEncodingList :: [OutputValue] -> Encoding

type Rep OutputValue Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

type Rep OutputValue = D1 ('MetaData "OutputValue" "Hasura.Backends.BigQuery.Execute" "graphql-engine-1.0.0-inplace" 'False) (((C1 ('MetaCons "DecimalOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Decimal)) :+: (C1 ('MetaCons "BigDecimalOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BigDecimal)) :+: C1 ('MetaCons "IntegerOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int64)))) :+: ((C1 ('MetaCons "FloatOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Float64)) :+: C1 ('MetaCons "GeographyOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Geography))) :+: (C1 ('MetaCons "TextOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "TimestampOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Timestamp))))) :+: (((C1 ('MetaCons "DateOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Date)) :+: C1 ('MetaCons "TimeOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Time))) :+: (C1 ('MetaCons "DatetimeOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Datetime)) :+: C1 ('MetaCons "BytesOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Base64)))) :+: ((C1 ('MetaCons "BoolOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "ArrayOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector OutputValue)))) :+: (C1 ('MetaCons "RecordOutputValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (InsOrdHashMap FieldNameText OutputValue))) :+: C1 ('MetaCons "NullOutputValue" 'PrefixI 'False) (U1 :: Type -> Type)))))

data ExecuteProblem Source #

Instances

Instances details
Generic ExecuteProblem Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Associated Types

type Rep ExecuteProblem :: Type -> Type #

ToJSON ExecuteProblem Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

toJSON :: ExecuteProblem -> Value

toEncoding :: ExecuteProblem -> Encoding

toJSONList :: [ExecuteProblem] -> Value

toEncodingList :: [ExecuteProblem] -> Encoding

MonadError ExecuteProblem Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

type Rep ExecuteProblem Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

data ShowDetails Source #

We use this to hide certain details from the front-end, while allowing them in tests. We have not actually decided whether showing the details is insecure, but until we decide otherwise, it's probably best to err on the side of caution.

newtype Execute a Source #

Execute monad; as queries are performed, the record sets are stored in the map.

Instances

Instances details
Monad Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

(>>=) :: Execute a -> (a -> Execute b) -> Execute b #

(>>) :: Execute a -> Execute b -> Execute b #

return :: a -> Execute a #

Functor Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

fmap :: (a -> b) -> Execute a -> Execute b #

(<$) :: a -> Execute b -> Execute a #

Applicative Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

pure :: a -> Execute a #

(<*>) :: Execute (a -> b) -> Execute a -> Execute b #

liftA2 :: (a -> b -> c) -> Execute a -> Execute b -> Execute c #

(*>) :: Execute a -> Execute b -> Execute b #

(<*) :: Execute a -> Execute b -> Execute a #

MonadIO Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

Methods

liftIO :: IO a -> Execute a #

MonadError ExecuteProblem Execute Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

data BigQueryType Source #

Big query parameters must be accompanied by an explicit type signature.

data BigQuery Source #

Constructors

BigQuery 

Fields

Instances

Instances details
Show BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Execute

data Parameter Source #

Constructors

Parameter 

Fields

newtype ParameterName Source #

Constructors

ParameterName Text 

streamDelaySeconds :: DiffTime Source #

Delay between attempts to get job results if the job is incomplete.

getFinalRecordSet :: RecordSet -> Execute RecordSet Source #

This is needed to strip out unneeded fields (join keys) in the final query. This is a relic of the data loader approach. A later improvement would be to update the FromIr code to explicitly reselect the query. But the purpose of this commit is to drop the dataloader code and not modify the from IR code which is more delicate.

valueType :: Value -> BigQueryType Source #

Make a BigQuery type for the given value.

valueToBigQueryJson :: Value -> Value Source #

Make a JSON representation of the type of the given value.

streamBigQuery :: MonadIO m => BigQueryConnection -> BigQuery -> m (Either ExecuteProblem RecordSet) Source #

TODO: WARNING: This function hasn't been tested on Big Data(tm), and therefore I was unable to get BigQuery to produce paginated results that would contain the $sel:pageToken:JobResults field in the JSON response. Until that test has been done, we should consider this a preliminary implementation.

executeBigQuery :: MonadIO m => BigQueryConnection -> BigQuery -> m (Either ExecuteProblem ()) Source #

Execute a query without expecting any output (e.g. CREATE TABLE or INSERT)

data JobResults Source #

Constructors

JobResults 

Fields

data Fetch Source #

Constructors

Fetch 

Fields

data Job Source #

Constructors

Job 

Fields

jsonRequestHeader :: Request -> Request Source #

Make a Request return JSON

createQueryJob :: (MonadError ExecuteProblem m, MonadIO m) => BigQueryConnection -> BigQuery -> m Job Source #

Create a job asynchronously.

data Dataset Source #

Constructors

Dataset 

Fields

deleteDataset :: (MonadError ExecuteProblem m, MonadIO m) => BigQueryConnection -> Text -> m () Source #

Delete a dataset

runBigQueryExcept :: (MonadError ExecuteProblem m, MonadIO m) => BigQueryConnection -> Request -> m (Response ByteString) Source #

Run request and map errors into ExecuteProblem

insertDataset :: (MonadError ExecuteProblem m, MonadIO m) => BigQueryConnection -> Text -> m Dataset Source #

Insert a new dataset

parseAsJsonOrText :: ByteString -> Value Source #

Parse given @ByteString as JSON value. If not a valid JSON, encode to plain text.

parseRow :: Vector BigQueryField -> Value -> Parser (InsOrdHashMap FieldNameText OutputValue) Source #

parseBigQueryRow :: Vector BigQueryField -> Value -> Parser OutputValue Source #

Parse a row, which at the top-level of the "rows" output has no {"v":..} wrapper. But when appearing nestedly, does have the wrapper. See parseBigQueryValue.

parseTimestamp :: Value -> Parser Timestamp Source #

Parse upstream timestamp value in epoch milliseconds and convert it to calendar date time format https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type

has_v :: IsNullable -> (Value -> Parser OutputValue) -> Value -> Parser OutputValue Source #

has_v_generic :: (Value -> Parser a) -> Value -> Parser a Source #