{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Hasura.Backends.BigQuery.Instances.Schema () where

import Control.Applicative (Const (..))
import Data.Aeson qualified as J
import Data.Has
import Data.HashMap.Strict qualified as HashMap
import Data.List.NonEmpty qualified as NE
import Data.Text qualified as T
import Data.Text.Casing qualified as C
import Data.Text.Extended
import Hasura.Backends.BigQuery.DDL (scalarTypeFromColumnType)
import Hasura.Backends.BigQuery.Name
import Hasura.Backends.BigQuery.Parser.Scalars qualified as BQP
import Hasura.Backends.BigQuery.Types qualified as BigQuery
import Hasura.Base.Error
import Hasura.Base.ErrorMessage (toErrorMessage)
import Hasura.Function.Cache
import Hasura.GraphQL.Schema.Backend
import Hasura.GraphQL.Schema.BoolExp
import Hasura.GraphQL.Schema.Build qualified as GSB
import Hasura.GraphQL.Schema.Common
import Hasura.GraphQL.Schema.Parser
  ( FieldParser,
    InputFieldsParser,
    Kind (..),
    MonadParse,
    Parser,
  )
import Hasura.GraphQL.Schema.Parser qualified as P
import Hasura.GraphQL.Schema.Select
import Hasura.GraphQL.Schema.Table
import Hasura.GraphQL.Schema.Typename
import Hasura.LogicalModel.Schema (defaultLogicalModelArgs, defaultLogicalModelSelectionSet)
import Hasura.Name qualified as Name
import Hasura.NativeQuery.Schema qualified as NativeQueries
import Hasura.Prelude
import Hasura.RQL.IR.BoolExp
import Hasura.RQL.IR.Select qualified as IR
import Hasura.RQL.IR.Value qualified as IR
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendType
import Hasura.RQL.Types.Column
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.ComputedField
import Hasura.RQL.Types.NamingCase
import Hasura.RQL.Types.Schema.Options qualified as Options
import Hasura.RQL.Types.Source
import Hasura.RQL.Types.SourceCustomization
import Hasura.Table.Cache
import Language.GraphQL.Draft.Syntax qualified as G

----------------------------------------------------------------
-- BackendSchema instance

instance BackendSchema 'BigQuery where
  -- top level parsers
  buildTableQueryAndSubscriptionFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     ([FieldParser
         n
         (QueryDB
            'BigQuery
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'BigQuery))],
      [FieldParser
         n
         (QueryDB
            'BigQuery
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'BigQuery))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
buildTableQueryAndSubscriptionFields = MkRootFieldName
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     ([FieldParser
         n
         (QueryDB
            'BigQuery
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'BigQuery))],
      [FieldParser
         n
         (QueryDB
            'BigQuery
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'BigQuery))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b,
 BackendTableSelectSchema b) =>
MkRootFieldName
-> TableName b
-> TableInfo b
-> GQLNameIdentifier
-> SchemaT
     r
     m
     ([FieldParser
         n
         (QueryDB
            b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))],
      [FieldParser
         n
         (QueryDB
            b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
GSB.buildTableQueryAndSubscriptionFields
  buildTableRelayQueryFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> NESeq (ColumnInfo 'BigQuery)
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildTableRelayQueryFields MkRootFieldName
_ TableName 'BigQuery
_ TableInfo 'BigQuery
_ GQLNameIdentifier
_ NESeq (ColumnInfo 'BigQuery)
_ = [FieldParser
   n
   (QueryDB
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableStreamingSubscriptionFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildTableStreamingSubscriptionFields = MkRootFieldName
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b,
 BackendTableSelectSchema b) =>
MkRootFieldName
-> TableName b
-> TableInfo b
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
GSB.buildTableStreamingSubscriptionFields
  buildTableInsertMutationFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> Scenario
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnotatedInsert
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildTableInsertMutationFields MkRootFieldName
_ Scenario
_ TableName 'BigQuery
_ TableInfo 'BigQuery
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnotatedInsert
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnotatedInsert
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableUpdateMutationFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
Scenario
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnotatedUpdateG
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildTableUpdateMutationFields Scenario
_ TableInfo 'BigQuery
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnotatedUpdateG
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnotatedUpdateG
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableDeleteMutationFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> Scenario
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> GQLNameIdentifier
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnDelG
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildTableDeleteMutationFields MkRootFieldName
_ Scenario
_ TableName 'BigQuery
_ TableInfo 'BigQuery
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnDelG
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (AnnDelG
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionQueryFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> FunctionName 'BigQuery
-> FunctionInfo 'BigQuery
-> TableName 'BigQuery
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildFunctionQueryFields MkRootFieldName
_ FunctionName 'BigQuery
_ FunctionInfo 'BigQuery
_ TableName 'BigQuery
_ = [FieldParser
   n
   (QueryDB
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionRelayQueryFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> FunctionName 'BigQuery
-> FunctionInfo 'BigQuery
-> TableName 'BigQuery
-> NESeq (ColumnInfo 'BigQuery)
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildFunctionRelayQueryFields MkRootFieldName
_ FunctionName 'BigQuery
_ FunctionInfo 'BigQuery
_ TableName 'BigQuery
_ NESeq (ColumnInfo 'BigQuery)
_ = [FieldParser
   n
   (QueryDB
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (QueryDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionMutationFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
MkRootFieldName
-> FunctionName 'BigQuery
-> FunctionInfo 'BigQuery
-> TableName 'BigQuery
-> SchemaT
     r
     m
     [FieldParser
        n
        (MutationDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
buildFunctionMutationFields MkRootFieldName
_ FunctionName 'BigQuery
_ FunctionInfo 'BigQuery
_ TableName 'BigQuery
_ = [FieldParser
   n
   (MutationDB
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     [FieldParser
        n
        (MutationDB
           'BigQuery
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'BigQuery))]
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildNativeQueryRootFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
NativeQueryInfo 'BigQuery
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (QueryDB
              'BigQuery
              (RemoteRelationshipField UnpreparedValue)
              (UnpreparedValue 'BigQuery))))
buildNativeQueryRootFields = NativeQueryInfo 'BigQuery
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (QueryDB
              'BigQuery
              (RemoteRelationshipField UnpreparedValue)
              (UnpreparedValue 'BigQuery))))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendNativeQuerySelectSchema b) =>
NativeQueryInfo b
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (QueryDB
              b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))))
NativeQueries.defaultBuildNativeQueryRootFields

  -- backend extensions
  relayExtension :: Maybe (XRelay 'BigQuery)
relayExtension = Maybe Void
Maybe (XRelay 'BigQuery)
forall a. Maybe a
Nothing
  nodesAggExtension :: Maybe (XNodesAgg 'BigQuery)
nodesAggExtension = () -> Maybe ()
forall a. a -> Maybe a
Just ()
  streamSubscriptionExtension :: Maybe (XStreamingSubscription 'BigQuery)
streamSubscriptionExtension = Maybe Void
Maybe (XStreamingSubscription 'BigQuery)
forall a. Maybe a
Nothing

  -- individual components
  columnParser :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
columnParser = ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
bqColumnParser
  enumParser :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
enumParser = TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
bqEnumParser
  possiblyNullable :: forall (m :: * -> *).
MonadParse m =>
ScalarType 'BigQuery
-> Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
possiblyNullable = (Nullability -> Parser 'Both m Value -> Parser 'Both m Value)
-> ScalarType
-> Nullability
-> Parser 'Both m Value
-> Parser 'Both m Value
forall a b. a -> b -> a
const Nullability
-> Parser MetadataObjId 'Both m (ScalarValue 'BigQuery)
-> Parser MetadataObjId 'Both m (ScalarValue 'BigQuery)
Nullability -> Parser 'Both m Value -> Parser 'Both m Value
forall (m :: * -> *).
MonadParse m =>
Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable
  scalarSelectionArgumentsParser :: forall (n :: * -> *).
MonadParse n =>
ColumnType 'BigQuery
-> InputFieldsParser n (Maybe (ScalarSelectionArguments 'BigQuery))
scalarSelectionArgumentsParser ColumnType 'BigQuery
_ = Maybe Void -> InputFieldsParser MetadataObjId n (Maybe Void)
forall a. a -> InputFieldsParser MetadataObjId n a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Void
forall a. Maybe a
Nothing
  orderByOperators :: SourceInfo 'BigQuery
-> NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery)))
orderByOperators SourceInfo 'BigQuery
_sourceInfo = NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery)))
bqOrderByOperators
  comparisonExps :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> SchemaT r m (Parser 'Input n [ComparisonExp 'BigQuery])
comparisonExps = ColumnType 'BigQuery
-> SchemaT r m (Parser 'Input n [ComparisonExp 'BigQuery])
forall (m :: * -> *) (n :: * -> *) r.
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> SchemaT r m (Parser 'Input n [ComparisonExp 'BigQuery])
bqComparisonExps
  countTypeInput :: forall (n :: * -> *).
MonadParse n =>
Maybe
  (Parser
     'Both
     n
     (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
countTypeInput = Maybe
  (Parser
     'Both
     n
     (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
forall (n :: * -> *).
MonadParse n =>
Maybe
  (Parser
     'Both
     n
     (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
bqCountTypeInput
  aggregateOrderByCountType :: ScalarType 'BigQuery
aggregateOrderByCountType = ScalarType 'BigQuery
ScalarType
BigQuery.IntegerScalarType
  computedField :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ComputedFieldInfo 'BigQuery
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
computedField = ComputedFieldInfo 'BigQuery
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ComputedFieldInfo 'BigQuery
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
bqComputedField

instance BackendTableSelectSchema 'BigQuery where
  tableArguments :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
tableArguments = TableInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b) =>
TableInfo b -> SchemaT r m (InputFieldsParser n (SelectArgs b))
defaultTableArgs
  selectTable :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (SelectExp 'BigQuery)))
selectTable = TableInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (SelectExp 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendTableSelectSchema b) =>
TableInfo b
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (SelectExp b)))
defaultSelectTable
  selectTableAggregate :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (AggSelectExp 'BigQuery)))
selectTableAggregate = TableInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (AggSelectExp 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendTableSelectSchema b) =>
TableInfo b
-> Name
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (AggSelectExp b)))
defaultSelectTableAggregate
  tableSelectionSet :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> SchemaT
     r m (Maybe (Parser 'Output n (AnnotatedFields 'BigQuery)))
tableSelectionSet = TableInfo 'BigQuery
-> SchemaT
     r m (Maybe (Parser 'Output n (AnnotatedFields 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(AggregationPredicatesSchema b, BackendTableSelectSchema b,
 Eq (AnnBoolExp b (UnpreparedValue b)), MonadBuildSchema b r m n) =>
TableInfo b
-> SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
defaultTableSelectionSet

instance BackendNativeQuerySelectSchema 'BigQuery where
  selectNativeQuery :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
NativeQueryInfo 'BigQuery
-> Name
-> Nullable
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (SelectExp 'BigQuery)))
selectNativeQuery = NativeQueryInfo 'BigQuery
-> Name
-> Nullable
-> Maybe Description
-> SchemaT r m (Maybe (FieldParser n (SelectExp 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendNativeQuerySelectSchema b) =>
NativeQueryInfo b
-> Name
-> Nullable
-> Maybe Description
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnSimpleSelectG
              b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))))
NativeQueries.defaultSelectNativeQuery
  selectNativeQueryObject :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
NativeQueryInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnObjectSelectG
              'BigQuery
              (RemoteRelationshipField UnpreparedValue)
              (UnpreparedValue 'BigQuery))))
selectNativeQueryObject = NativeQueryInfo 'BigQuery
-> Name
-> Maybe Description
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnObjectSelectG
              'BigQuery
              (RemoteRelationshipField UnpreparedValue)
              (UnpreparedValue 'BigQuery))))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendNativeQuerySelectSchema b) =>
NativeQueryInfo b
-> Name
-> Maybe Description
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnObjectSelectG
              b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))))
NativeQueries.defaultSelectNativeQueryObject

instance BackendLogicalModelSelectSchema 'BigQuery where
  logicalModelArguments :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
LogicalModelInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
logicalModelArguments = LogicalModelInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b) =>
LogicalModelInfo b
-> SchemaT r m (InputFieldsParser n (SelectArgs b))
defaultLogicalModelArgs
  logicalModelSelectionSet :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
LogicalModelInfo 'BigQuery
-> SchemaT
     r m (Maybe (Parser 'Output n (AnnotatedFields 'BigQuery)))
logicalModelSelectionSet = LogicalModelInfo 'BigQuery
-> SchemaT
     r m (Maybe (Parser 'Output n (AnnotatedFields 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
MonadBuildSchema b r m n =>
LogicalModelInfo b
-> SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
defaultLogicalModelSelectionSet

----------------------------------------------------------------
-- Individual components

bqColumnParser ::
  (MonadBuildSchema 'BigQuery r m n) =>
  ColumnType 'BigQuery ->
  G.Nullability ->
  SchemaT r m (Parser 'Both n (IR.ValueWithOrigin (ColumnValue 'BigQuery)))
bqColumnParser :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
bqColumnParser ColumnType 'BigQuery
columnType Nullability
nullability = case ColumnType 'BigQuery
columnType of
  ColumnScalar ScalarType 'BigQuery
scalarType -> Name
-> (ColumnType 'BigQuery, Nullability)
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (m :: * -> *) a (p :: (* -> *) -> * -> *) (n :: * -> *) b.
(MonadMemoize m, Ord a, Typeable a, Typeable p, MonadParse n,
 Typeable b) =>
Name -> a -> m (p n b) -> m (p n b)
P.memoizeOn 'bqColumnParser (ColumnType 'BigQuery
columnType, Nullability
nullability) do
    Options.SchemaOptions {BigQueryStringNumericInput
soBigQueryStringNumericInput :: BigQueryStringNumericInput
soBigQueryStringNumericInput :: SchemaOptions -> BigQueryStringNumericInput
soBigQueryStringNumericInput} <- (r -> SchemaOptions) -> SchemaT r m SchemaOptions
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks r -> SchemaOptions
forall a t. Has a t => t -> a
getter
    let numericInputParser :: forall a. a -> a -> a
        numericInputParser :: forall a. a -> a -> a
numericInputParser a
builtin a
custom =
          case BigQueryStringNumericInput
soBigQueryStringNumericInput of
            BigQueryStringNumericInput
Options.EnableBigQueryStringNumericInput -> a
custom
            BigQueryStringNumericInput
Options.DisableBigQueryStringNumericInput -> a
builtin
    Parser 'Both n (ColumnValue 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) a.
MonadParse m =>
Parser 'Both m a -> Parser 'Both m (ValueWithOrigin a)
peelWithOrigin
      (Parser 'Both n (ColumnValue 'BigQuery)
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
-> (Parser MetadataObjId 'Both n Value
    -> Parser 'Both n (ColumnValue 'BigQuery))
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Value -> ColumnValue 'BigQuery)
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ColumnValue 'BigQuery)
forall a b.
(a -> b)
-> Parser MetadataObjId 'Both n a -> Parser MetadataObjId 'Both n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ColumnType 'BigQuery
-> ScalarValue 'BigQuery -> ColumnValue 'BigQuery
forall (b :: BackendType).
ColumnType b -> ScalarValue b -> ColumnValue b
ColumnValue ColumnType 'BigQuery
columnType)
      (Parser MetadataObjId 'Both n Value
 -> Parser 'Both n (ColumnValue 'BigQuery))
-> (Parser MetadataObjId 'Both n Value
    -> Parser MetadataObjId 'Both n Value)
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ColumnValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Nullability
-> Parser 'Both n (ScalarValue 'BigQuery)
-> Parser 'Both n (ScalarValue 'BigQuery)
forall (m :: * -> *).
MonadParse m =>
Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable Nullability
nullability
      (Parser MetadataObjId 'Both n Value
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ScalarType 'BigQuery
scalarType of
        -- bytestrings
        -- we only accept string literals
        ScalarType 'BigQuery
ScalarType
BigQuery.BytesScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Text -> Value
BigQuery.StringValue (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
_Bytes
        -- text
        ScalarType 'BigQuery
ScalarType
BigQuery.StringScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Text -> Value
BigQuery.StringValue (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
        -- floating point values

        ScalarType 'BigQuery
ScalarType
BigQuery.FloatScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
            (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Float64 -> Value
BigQuery.FloatValue
            (Float64 -> Value)
-> Parser MetadataObjId 'Both n Float64
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Float64
-> Parser MetadataObjId 'Both n Float64
-> Parser MetadataObjId 'Both n Float64
forall a. a -> a -> a
numericInputParser (Double -> Float64
BigQuery.doubleToFloat64 (Double -> Float64)
-> Parser MetadataObjId 'Both n Double
-> Parser MetadataObjId 'Both n Float64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Double
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Double
P.float) Parser MetadataObjId 'Both n Float64
forall origin (m :: * -> *).
MonadParse m =>
Parser origin 'Both m Float64
BQP.bqFloat64
        ScalarType 'BigQuery
ScalarType
BigQuery.IntegerScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
            (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Int64 -> Value
BigQuery.IntegerValue
            (Int64 -> Value)
-> Parser MetadataObjId 'Both n Int64
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int64
-> Parser MetadataObjId 'Both n Int64
-> Parser MetadataObjId 'Both n Int64
forall a. a -> a -> a
numericInputParser (Int64 -> Int64
BigQuery.intToInt64 (Int64 -> Int64) -> (Int32 -> Int64) -> Int32 -> Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32 -> Int64)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int) Parser MetadataObjId 'Both n Int64
forall origin (m :: * -> *).
MonadParse m =>
Parser origin 'Both m Int64
BQP.bqInt64
        ScalarType 'BigQuery
ScalarType
BigQuery.DecimalScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
            (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Decimal -> Value
BigQuery.DecimalValue
            (Decimal -> Value)
-> Parser MetadataObjId 'Both n Decimal
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Decimal
-> Parser MetadataObjId 'Both n Decimal
-> Parser MetadataObjId 'Both n Decimal
forall a. a -> a -> a
numericInputParser
              (Text -> Decimal
BigQuery.Decimal (Text -> Decimal) -> (Scientific -> Text) -> Scientific -> Decimal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Scientific -> Text
BigQuery.scientificToText (Scientific -> Decimal)
-> Parser MetadataObjId 'Both n Scientific
-> Parser MetadataObjId 'Both n Decimal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Scientific
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Scientific
P.scientific)
              Parser MetadataObjId 'Both n Decimal
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Decimal
BQP.bqDecimal
        ScalarType 'BigQuery
ScalarType
BigQuery.BigDecimalScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
            (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ BigDecimal -> Value
BigQuery.BigDecimalValue
            (BigDecimal -> Value)
-> Parser MetadataObjId 'Both n BigDecimal
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n BigDecimal
-> Parser MetadataObjId 'Both n BigDecimal
-> Parser MetadataObjId 'Both n BigDecimal
forall a. a -> a -> a
numericInputParser
              (Text -> BigDecimal
BigQuery.BigDecimal (Text -> BigDecimal)
-> (Scientific -> Text) -> Scientific -> BigDecimal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Scientific -> Text
BigQuery.scientificToText (Scientific -> BigDecimal)
-> Parser MetadataObjId 'Both n Scientific
-> Parser MetadataObjId 'Both n BigDecimal
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Scientific
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Scientific
P.scientific)
              Parser MetadataObjId 'Both n BigDecimal
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m BigDecimal
BQP.bqBigDecimal
        -- boolean type
        ScalarType 'BigQuery
ScalarType
BigQuery.BoolScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Bool -> Value
BigQuery.BoolValue (Bool -> Value)
-> Parser MetadataObjId 'Both n Bool
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Bool
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Bool
P.boolean
        ScalarType 'BigQuery
ScalarType
BigQuery.DateScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Date -> Value
BigQuery.DateValue (Date -> Value) -> (Text -> Date) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Date
BigQuery.Date (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
_Date
        ScalarType 'BigQuery
ScalarType
BigQuery.TimeScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Time -> Value
BigQuery.TimeValue (Time -> Value) -> (Text -> Time) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Time
BigQuery.Time (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
_Time
        ScalarType 'BigQuery
ScalarType
BigQuery.JsonScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Value -> Value
BigQuery.JsonValue (Value -> Value)
-> Parser MetadataObjId 'Both n Value
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Value
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Value
P.json
        ScalarType 'BigQuery
ScalarType
BigQuery.DatetimeScalarType -> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Datetime -> Value
BigQuery.DatetimeValue (Datetime -> Value) -> (Text -> Datetime) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Datetime
BigQuery.Datetime (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
_Datetime
        ScalarType 'BigQuery
ScalarType
BigQuery.GeographyScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Geography -> Value
BigQuery.GeographyValue (Geography -> Value) -> (Text -> Geography) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Geography
BigQuery.Geography (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall {m :: * -> *} {a} {origin}.
(MonadParse m, FromJSON a) =>
Name -> Parser origin 'Both m a
throughJSON Name
_Geography
        ScalarType 'BigQuery
ScalarType
BigQuery.TimestampScalarType ->
          Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n Value
 -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> Parser MetadataObjId 'Both n Value
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Timestamp -> Value
BigQuery.TimestampValue (Timestamp -> Value) -> (Text -> Timestamp) -> Text -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Timestamp
BigQuery.Timestamp (Text -> Value)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Parser MetadataObjId 'Both n Text
forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
_Timestamp
        ScalarType 'BigQuery
ty -> QErr -> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a. QErr -> SchemaT r m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (QErr -> SchemaT r m (Parser MetadataObjId 'Both n Value))
-> QErr -> SchemaT r m (Parser MetadataObjId 'Both n Value)
forall a b. (a -> b) -> a -> b
$ Text -> QErr
internalError (Text -> QErr) -> Text -> QErr
forall a b. (a -> b) -> a -> b
$ [Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ [Char]
"Type currently unsupported for BigQuery: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ ScalarType -> [Char]
forall a. Show a => a -> [Char]
show ScalarType 'BigQuery
ScalarType
ty
  ColumnEnumReference (EnumReference TableName 'BigQuery
tableName EnumValues
enumValues Maybe Name
customTableName) ->
    case [(EnumValue, EnumValueInfo)]
-> Maybe (NonEmpty (EnumValue, EnumValueInfo))
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty (EnumValues -> [(EnumValue, EnumValueInfo)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList EnumValues
enumValues) of
      Just NonEmpty (EnumValue, EnumValueInfo)
enumValuesList ->
        Parser 'Both n (ColumnValue 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) a.
MonadParse m =>
Parser 'Both m a -> Parser 'Both m (ValueWithOrigin a)
peelWithOrigin
          (Parser 'Both n (ColumnValue 'BigQuery)
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
-> (Parser MetadataObjId 'Both n Value
    -> Parser 'Both n (ColumnValue 'BigQuery))
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Value -> ColumnValue 'BigQuery)
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ColumnValue 'BigQuery)
forall a b.
(a -> b)
-> Parser MetadataObjId 'Both n a -> Parser MetadataObjId 'Both n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ColumnType 'BigQuery
-> ScalarValue 'BigQuery -> ColumnValue 'BigQuery
forall (b :: BackendType).
ColumnType b -> ScalarValue b -> ColumnValue b
ColumnValue ColumnType 'BigQuery
columnType)
          (Parser MetadataObjId 'Both n Value
 -> Parser 'Both n (ColumnValue 'BigQuery))
-> (Parser MetadataObjId 'Both n Value
    -> Parser MetadataObjId 'Both n Value)
-> Parser MetadataObjId 'Both n Value
-> Parser 'Both n (ColumnValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Nullability
-> Parser 'Both n (ScalarValue 'BigQuery)
-> Parser 'Both n (ScalarValue 'BigQuery)
forall (m :: * -> *).
MonadParse m =>
Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable Nullability
nullability
          (Parser MetadataObjId 'Both n Value
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
-> SchemaT r m (Parser MetadataObjId 'Both n Value)
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
bqEnumParser TableName 'BigQuery
tableName NonEmpty (EnumValue, EnumValueInfo)
enumValuesList Maybe Name
customTableName Nullability
nullability
      Maybe (NonEmpty (EnumValue, EnumValueInfo))
Nothing -> Code
-> Text
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
ValidationFailed Text
"empty enum values"
  where
    throughJSON :: Name -> Parser origin 'Both m a
throughJSON Name
scalarName =
      let schemaType :: Type origin 'Both
schemaType = Nullability
-> Definition origin (TypeInfo origin 'Both) -> Type origin 'Both
forall origin (k :: Kind).
Nullability
-> Definition origin (TypeInfo origin k) -> Type origin k
P.TNamed Nullability
P.NonNullable (Definition origin (TypeInfo origin 'Both) -> Type origin 'Both)
-> Definition origin (TypeInfo origin 'Both) -> Type origin 'Both
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> TypeInfo origin 'Both
-> Definition origin (TypeInfo origin 'Both)
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
scalarName Maybe Description
forall a. Maybe a
Nothing Maybe origin
forall a. Maybe a
Nothing [] TypeInfo origin 'Both
forall origin. TypeInfo origin 'Both
P.TIScalar
       in P.Parser
            { pType :: Type origin 'Both
pType = Type origin 'Both
schemaType,
              pParser :: ParserInput 'Both -> m a
pParser =
                GType -> InputValue Variable -> m Value
forall (m :: * -> *).
MonadParse m =>
GType -> InputValue Variable -> m Value
P.valueToJSON (Type origin 'Both -> GType
forall origin (k :: Kind). Type origin k -> GType
P.toGraphQLType Type origin 'Both
schemaType)
                  (InputValue Variable -> m Value)
-> (Value -> m a) -> InputValue Variable -> m a
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (QErr -> m a) -> (a -> m a) -> Either QErr a -> m a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (ParseErrorCode -> ErrorMessage -> m a
forall a. ParseErrorCode -> ErrorMessage -> m a
forall (m :: * -> *) a.
MonadParse m =>
ParseErrorCode -> ErrorMessage -> m a
P.parseErrorWith ParseErrorCode
P.ParseFailed (ErrorMessage -> m a) -> (QErr -> ErrorMessage) -> QErr -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ErrorMessage
toErrorMessage (Text -> ErrorMessage) -> (QErr -> Text) -> QErr -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QErr -> Text
qeError) a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
                  (Either QErr a -> m a) -> (Value -> Either QErr a) -> Value -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Value -> Parser a) -> Value -> Either QErr a
forall (m :: * -> *) v a. QErrM m => (v -> Parser a) -> v -> m a
runAesonParser Value -> Parser a
forall a. FromJSON a => Value -> Parser a
J.parseJSON
            }
    stringBased :: (MonadParse m) => G.Name -> Parser 'Both m Text
    stringBased :: forall (m :: * -> *). MonadParse m => Name -> Parser 'Both m Text
stringBased Name
scalarName =
      Parser Any 'Both m Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string {pType :: Type MetadataObjId 'Both
P.pType = Nullability
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
-> Type MetadataObjId 'Both
forall origin (k :: Kind).
Nullability
-> Definition origin (TypeInfo origin k) -> Type origin k
P.TNamed Nullability
P.NonNullable (Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
 -> Type MetadataObjId 'Both)
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
-> Type MetadataObjId 'Both
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> Maybe MetadataObjId
-> [Directive Void]
-> TypeInfo MetadataObjId 'Both
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
scalarName Maybe Description
forall a. Maybe a
Nothing Maybe MetadataObjId
forall a. Maybe a
Nothing [] TypeInfo MetadataObjId 'Both
forall origin. TypeInfo origin 'Both
P.TIScalar}

bqEnumParser ::
  (MonadBuildSchema 'BigQuery r m n) =>
  TableName 'BigQuery ->
  NonEmpty (EnumValue, EnumValueInfo) ->
  Maybe G.Name ->
  G.Nullability ->
  SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
bqEnumParser :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
TableName 'BigQuery
-> NonEmpty (EnumValue, EnumValueInfo)
-> Maybe Name
-> Nullability
-> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery))
bqEnumParser TableName 'BigQuery
tableName NonEmpty (EnumValue, EnumValueInfo)
enumValues Maybe Name
customTableName Nullability
nullability = do
  Name
enumName <- forall (b :: BackendType) r (m :: * -> *).
(Backend b, MonadError QErr m, Has (SourceInfo b) r) =>
TableName b -> Maybe Name -> SchemaT r m Name
mkEnumTypeName @'BigQuery TableName 'BigQuery
tableName Maybe Name
customTableName
  pure $ Nullability
-> Parser 'Both n (ScalarValue 'BigQuery)
-> Parser 'Both n (ScalarValue 'BigQuery)
forall (m :: * -> *).
MonadParse m =>
Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable Nullability
nullability (Parser 'Both n (ScalarValue 'BigQuery)
 -> Parser 'Both n (ScalarValue 'BigQuery))
-> Parser 'Both n (ScalarValue 'BigQuery)
-> Parser 'Both n (ScalarValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> NonEmpty (Definition EnumValueInfo, Value)
-> Parser MetadataObjId 'Both n Value
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> NonEmpty (Definition origin EnumValueInfo, a)
-> Parser origin 'Both m a
P.enum Name
enumName Maybe Description
forall a. Maybe a
Nothing ((EnumValue, EnumValueInfo)
-> (Definition EnumValueInfo, ScalarValue 'BigQuery)
(EnumValue, EnumValueInfo) -> (Definition EnumValueInfo, Value)
mkEnumValue ((EnumValue, EnumValueInfo) -> (Definition EnumValueInfo, Value))
-> NonEmpty (EnumValue, EnumValueInfo)
-> NonEmpty (Definition EnumValueInfo, Value)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (EnumValue, EnumValueInfo)
enumValues)
  where
    mkEnumValue :: (EnumValue, EnumValueInfo) -> (P.Definition P.EnumValueInfo, ScalarValue 'BigQuery)
    mkEnumValue :: (EnumValue, EnumValueInfo)
-> (Definition EnumValueInfo, ScalarValue 'BigQuery)
mkEnumValue (EnumValue Name
value, EnumValueInfo Maybe Text
description) =
      ( Name
-> Maybe Description
-> Maybe MetadataObjId
-> [Directive Void]
-> EnumValueInfo
-> Definition EnumValueInfo
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
value (Text -> Description
G.Description (Text -> Description) -> Maybe Text -> Maybe Description
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
description) Maybe MetadataObjId
forall a. Maybe a
Nothing [] EnumValueInfo
P.EnumValueInfo,
        Text -> Value
BigQuery.StringValue (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Name -> Text
G.unName Name
value
      )

bqPossiblyNullable ::
  (MonadParse m) =>
  G.Nullability ->
  Parser 'Both m (ScalarValue 'BigQuery) ->
  Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable :: forall (m :: * -> *).
MonadParse m =>
Nullability
-> Parser 'Both m (ScalarValue 'BigQuery)
-> Parser 'Both m (ScalarValue 'BigQuery)
bqPossiblyNullable (G.Nullability Bool
isNullable)
  | Bool
isNullable = (Maybe Value -> Value)
-> Parser MetadataObjId 'Both m (Maybe Value)
-> Parser MetadataObjId 'Both m Value
forall a b.
(a -> b)
-> Parser MetadataObjId 'Both m a -> Parser MetadataObjId 'Both m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Maybe Value -> Value
forall a. a -> Maybe a -> a
fromMaybe Value
BigQuery.NullValue) (Parser MetadataObjId 'Both m (Maybe Value)
 -> Parser MetadataObjId 'Both m Value)
-> (Parser MetadataObjId 'Both m Value
    -> Parser MetadataObjId 'Both m (Maybe Value))
-> Parser MetadataObjId 'Both m Value
-> Parser MetadataObjId 'Both m Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser MetadataObjId 'Both m Value
-> Parser MetadataObjId 'Both m (Maybe Value)
forall origin (k :: Kind) (m :: * -> *) a.
(MonadParse m, 'Input <: k) =>
Parser origin k m a -> Parser origin k m (Maybe a)
P.nullable
  | Bool
otherwise = Parser MetadataObjId 'Both m (ScalarValue 'BigQuery)
-> Parser MetadataObjId 'Both m (ScalarValue 'BigQuery)
Parser MetadataObjId 'Both m Value
-> Parser MetadataObjId 'Both m Value
forall a. a -> a
id

bqOrderByOperators ::
  NamingCase ->
  ( G.Name,
    NonEmpty
      ( P.Definition P.EnumValueInfo,
        (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery)
      )
  )
bqOrderByOperators :: NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery)))
bqOrderByOperators NamingCase
_tCase =
  (Name
Name._order_by,)
    (NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
 -> (Name,
     NonEmpty
       (Definition EnumValueInfo,
        (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery))))
-> NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'BigQuery, NullsOrderType 'BigQuery)))
forall a b. (a -> b) -> a -> b
$
    -- NOTE: NamingCase is not being used here as we don't support naming conventions for this DB
    [(Definition EnumValueInfo, (Order, NullsOrder))]
-> NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
forall a. HasCallStack => [a] -> NonEmpty a
NE.fromList
      [ ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc Description
"in ascending order, nulls first",
          (Order
BigQuery.AscOrder, NullsOrder
BigQuery.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc_nulls_first Description
"in ascending order, nulls first",
          (Order
BigQuery.AscOrder, NullsOrder
BigQuery.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc_nulls_last Description
"in ascending order, nulls last",
          (Order
BigQuery.AscOrder, NullsOrder
BigQuery.NullsLast)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc Description
"in descending order, nulls last",
          (Order
BigQuery.DescOrder, NullsOrder
BigQuery.NullsLast)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc_nulls_first Description
"in descending order, nulls first",
          (Order
BigQuery.DescOrder, NullsOrder
BigQuery.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall {origin}.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc_nulls_last Description
"in descending order, nulls last",
          (Order
BigQuery.DescOrder, NullsOrder
BigQuery.NullsLast)
        )
      ]
  where
    define :: Name -> Description -> Definition origin EnumValueInfo
define Name
name Description
desc = Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> EnumValueInfo
-> Definition origin EnumValueInfo
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
name (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
desc) Maybe origin
forall a. Maybe a
Nothing [] EnumValueInfo
P.EnumValueInfo

bqComparisonExps ::
  forall m n r.
  (MonadBuildSchema 'BigQuery r m n) =>
  ColumnType 'BigQuery ->
  SchemaT r m (Parser 'Input n [ComparisonExp 'BigQuery])
bqComparisonExps :: forall (m :: * -> *) (n :: * -> *) r.
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> SchemaT r m (Parser 'Input n [ComparisonExp 'BigQuery])
bqComparisonExps = Name
-> (ColumnType 'BigQuery
    -> SchemaT
         r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]))
-> ColumnType 'BigQuery
-> SchemaT
     r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery])
forall (m :: * -> *) a (p :: (* -> *) -> * -> *) (n :: * -> *) b.
(MonadMemoize m, Ord a, Typeable a, Typeable p, MonadParse n,
 Typeable b) =>
Name -> (a -> m (p n b)) -> a -> m (p n b)
P.memoize 'comparisonExps ((ColumnType 'BigQuery
  -> SchemaT
       r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]))
 -> ColumnType 'BigQuery
 -> SchemaT
      r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]))
-> (ColumnType 'BigQuery
    -> SchemaT
         r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]))
-> ColumnType 'BigQuery
-> SchemaT
     r m (Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery])
forall a b. (a -> b) -> a -> b
$ \ColumnType 'BigQuery
columnType -> do
  DangerouslyCollapseBooleans
collapseIfNull <- (SchemaOptions -> DangerouslyCollapseBooleans)
-> SchemaT r m DangerouslyCollapseBooleans
forall r (m :: * -> *) a b.
(MonadReader r m, Has a r) =>
(a -> b) -> m b
retrieve SchemaOptions -> DangerouslyCollapseBooleans
Options.soDangerousBooleanCollapse

  Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery))
dWithinGeogOpParser <- SchemaT
  r m (Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery)))
forall (m :: * -> *) (n :: * -> *) r.
MonadBuildSchema 'BigQuery r m n =>
SchemaT
  r m (Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery)))
geographyWithinDistanceInput
  NamingCase
tCase <- (SourceInfo 'BigQuery -> NamingCase) -> SchemaT r m NamingCase
forall r (m :: * -> *) a b.
(MonadReader r m, Has a r) =>
(a -> b) -> m b
retrieve ((SourceInfo 'BigQuery -> NamingCase) -> SchemaT r m NamingCase)
-> (SourceInfo 'BigQuery -> NamingCase) -> SchemaT r m NamingCase
forall a b. (a -> b) -> a -> b
$ ResolvedSourceCustomization -> NamingCase
_rscNamingConvention (ResolvedSourceCustomization -> NamingCase)
-> (SourceInfo 'BigQuery -> ResolvedSourceCustomization)
-> SourceInfo 'BigQuery
-> NamingCase
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (b :: BackendType).
SourceInfo b -> ResolvedSourceCustomization
_siCustomization @'BigQuery
  -- see Note [Columns in comparison expression are never nullable]
  Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser <- ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser ColumnType 'BigQuery
columnType (Bool -> Nullability
G.Nullability Bool
False)
  -- textParser <- columnParser (ColumnScalar @'BigQuery BigQuery.StringScalarType) (G.Nullability False)
  let name :: Name
name = Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)) -> Name
forall a. HasName a => a -> Name
P.getName Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__BigQuery_comparison_exp
      desc :: Description
desc =
        Text -> Description
G.Description
          (Text -> Description) -> Text -> Description
forall a b. (a -> b) -> a -> b
$ Text
"Boolean expression to compare columns of type "
          Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)) -> Name
forall a. HasName a => a -> Name
P.getName Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser
          Name -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
". All fields are combined with logical 'AND'."
      -- textListParser = fmap openValueOrigin <$> P.list textParser
      columnListParser :: Parser MetadataObjId 'Both n [ColumnValue 'BigQuery]
columnListParser = (ValueWithOrigin (ColumnValue 'BigQuery) -> ColumnValue 'BigQuery)
-> [ValueWithOrigin (ColumnValue 'BigQuery)]
-> [ColumnValue 'BigQuery]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ValueWithOrigin (ColumnValue 'BigQuery) -> ColumnValue 'BigQuery
forall a. ValueWithOrigin a -> a
IR.openValueOrigin ([ValueWithOrigin (ColumnValue 'BigQuery)]
 -> [ColumnValue 'BigQuery])
-> Parser
     MetadataObjId 'Both n [ValueWithOrigin (ColumnValue 'BigQuery)]
-> Parser MetadataObjId 'Both n [ColumnValue 'BigQuery]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser
     MetadataObjId 'Both n [ValueWithOrigin (ColumnValue 'BigQuery)]
forall origin (k :: Kind) (m :: * -> *) a.
(MonadParse m, 'Input <: k) =>
Parser origin k m a -> Parser origin k m [a]
P.list Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser
      mkListLiteral :: [ColumnValue 'BigQuery] -> IR.UnpreparedValue 'BigQuery
      mkListLiteral :: [ColumnValue 'BigQuery] -> UnpreparedValue 'BigQuery
mkListLiteral =
        SQLExpression 'BigQuery -> UnpreparedValue 'BigQuery
Expression -> UnpreparedValue 'BigQuery
forall (b :: BackendType). SQLExpression b -> UnpreparedValue b
IR.UVLiteral
          (Expression -> UnpreparedValue 'BigQuery)
-> ([ColumnValue 'BigQuery] -> Expression)
-> [ColumnValue 'BigQuery]
-> UnpreparedValue 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Expression] -> Expression
BigQuery.ListExpression
          ([Expression] -> Expression)
-> ([ColumnValue 'BigQuery] -> [Expression])
-> [ColumnValue 'BigQuery]
-> Expression
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ColumnValue 'BigQuery -> Expression)
-> [ColumnValue 'BigQuery] -> [Expression]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
            ( \ColumnValue 'BigQuery
columnValue ->
                TypedValue -> Expression
BigQuery.ValueExpression
                  ( ScalarType -> Value -> TypedValue
BigQuery.TypedValue
                      (ColumnType 'BigQuery -> ScalarType
scalarTypeFromColumnType (ColumnValue 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ColumnValue b -> ColumnType b
cvType ColumnValue 'BigQuery
columnValue))
                      (ColumnValue 'BigQuery -> ScalarValue 'BigQuery
forall (b :: BackendType). ColumnValue b -> ScalarValue b
cvValue ColumnValue 'BigQuery
columnValue)
                  )
            )
  pure
    $ Name
-> Maybe Description
-> InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery]
-> Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Input m a
P.object Name
name (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
desc)
    (InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery]
 -> Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery])
-> InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery]
-> Parser MetadataObjId 'Input n [ComparisonExp 'BigQuery]
forall a b. (a -> b) -> a -> b
$ ([Maybe (ComparisonExp 'BigQuery)] -> [ComparisonExp 'BigQuery])
-> InputFieldsParser
     MetadataObjId n [Maybe (ComparisonExp 'BigQuery)]
-> InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery]
forall a b.
(a -> b)
-> InputFieldsParser MetadataObjId n a
-> InputFieldsParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Maybe (ComparisonExp 'BigQuery)] -> [ComparisonExp 'BigQuery]
forall a. [Maybe a] -> [a]
forall (f :: * -> *) a. Filterable f => f (Maybe a) -> f a
catMaybes
    (InputFieldsParser
   MetadataObjId n [Maybe (ComparisonExp 'BigQuery)]
 -> InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery])
-> InputFieldsParser
     MetadataObjId n [Maybe (ComparisonExp 'BigQuery)]
-> InputFieldsParser MetadataObjId n [ComparisonExp 'BigQuery]
forall a b. (a -> b) -> a -> b
$ [InputFieldsParser
   MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> InputFieldsParser
     MetadataObjId n [Maybe (ComparisonExp 'BigQuery)]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
sequenceA
    ([InputFieldsParser
    MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
 -> InputFieldsParser
      MetadataObjId n [Maybe (ComparisonExp 'BigQuery)])
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> InputFieldsParser
     MetadataObjId n [Maybe (ComparisonExp 'BigQuery)]
forall a b. (a -> b) -> a -> b
$ [[InputFieldsParser
    MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
      [ -- from https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types:
        -- GEOGRAPHY comparisons are not supported. To compare GEOGRAPHY values, use ST_Equals.
        Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard ((ScalarType 'BigQuery -> Bool) -> ColumnType 'BigQuery -> Bool
forall (b :: BackendType).
(ScalarType b -> Bool) -> ColumnType b -> Bool
isScalarColumnWhere (ScalarType -> ScalarType -> Bool
forall a. Eq a => a -> a -> Bool
/= ScalarType
BigQuery.GeographyScalarType) ColumnType 'BigQuery
columnType)
          [()]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall a b. [a] -> [b] -> [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> NamingCase
-> DangerouslyCollapseBooleans
-> Parser 'Both n (UnpreparedValue 'BigQuery)
-> Parser 'Both n (UnpreparedValue 'BigQuery)
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall (n :: * -> *) (k :: Kind) (b :: BackendType).
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> Parser k n (UnpreparedValue b)
-> Parser k n (UnpreparedValue b)
-> [InputFieldsParser n (Maybe (OpExpG b (UnpreparedValue b)))]
equalityOperators
            NamingCase
tCase
            DangerouslyCollapseBooleans
collapseIfNull
            (ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> UnpreparedValue 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser)
            ([ColumnValue 'BigQuery] -> UnpreparedValue 'BigQuery
mkListLiteral ([ColumnValue 'BigQuery] -> UnpreparedValue 'BigQuery)
-> Parser MetadataObjId 'Both n [ColumnValue 'BigQuery]
-> Parser 'Both n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n [ColumnValue 'BigQuery]
columnListParser),
        Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard ((ScalarType 'BigQuery -> Bool) -> ColumnType 'BigQuery -> Bool
forall (b :: BackendType).
(ScalarType b -> Bool) -> ColumnType b -> Bool
isScalarColumnWhere (ScalarType -> ScalarType -> Bool
forall a. Eq a => a -> a -> Bool
/= ScalarType
BigQuery.GeographyScalarType) ColumnType 'BigQuery
columnType)
          [()]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall a b. [a] -> [b] -> [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> NamingCase
-> DangerouslyCollapseBooleans
-> Parser 'Both n (UnpreparedValue 'BigQuery)
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall (n :: * -> *) (k :: Kind) (b :: BackendType).
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> Parser k n (UnpreparedValue b)
-> [InputFieldsParser n (Maybe (OpExpG b (UnpreparedValue b)))]
comparisonOperators
            NamingCase
tCase
            DangerouslyCollapseBooleans
collapseIfNull
            (ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> UnpreparedValue 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
        -- Ops for String type
        Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard ((ScalarType 'BigQuery -> Bool) -> ColumnType 'BigQuery -> Bool
forall (b :: BackendType).
(ScalarType b -> Bool) -> ColumnType b -> Bool
isScalarColumnWhere (ScalarType -> ScalarType -> Bool
forall a. Eq a => a -> a -> Bool
== ScalarType
BigQuery.StringScalarType) ColumnType 'BigQuery
columnType)
          [()]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall a b. [a] -> [b] -> [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [ NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 (Name -> GQLNameIdentifier
C.fromAutogeneratedName Name
Name.__like)
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column match the given pattern")
                 (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
field -> OpExpG backend field
ALIKE (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 (Name -> GQLNameIdentifier
C.fromAutogeneratedName Name
Name.__nlike)
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column NOT match the given pattern")
                 (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
field -> OpExpG backend field
ANLIKE (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser)
             ],
        -- Ops for Bytes type
        Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard ((ScalarType 'BigQuery -> Bool) -> ColumnType 'BigQuery -> Bool
forall (b :: BackendType).
(ScalarType b -> Bool) -> ColumnType b -> Bool
isScalarColumnWhere (ScalarType -> ScalarType -> Bool
forall a. Eq a => a -> a -> Bool
== ScalarType
BigQuery.BytesScalarType) ColumnType 'BigQuery
columnType)
          [()]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall a b. [a] -> [b] -> [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [ NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 (Name -> GQLNameIdentifier
C.fromAutogeneratedName Name
Name.__like)
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column match the given pattern")
                 (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
field -> OpExpG backend field
ALIKE (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 (Name -> GQLNameIdentifier
C.fromAutogeneratedName Name
Name.__nlike)
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column NOT match the given pattern")
                 (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
field -> OpExpG backend field
ANLIKE (UnpreparedValue 'BigQuery -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser)
             ],
        -- Ops for Geography type
        Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard ((ScalarType 'BigQuery -> Bool) -> ColumnType 'BigQuery -> Bool
forall (b :: BackendType).
(ScalarType b -> Bool) -> ColumnType b -> Bool
isScalarColumnWhere (ScalarType -> ScalarType -> Bool
forall a. Eq a => a -> a -> Bool
== ScalarType
BigQuery.GeographyScalarType) ColumnType 'BigQuery
columnType)
          [()]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
-> [InputFieldsParser
      MetadataObjId n (Maybe (ComparisonExp 'BigQuery))]
forall a b. [a] -> [b] -> [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [ NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "contains"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column contain the given geography value")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnpreparedValue 'BigQuery
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. a -> BooleanOperators a
BigQuery.ASTContains (UnpreparedValue 'BigQuery
 -> BooleanOperators (UnpreparedValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "equals"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"is the column equal to given geography value (directionality is ignored)")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnpreparedValue 'BigQuery
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. a -> BooleanOperators a
BigQuery.ASTEquals (UnpreparedValue 'BigQuery
 -> BooleanOperators (UnpreparedValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "touches"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column have at least one point in common with the given geography value")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnpreparedValue 'BigQuery
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. a -> BooleanOperators a
BigQuery.ASTTouches (UnpreparedValue 'BigQuery
 -> BooleanOperators (UnpreparedValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "within"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"is the column contained in the given geography value")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnpreparedValue 'BigQuery
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. a -> BooleanOperators a
BigQuery.ASTWithin (UnpreparedValue 'BigQuery
 -> BooleanOperators (UnpreparedValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Both n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "intersects"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"does the column spatially intersect the given geography value")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnpreparedValue 'BigQuery
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. a -> BooleanOperators a
BigQuery.ASTIntersects (UnpreparedValue 'BigQuery
 -> BooleanOperators (UnpreparedValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> UnpreparedValue 'BigQuery)
-> ValueWithOrigin (ColumnValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> Parser 'Both n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser),
               NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser 'Input n (ComparisonExp 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (Maybe (ComparisonExp 'BigQuery))
forall (n :: * -> *) (k :: Kind) a.
(MonadParse n, 'Input <: k) =>
NamingCase
-> DangerouslyCollapseBooleans
-> GQLNameIdentifier
-> Maybe Description
-> Parser k n a
-> InputFieldsParser n (Maybe a)
mkBoolOperator
                 NamingCase
tCase
                 DangerouslyCollapseBooleans
collapseIfNull
                 ((Name, [NameSuffix]) -> GQLNameIdentifier
C.fromAutogeneratedTuple $$(G.litGQLIdentifier ["_st", "d", "within"]))
                 (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
"is the column within a given distance from the given geometry value")
                 (BooleanOperators 'BigQuery (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
BooleanOperators (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall (backend :: BackendType) field.
BooleanOperators backend field -> OpExpG backend field
ABackendSpecific (BooleanOperators (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> (DWithinGeogOp (UnpreparedValue 'BigQuery)
    -> BooleanOperators (UnpreparedValue 'BigQuery))
-> DWithinGeogOp (UnpreparedValue 'BigQuery)
-> ComparisonExp 'BigQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DWithinGeogOp (UnpreparedValue 'BigQuery)
-> BooleanOperators (UnpreparedValue 'BigQuery)
forall a. DWithinGeogOp a -> BooleanOperators a
BigQuery.ASTDWithin (DWithinGeogOp (UnpreparedValue 'BigQuery)
 -> ComparisonExp 'BigQuery)
-> Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery))
-> Parser 'Input n (ComparisonExp 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery))
dWithinGeogOpParser)
             ]
      ]

bqCountTypeInput ::
  (MonadParse n) =>
  Maybe (Parser 'Both n (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)) ->
  InputFieldsParser n (IR.CountDistinct -> CountType 'BigQuery (IR.UnpreparedValue 'BigQuery))
bqCountTypeInput :: forall (n :: * -> *).
MonadParse n =>
Maybe
  (Parser
     'Both
     n
     (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
bqCountTypeInput = \case
  Just Parser
  'Both
  n
  (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)
columnEnum -> do
    Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
columns <- Name
-> Maybe Description
-> Parser
     MetadataObjId
     'Both
     n
     [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> InputFieldsParser
     MetadataObjId
     n
     (Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)])
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name._columns Maybe Description
forall a. Maybe a
Nothing (Parser
   MetadataObjId
   'Both
   n
   [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
 -> InputFieldsParser
      MetadataObjId
      n
      (Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]))
-> Parser
     MetadataObjId
     'Both
     n
     [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> InputFieldsParser
     MetadataObjId
     n
     (Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)])
forall a b. (a -> b) -> a -> b
$ Parser
  MetadataObjId
  'Both
  n
  (ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
-> Parser
     MetadataObjId
     'Both
     n
     [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
forall origin (k :: Kind) (m :: * -> *) a.
(MonadParse m, 'Input <: k) =>
Parser origin k m a -> Parser origin k m [a]
P.list Parser
  'Both
  n
  (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)
Parser
  MetadataObjId
  'Both
  n
  (ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
columnEnum
    pure $ (CountDistinct
 -> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
 -> Const (Countable ColumnName) (UnpreparedValue 'BigQuery))
-> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> CountDistinct
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall a b c. (a -> b -> c) -> b -> a -> c
flip CountDistinct
-> Maybe
     [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
CountDistinct
-> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
mkCountType Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
columns
  Maybe
  (Parser
     'Both
     n
     (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery))
Nothing -> (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
forall a. a -> InputFieldsParser MetadataObjId n a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
 -> InputFieldsParser
      n
      (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery)))
-> (CountDistinct
    -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> InputFieldsParser
     n
     (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
forall a b. (a -> b) -> a -> b
$ (CountDistinct
 -> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
 -> Const (Countable ColumnName) (UnpreparedValue 'BigQuery))
-> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> CountDistinct
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall a b c. (a -> b -> c) -> b -> a -> c
flip CountDistinct
-> Maybe
     [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
CountDistinct
-> Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
mkCountType Maybe [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
forall a. Maybe a
Nothing
  where
    mkCountType :: IR.CountDistinct -> Maybe [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)] -> CountType 'BigQuery (IR.UnpreparedValue 'BigQuery)
    mkCountType :: CountDistinct
-> Maybe
     [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
mkCountType CountDistinct
_ Maybe
  [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
Nothing = Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall {k} a (b :: k). a -> Const a b
Const (Countable ColumnName
 -> Const (Countable ColumnName) (UnpreparedValue 'BigQuery))
-> Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ Countable ColumnName
forall fieldname. Countable fieldname
BigQuery.StarCountable
    mkCountType CountDistinct
IR.SelectCountDistinct (Just [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
cols) =
      CountType 'BigQuery (UnpreparedValue 'BigQuery)
-> (NonEmpty ColumnName
    -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> Maybe (NonEmpty ColumnName)
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall {k} a (b :: k). a -> Const a b
Const Countable ColumnName
forall fieldname. Countable fieldname
BigQuery.StarCountable) (Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall {k} a (b :: k). a -> Const a b
Const (Countable ColumnName
 -> Const (Countable ColumnName) (UnpreparedValue 'BigQuery))
-> (NonEmpty ColumnName -> Countable ColumnName)
-> NonEmpty ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty ColumnName -> Countable ColumnName
forall fieldname. NonEmpty fieldname -> Countable fieldname
BigQuery.DistinctCountable) (Maybe (NonEmpty ColumnName)
 -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> Maybe (NonEmpty ColumnName)
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ [ColumnName] -> Maybe (NonEmpty ColumnName)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ((ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
-> ColumnName
forall a b. (a, b) -> a
fst ((ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
 -> ColumnName)
-> [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> [ColumnName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
[(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
cols) -- TODO(redactionExp): Deal with redaction expressions
    mkCountType CountDistinct
IR.SelectCountNonDistinct (Just [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
cols) =
      CountType 'BigQuery (UnpreparedValue 'BigQuery)
-> (NonEmpty ColumnName
    -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> Maybe (NonEmpty ColumnName)
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall {k} a (b :: k). a -> Const a b
Const Countable ColumnName
forall fieldname. Countable fieldname
BigQuery.StarCountable) (Countable ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall {k} a (b :: k). a -> Const a b
Const (Countable ColumnName
 -> Const (Countable ColumnName) (UnpreparedValue 'BigQuery))
-> (NonEmpty ColumnName -> Countable ColumnName)
-> NonEmpty ColumnName
-> Const (Countable ColumnName) (UnpreparedValue 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty ColumnName -> Countable ColumnName
forall fieldname. NonEmpty fieldname -> Countable fieldname
BigQuery.NonNullFieldCountable) (Maybe (NonEmpty ColumnName)
 -> CountType 'BigQuery (UnpreparedValue 'BigQuery))
-> Maybe (NonEmpty ColumnName)
-> CountType 'BigQuery (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ [ColumnName] -> Maybe (NonEmpty ColumnName)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ((ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
-> ColumnName
forall a b. (a, b) -> a
fst ((ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)
 -> ColumnName)
-> [(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
-> [ColumnName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)]
[(ColumnName, AnnRedactionExpUnpreparedValue 'BigQuery)]
cols) -- TODO(redactionExp): Deal with redaction expressions

geographyWithinDistanceInput ::
  forall m n r.
  (MonadBuildSchema 'BigQuery r m n) =>
  SchemaT r m (Parser 'Input n (DWithinGeogOp (IR.UnpreparedValue 'BigQuery)))
geographyWithinDistanceInput :: forall (m :: * -> *) (n :: * -> *) r.
MonadBuildSchema 'BigQuery r m n =>
SchemaT
  r m (Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery)))
geographyWithinDistanceInput = do
  Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
geographyParser <- ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar ScalarType 'BigQuery
ScalarType
BigQuery.GeographyScalarType) (Bool -> Nullability
G.Nullability Bool
False)
  -- practically BigQuery (as of 2021-11-19) doesn't support TRUE as use_spheroid parameter for ST_DWITHIN
  Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
booleanParser <- ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar ScalarType 'BigQuery
ScalarType
BigQuery.BoolScalarType) (Bool -> Nullability
G.Nullability Bool
True)
  Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
floatParser <- ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar ScalarType 'BigQuery
ScalarType
BigQuery.FloatScalarType) (Bool -> Nullability
G.Nullability Bool
False)
  pure
    $ Name
-> Maybe Description
-> InputFieldsParser
     MetadataObjId n (DWithinGeogOp (UnpreparedValue 'BigQuery))
-> Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery))
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Input m a
P.object Name
Name._st_dwithin_input Maybe Description
forall a. Maybe a
Nothing
    (InputFieldsParser
   MetadataObjId n (DWithinGeogOp (UnpreparedValue 'BigQuery))
 -> Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery)))
-> InputFieldsParser
     MetadataObjId n (DWithinGeogOp (UnpreparedValue 'BigQuery))
-> Parser 'Input n (DWithinGeogOp (UnpreparedValue 'BigQuery))
forall a b. (a -> b) -> a -> b
$ UnpreparedValue 'BigQuery
-> UnpreparedValue 'BigQuery
-> UnpreparedValue 'BigQuery
-> DWithinGeogOp (UnpreparedValue 'BigQuery)
forall field. field -> field -> field -> DWithinGeogOp field
DWithinGeogOp
    (UnpreparedValue 'BigQuery
 -> UnpreparedValue 'BigQuery
 -> UnpreparedValue 'BigQuery
 -> DWithinGeogOp (UnpreparedValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId
     n
     (UnpreparedValue 'BigQuery
      -> UnpreparedValue 'BigQuery
      -> DWithinGeogOp (UnpreparedValue 'BigQuery))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name
-> Maybe Description
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m a
P.field Name
Name._distance Maybe Description
forall a. Maybe a
Nothing Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
floatParser)
    InputFieldsParser
  MetadataObjId
  n
  (UnpreparedValue 'BigQuery
   -> UnpreparedValue 'BigQuery
   -> DWithinGeogOp (UnpreparedValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId
     n
     (UnpreparedValue 'BigQuery
      -> DWithinGeogOp (UnpreparedValue 'BigQuery))
forall a b.
InputFieldsParser MetadataObjId n (a -> b)
-> InputFieldsParser MetadataObjId n a
-> InputFieldsParser MetadataObjId n b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name
-> Maybe Description
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m a
P.field Name
Name._from Maybe Description
forall a. Maybe a
Nothing Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
geographyParser)
    InputFieldsParser
  MetadataObjId
  n
  (UnpreparedValue 'BigQuery
   -> DWithinGeogOp (UnpreparedValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (DWithinGeogOp (UnpreparedValue 'BigQuery))
forall a b.
InputFieldsParser MetadataObjId n (a -> b)
-> InputFieldsParser MetadataObjId n a
-> InputFieldsParser MetadataObjId n b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter (ValueWithOrigin (ColumnValue 'BigQuery)
 -> UnpreparedValue 'BigQuery)
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser MetadataObjId n (UnpreparedValue 'BigQuery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name
-> Maybe Description
-> Value Void
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Value Void
-> Parser origin k m a
-> InputFieldsParser origin m a
P.fieldWithDefault Name
Name._use_spheroid Maybe Description
forall a. Maybe a
Nothing (Bool -> Value Void
forall var. Bool -> Value var
G.VBoolean Bool
False) Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
booleanParser)

-- | Computed field parser.
bqComputedField ::
  forall r m n.
  (MonadBuildSchema 'BigQuery r m n) =>
  ComputedFieldInfo 'BigQuery ->
  TableName 'BigQuery ->
  TableInfo 'BigQuery ->
  SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
bqComputedField :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ComputedFieldInfo 'BigQuery
-> TableName 'BigQuery
-> TableInfo 'BigQuery
-> SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
bqComputedField ComputedFieldInfo {Maybe Text
ComputedFieldName
ComputedFieldReturn 'BigQuery
XComputedField 'BigQuery
ComputedFieldFunction 'BigQuery
_cfiXComputedFieldInfo :: XComputedField 'BigQuery
_cfiName :: ComputedFieldName
_cfiFunction :: ComputedFieldFunction 'BigQuery
_cfiReturnType :: ComputedFieldReturn 'BigQuery
_cfiDescription :: Maybe Text
_cfiXComputedFieldInfo :: forall (b :: BackendType). ComputedFieldInfo b -> XComputedField b
_cfiName :: forall (b :: BackendType). ComputedFieldInfo b -> ComputedFieldName
_cfiFunction :: forall (b :: BackendType).
ComputedFieldInfo b -> ComputedFieldFunction b
_cfiReturnType :: forall (b :: BackendType).
ComputedFieldInfo b -> ComputedFieldReturn b
_cfiDescription :: forall (b :: BackendType). ComputedFieldInfo b -> Maybe Text
..} TableName 'BigQuery
tableName TableInfo 'BigQuery
tableInfo = MaybeT (SchemaT r m) (FieldParser n (AnnotatedField 'BigQuery))
-> SchemaT r m (Maybe (FieldParser n (AnnotatedField 'BigQuery)))
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT do
  SourceInfo 'BigQuery
sourceInfo :: SourceInfo 'BigQuery <- (r -> SourceInfo 'BigQuery)
-> MaybeT (SchemaT r m) (SourceInfo 'BigQuery)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks r -> SourceInfo 'BigQuery
forall a t. Has a t => t -> a
getter
  let customization :: ResolvedSourceCustomization
customization = SourceInfo 'BigQuery -> ResolvedSourceCustomization
forall (b :: BackendType).
SourceInfo b -> ResolvedSourceCustomization
_siCustomization SourceInfo 'BigQuery
sourceInfo
      mkTypename :: Name -> Name
mkTypename = MkTypename -> Name -> Name
runMkTypename (MkTypename -> Name -> Name) -> MkTypename -> Name -> Name
forall a b. (a -> b) -> a -> b
$ ResolvedSourceCustomization -> MkTypename
_rscTypeNames ResolvedSourceCustomization
customization
  StringifyNumbers
stringifyNumbers <- (SchemaOptions -> StringifyNumbers)
-> MaybeT (SchemaT r m) StringifyNumbers
forall r (m :: * -> *) a b.
(MonadReader r m, Has a r) =>
(a -> b) -> m b
retrieve SchemaOptions -> StringifyNumbers
Options.soStringifyNumbers
  RoleName
roleName <- (SchemaContext -> RoleName) -> MaybeT (SchemaT r m) RoleName
forall r (m :: * -> *) a b.
(MonadReader r m, Has a r) =>
(a -> b) -> m b
retrieve SchemaContext -> RoleName
scRole
  Name
fieldName <- SchemaT r m Name -> MaybeT (SchemaT r m) Name
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (SchemaT r m Name -> MaybeT (SchemaT r m) Name)
-> SchemaT r m Name -> MaybeT (SchemaT r m) Name
forall a b. (a -> b) -> a -> b
$ Text -> SchemaT r m Name
forall (m :: * -> *). MonadError QErr m => Text -> m Name
textToName (Text -> SchemaT r m Name) -> Text -> SchemaT r m Name
forall a b. (a -> b) -> a -> b
$ ComputedFieldName -> Text
computedFieldNameToText ComputedFieldName
_cfiName
  InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
functionArgsParser <- SchemaT
  r
  m
  (InputFieldsParser
     n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
-> MaybeT
     (SchemaT r m)
     (InputFieldsParser
        n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (SchemaT
   r
   m
   (InputFieldsParser
      n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
 -> MaybeT
      (SchemaT r m)
      (InputFieldsParser
         n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery))))
-> SchemaT
     r
     m
     (InputFieldsParser
        n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
-> MaybeT
     (SchemaT r m)
     (InputFieldsParser
        n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
forall a b. (a -> b) -> a -> b
$ (Name -> Name)
-> ComputedFieldFunction 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
computedFieldFunctionArgs Name -> Name
mkTypename ComputedFieldFunction 'BigQuery
_cfiFunction
  case ComputedFieldReturn 'BigQuery
_cfiReturnType of
    BigQuery.ReturnExistingTable TableName
returnTable -> do
      TableInfo 'BigQuery
returnTableInfo <- SchemaT r m (TableInfo 'BigQuery)
-> MaybeT (SchemaT r m) (TableInfo 'BigQuery)
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (SchemaT r m (TableInfo 'BigQuery)
 -> MaybeT (SchemaT r m) (TableInfo 'BigQuery))
-> SchemaT r m (TableInfo 'BigQuery)
-> MaybeT (SchemaT r m) (TableInfo 'BigQuery)
forall a b. (a -> b) -> a -> b
$ TableName 'BigQuery -> SchemaT r m (TableInfo 'BigQuery)
forall (b :: BackendType) r (m :: * -> *).
(Backend b, MonadError QErr m, MonadReader r m,
 Has (SourceInfo b) r) =>
TableName b -> m (TableInfo b)
askTableInfo TableName 'BigQuery
TableName
returnTable
      SelPermInfo 'BigQuery
returnTablePermissions <- Maybe (SelPermInfo 'BigQuery)
-> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery)
forall (m :: * -> *) b. Applicative m => Maybe b -> MaybeT m b
hoistMaybe (Maybe (SelPermInfo 'BigQuery)
 -> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery))
-> Maybe (SelPermInfo 'BigQuery)
-> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery)
forall a b. (a -> b) -> a -> b
$ RoleName -> TableInfo 'BigQuery -> Maybe (SelPermInfo 'BigQuery)
forall (b :: BackendType).
RoleName -> TableInfo b -> Maybe (SelPermInfo b)
tableSelectPermissions RoleName
roleName TableInfo 'BigQuery
returnTableInfo
      Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
selectionSetParser <- SchemaT
  r
  m
  (Maybe
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
-> MaybeT
     (SchemaT r m)
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT ((Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
 -> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
-> Maybe
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
-> Maybe
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
forall (m :: * -> *) origin a.
Parser origin 'Output m a -> Parser origin 'Output m a
P.multiple (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
 -> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
-> (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
    -> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
forall (m :: * -> *) origin (k :: Kind) a.
Parser origin k m a -> Parser origin k m a
P.nonNullableParser) (Maybe (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
 -> Maybe
      (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
-> SchemaT
     r
     m
     (Maybe
        (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
-> SchemaT
     r
     m
     (Maybe
        (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TableInfo 'BigQuery
-> SchemaT
     r
     m
     (Maybe
        (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> SchemaT
     r m (Maybe (Parser 'Output n (AnnotatedFields 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendTableSelectSchema b, MonadBuildSourceSchema b r m n) =>
TableInfo b
-> SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
tableSelectionSet TableInfo 'BigQuery
returnTableInfo)
      InputFieldsParser
  n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
selectArgsParser <- SchemaT
  r
  m
  (InputFieldsParser
     n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
-> MaybeT
     (SchemaT r m)
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (SchemaT
   r
   m
   (InputFieldsParser
      n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
 -> MaybeT
      (SchemaT r m)
      (InputFieldsParser
         n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))))
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
-> MaybeT
     (SchemaT r m)
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall a b. (a -> b) -> a -> b
$ TableInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSourceSchema 'BigQuery r m n =>
TableInfo 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendTableSelectSchema b, MonadBuildSourceSchema b r m n) =>
TableInfo b
-> SchemaT
     r m (InputFieldsParser n (SelectArgsG b (UnpreparedValue b)))
tableArguments TableInfo 'BigQuery
returnTableInfo
      let fieldArgsParser :: InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
   SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
fieldArgsParser = (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
 -> SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
 -> (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
     SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)))
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
-> InputFieldsParser
     n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
      SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
forall a b c.
(a -> b -> c)
-> InputFieldsParser MetadataObjId n a
-> InputFieldsParser MetadataObjId n b
-> InputFieldsParser MetadataObjId n c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,) InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
functionArgsParser InputFieldsParser
  n (SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
selectArgsParser
      pure
        $ Name
-> Maybe Description
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
      SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> FieldParser
     MetadataObjId
     n
     ((FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
       SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)),
      AnnotatedFields 'BigQuery)
forall (m :: * -> *) origin a b.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Output m b
-> FieldParser origin m (a, b)
P.subselection Name
fieldName Maybe Description
fieldDescription InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
   SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery))
fieldArgsParser Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
selectionSetParser
        FieldParser
  MetadataObjId
  n
  ((FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
    SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)),
   AnnotatedFields 'BigQuery)
-> (((FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
      SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)),
     AnnotatedFields 'BigQuery)
    -> AnnotatedField 'BigQuery)
-> FieldParser n (AnnotatedField 'BigQuery)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \((FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
functionArgs', SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
args), AnnotatedFields 'BigQuery
fields) ->
          XComputedField 'BigQuery
-> ComputedFieldName
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
-> AnnotatedField 'BigQuery
forall (b :: BackendType) r v.
XComputedField b
-> ComputedFieldName
-> ComputedFieldSelect b r v
-> AnnFieldG b r v
IR.AFComputedField XComputedField 'BigQuery
_cfiXComputedFieldInfo ComputedFieldName
_cfiName
            (ComputedFieldSelect
   'BigQuery
   (RemoteRelationshipField UnpreparedValue)
   (UnpreparedValue 'BigQuery)
 -> AnnotatedField 'BigQuery)
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
-> AnnotatedField 'BigQuery
forall a b. (a -> b) -> a -> b
$ JsonAggSelect
-> SelectExp 'BigQuery
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
forall (b :: BackendType) r v.
JsonAggSelect
-> AnnSimpleSelectG b r v -> ComputedFieldSelect b r v
IR.CFSTable JsonAggSelect
JASMultipleRows
            (SelectExp 'BigQuery
 -> ComputedFieldSelect
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))
-> SelectExp 'BigQuery
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ IR.AnnSelectG
              { $sel:_asnFields:AnnSelectG :: AnnotatedFields 'BigQuery
IR._asnFields = AnnotatedFields 'BigQuery
fields,
                $sel:_asnFrom:AnnSelectG :: SelectFromG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnFrom = FunctionName 'BigQuery
-> FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)
-> Maybe [(Column 'BigQuery, ScalarType 'BigQuery)]
-> SelectFromG 'BigQuery (UnpreparedValue 'BigQuery)
forall (b :: BackendType) v.
FunctionName b
-> FunctionArgsExp b v
-> Maybe [(Column b, ScalarType b)]
-> SelectFromG b v
IR.FromFunction (ComputedFieldFunction 'BigQuery -> FunctionName 'BigQuery
forall (b :: BackendType).
ComputedFieldFunction b -> FunctionName b
_cffName ComputedFieldFunction 'BigQuery
_cfiFunction) FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)
FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
functionArgs' Maybe [(Column 'BigQuery, ScalarType 'BigQuery)]
Maybe [(ColumnName, ScalarType)]
forall a. Maybe a
Nothing,
                $sel:_asnPerm:AnnSelectG :: TablePermG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnPerm = SelPermInfo 'BigQuery
-> TablePermG 'BigQuery (UnpreparedValue 'BigQuery)
forall (b :: BackendType).
Backend b =>
SelPermInfo b -> TablePerms b
tablePermissionsInfo SelPermInfo 'BigQuery
returnTablePermissions,
                $sel:_asnArgs:AnnSelectG :: SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnArgs = SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
args,
                $sel:_asnStrfyNum:AnnSelectG :: StringifyNumbers
IR._asnStrfyNum = StringifyNumbers
stringifyNumbers,
                $sel:_asnNamingConvention:AnnSelectG :: Maybe NamingCase
IR._asnNamingConvention = Maybe NamingCase
forall a. Maybe a
Nothing
              }
    BigQuery.ReturnTableSchema [(ColumnName, Name, ScalarType)]
returnFields -> do
      -- Check if the computed field is available in the select permission
      SelPermInfo 'BigQuery
selectPermissions <- Maybe (SelPermInfo 'BigQuery)
-> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery)
forall (m :: * -> *) b. Applicative m => Maybe b -> MaybeT m b
hoistMaybe (Maybe (SelPermInfo 'BigQuery)
 -> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery))
-> Maybe (SelPermInfo 'BigQuery)
-> MaybeT (SchemaT r m) (SelPermInfo 'BigQuery)
forall a b. (a -> b) -> a -> b
$ RoleName -> TableInfo 'BigQuery -> Maybe (SelPermInfo 'BigQuery)
forall (b :: BackendType).
RoleName -> TableInfo b -> Maybe (SelPermInfo b)
tableSelectPermissions RoleName
roleName TableInfo 'BigQuery
tableInfo
      Bool -> MaybeT (SchemaT r m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> MaybeT (SchemaT r m) ())
-> Bool -> MaybeT (SchemaT r m) ()
forall a b. (a -> b) -> a -> b
$ ComputedFieldName
-> HashMap ComputedFieldName (AnnRedactionExpPartialSQL 'BigQuery)
-> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
HashMap.member ComputedFieldName
_cfiName (HashMap ComputedFieldName (AnnRedactionExpPartialSQL 'BigQuery)
 -> Bool)
-> HashMap ComputedFieldName (AnnRedactionExpPartialSQL 'BigQuery)
-> Bool
forall a b. (a -> b) -> a -> b
$ SelPermInfo 'BigQuery
-> HashMap ComputedFieldName (AnnRedactionExpPartialSQL 'BigQuery)
forall (b :: BackendType).
SelPermInfo b
-> HashMap ComputedFieldName (AnnRedactionExpPartialSQL b)
spiComputedFields SelPermInfo 'BigQuery
selectPermissions
      Name
objectTypeName <-
        Name -> Name
mkTypename (Name -> Name)
-> MaybeT (SchemaT r m) Name -> MaybeT (SchemaT r m) Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
          Name
computedFieldGQLName <- Text -> MaybeT (SchemaT r m) Name
forall (m :: * -> *). MonadError QErr m => Text -> m Name
textToName (Text -> MaybeT (SchemaT r m) Name)
-> Text -> MaybeT (SchemaT r m) Name
forall a b. (a -> b) -> a -> b
$ ComputedFieldName -> Text
computedFieldNameToText ComputedFieldName
_cfiName
          pure $ Name
computedFieldGQLName Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__ Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__fields
      Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
selectionSetParser <- do
        [FieldParser n (AnnotatedField 'BigQuery)]
fieldParsers <- SchemaT r m [FieldParser n (AnnotatedField 'BigQuery)]
-> MaybeT (SchemaT r m) [FieldParser n (AnnotatedField 'BigQuery)]
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (SchemaT r m [FieldParser n (AnnotatedField 'BigQuery)]
 -> MaybeT (SchemaT r m) [FieldParser n (AnnotatedField 'BigQuery)])
-> SchemaT r m [FieldParser n (AnnotatedField 'BigQuery)]
-> MaybeT (SchemaT r m) [FieldParser n (AnnotatedField 'BigQuery)]
forall a b. (a -> b) -> a -> b
$ [(ColumnName, Name, ScalarType)]
-> ((ColumnName, Name, ScalarType)
    -> SchemaT r m (FieldParser n (AnnotatedField 'BigQuery)))
-> SchemaT r m [FieldParser n (AnnotatedField 'BigQuery)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [(ColumnName, Name, ScalarType)]
returnFields (ColumnName, Name, ScalarType)
-> SchemaT r m (FieldParser n (AnnotatedField 'BigQuery))
selectArbitraryField
        let description :: Description
description = Text -> Description
G.Description (Text -> Description) -> Text -> Description
forall a b. (a -> b) -> a -> b
$ Text
"column fields returning by " Text -> ComputedFieldName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> ComputedFieldName
_cfiName
        Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> MaybeT
     (SchemaT r m)
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
forall a. a -> MaybeT (SchemaT r m) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
          (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
 -> MaybeT
      (SchemaT r m)
      (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)))
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> MaybeT
     (SchemaT r m)
     (Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery))
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> [FieldParser n (AnnotatedField 'BigQuery)]
-> [Parser MetadataObjId 'Output n Any]
-> Parser
     MetadataObjId
     'Output
     n
     (InsOrdHashMap Name (ParsedSelection (AnnotatedField 'BigQuery)))
forall (m :: * -> *) origin a b.
MonadParse m =>
Name
-> Maybe Description
-> [FieldParser origin m a]
-> [Parser origin 'Output m b]
-> Parser origin 'Output m (InsOrdHashMap Name (ParsedSelection a))
P.selectionSetObject Name
objectTypeName (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
description) [FieldParser n (AnnotatedField 'BigQuery)]
fieldParsers []
          Parser
  MetadataObjId
  'Output
  n
  (InsOrdHashMap Name (ParsedSelection (AnnotatedField 'BigQuery)))
-> (InsOrdHashMap Name (ParsedSelection (AnnotatedField 'BigQuery))
    -> AnnotatedFields 'BigQuery)
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Text -> AnnotatedField 'BigQuery)
-> InsOrdHashMap Name (ParsedSelection (AnnotatedField 'BigQuery))
-> AnnotatedFields 'BigQuery
forall a.
(Text -> a) -> InsOrdHashMap Name (ParsedSelection a) -> Fields a
parsedSelectionsToFields Text -> AnnotatedField 'BigQuery
forall (b :: BackendType) r v. Text -> AnnFieldG b r v
IR.AFExpression
      pure
        $ Name
-> Maybe Description
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
-> Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
-> FieldParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
      AnnotatedFields 'BigQuery)
forall (m :: * -> *) origin a b.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Output m b
-> FieldParser origin m (a, b)
P.subselection Name
fieldName Maybe Description
fieldDescription InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
functionArgsParser Parser MetadataObjId 'Output n (AnnotatedFields 'BigQuery)
selectionSetParser
        FieldParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
   AnnotatedFields 'BigQuery)
-> ((FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)),
     AnnotatedFields 'BigQuery)
    -> AnnotatedField 'BigQuery)
-> FieldParser n (AnnotatedField 'BigQuery)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
functionArgs', AnnotatedFields 'BigQuery
fields) ->
          XComputedField 'BigQuery
-> ComputedFieldName
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
-> AnnotatedField 'BigQuery
forall (b :: BackendType) r v.
XComputedField b
-> ComputedFieldName
-> ComputedFieldSelect b r v
-> AnnFieldG b r v
IR.AFComputedField XComputedField 'BigQuery
_cfiXComputedFieldInfo ComputedFieldName
_cfiName
            (ComputedFieldSelect
   'BigQuery
   (RemoteRelationshipField UnpreparedValue)
   (UnpreparedValue 'BigQuery)
 -> AnnotatedField 'BigQuery)
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
-> AnnotatedField 'BigQuery
forall a b. (a -> b) -> a -> b
$ JsonAggSelect
-> SelectExp 'BigQuery
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
forall (b :: BackendType) r v.
JsonAggSelect
-> AnnSimpleSelectG b r v -> ComputedFieldSelect b r v
IR.CFSTable JsonAggSelect
JASMultipleRows
            (SelectExp 'BigQuery
 -> ComputedFieldSelect
      'BigQuery
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'BigQuery))
-> SelectExp 'BigQuery
-> ComputedFieldSelect
     'BigQuery
     (RemoteRelationshipField UnpreparedValue)
     (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ IR.AnnSelectG
              { $sel:_asnFields:AnnSelectG :: AnnotatedFields 'BigQuery
IR._asnFields = AnnotatedFields 'BigQuery
fields,
                $sel:_asnFrom:AnnSelectG :: SelectFromG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnFrom = FunctionName 'BigQuery
-> FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)
-> Maybe [(Column 'BigQuery, ScalarType 'BigQuery)]
-> SelectFromG 'BigQuery (UnpreparedValue 'BigQuery)
forall (b :: BackendType) v.
FunctionName b
-> FunctionArgsExp b v
-> Maybe [(Column b, ScalarType b)]
-> SelectFromG b v
IR.FromFunction (ComputedFieldFunction 'BigQuery -> FunctionName 'BigQuery
forall (b :: BackendType).
ComputedFieldFunction b -> FunctionName b
_cffName ComputedFieldFunction 'BigQuery
_cfiFunction) FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)
FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
functionArgs' Maybe [(Column 'BigQuery, ScalarType 'BigQuery)]
Maybe [(ColumnName, ScalarType)]
forall a. Maybe a
Nothing,
                $sel:_asnPerm:AnnSelectG :: TablePermG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnPerm = TablePermG 'BigQuery (UnpreparedValue 'BigQuery)
forall (backend :: BackendType) v. TablePermG backend v
IR.noTablePermissions,
                $sel:_asnArgs:AnnSelectG :: SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
IR._asnArgs = SelectArgsG 'BigQuery (UnpreparedValue 'BigQuery)
forall (backend :: BackendType) v. SelectArgsG backend v
IR.noSelectArgs,
                $sel:_asnStrfyNum:AnnSelectG :: StringifyNumbers
IR._asnStrfyNum = StringifyNumbers
stringifyNumbers,
                $sel:_asnNamingConvention:AnnSelectG :: Maybe NamingCase
IR._asnNamingConvention = Maybe NamingCase
forall a. Maybe a
Nothing
              }
  where
    fieldDescription :: Maybe G.Description
    fieldDescription :: Maybe Description
fieldDescription = Text -> Description
G.Description (Text -> Description) -> Maybe Text -> Maybe Description
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
_cfiDescription

    selectArbitraryField ::
      (BigQuery.ColumnName, G.Name, BigQuery.ScalarType) ->
      SchemaT r m (FieldParser n (AnnotatedField 'BigQuery))
    selectArbitraryField :: (ColumnName, Name, ScalarType)
-> SchemaT r m (FieldParser n (AnnotatedField 'BigQuery))
selectArbitraryField (ColumnName
columnName, Name
graphQLName, ScalarType
columnType) = do
      Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
field <- forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser @'BigQuery (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar ScalarType 'BigQuery
ScalarType
columnType) (Bool -> Nullability
G.Nullability Bool
True)
      pure
        $ Name
-> Maybe Description
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> FieldParser MetadataObjId n ()
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> Parser origin 'Both m a
-> FieldParser origin m ()
P.selection_ Name
graphQLName Maybe Description
forall a. Maybe a
Nothing Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
field
        FieldParser MetadataObjId n ()
-> AnnotatedField 'BigQuery
-> FieldParser n (AnnotatedField 'BigQuery)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Column 'BigQuery
-> ColumnType 'BigQuery
-> AnnRedactionExpUnpreparedValue 'BigQuery
-> Maybe (ScalarSelectionArguments 'BigQuery)
-> AnnotatedField 'BigQuery
forall (backend :: BackendType) v r.
Column backend
-> ColumnType backend
-> AnnRedactionExp backend v
-> Maybe (ScalarSelectionArguments backend)
-> AnnFieldG backend r v
IR.mkAnnColumnField Column 'BigQuery
ColumnName
columnName (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar ScalarType 'BigQuery
ScalarType
columnType) AnnRedactionExpUnpreparedValue 'BigQuery
forall (b :: BackendType) v. AnnRedactionExp b v
NoRedaction Maybe Void
Maybe (ScalarSelectionArguments 'BigQuery)
forall a. Maybe a
Nothing

    computedFieldFunctionArgs ::
      (G.Name -> G.Name) ->
      ComputedFieldFunction 'BigQuery ->
      SchemaT r m (InputFieldsParser n (FunctionArgsExp 'BigQuery (IR.UnpreparedValue 'BigQuery)))
    computedFieldFunctionArgs :: (Name -> Name)
-> ComputedFieldFunction 'BigQuery
-> SchemaT
     r
     m
     (InputFieldsParser
        n (FunctionArgsExp 'BigQuery (UnpreparedValue 'BigQuery)))
computedFieldFunctionArgs Name -> Name
mkTypename ComputedFieldFunction {Maybe PGDescription
Seq (FunctionArgument 'BigQuery)
FunctionName 'BigQuery
ComputedFieldImplicitArguments 'BigQuery
_cffName :: forall (b :: BackendType).
ComputedFieldFunction b -> FunctionName b
_cffName :: FunctionName 'BigQuery
_cffInputArgs :: Seq (FunctionArgument 'BigQuery)
_cffComputedFieldImplicitArgs :: ComputedFieldImplicitArguments 'BigQuery
_cffDescription :: Maybe PGDescription
_cffInputArgs :: forall (b :: BackendType).
ComputedFieldFunction b -> Seq (FunctionArgument b)
_cffComputedFieldImplicitArgs :: forall (b :: BackendType).
ComputedFieldFunction b -> ComputedFieldImplicitArguments b
_cffDescription :: forall (b :: BackendType).
ComputedFieldFunction b -> Maybe PGDescription
..} = do
      Name
objectName <-
        Name -> Name
mkTypename (Name -> Name) -> SchemaT r m Name -> SchemaT r m Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
          Name
computedFieldGQLName <- Text -> SchemaT r m Name
forall (m :: * -> *). MonadError QErr m => Text -> m Name
textToName (Text -> SchemaT r m Name) -> Text -> SchemaT r m Name
forall a b. (a -> b) -> a -> b
$ ComputedFieldName -> Text
computedFieldNameToText ComputedFieldName
_cfiName
          Name
tableGQLName <- forall (b :: BackendType) (m :: * -> *).
(Backend b, MonadError QErr m) =>
TableInfo b -> m Name
getTableGQLName @'BigQuery TableInfo 'BigQuery
tableInfo
          pure $ Name
computedFieldGQLName Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__ Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
tableGQLName Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__args

      let userInputArgs :: [FunctionArgument]
userInputArgs = (FunctionArgument -> Bool)
-> [FunctionArgument] -> [FunctionArgument]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (FunctionArgument -> Bool) -> FunctionArgument -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FunctionArgName -> HashMap FunctionArgName ColumnName -> Bool)
-> HashMap FunctionArgName ColumnName -> FunctionArgName -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip FunctionArgName -> HashMap FunctionArgName ColumnName -> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
HashMap.member HashMap FunctionArgName ColumnName
ComputedFieldImplicitArguments 'BigQuery
_cffComputedFieldImplicitArgs (FunctionArgName -> Bool)
-> (FunctionArgument -> FunctionArgName)
-> FunctionArgument
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FunctionArgument -> FunctionArgName
BigQuery._faName) (Seq FunctionArgument -> [FunctionArgument]
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Seq (FunctionArgument 'BigQuery)
Seq FunctionArgument
_cffInputArgs)

      InputFieldsParser
  MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
argumentParsers <- [InputFieldsParser
   MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> InputFieldsParser
     MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
sequenceA ([InputFieldsParser
    MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))]
 -> InputFieldsParser
      MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
-> SchemaT
     r
     m
     [InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [FunctionArgument]
-> (FunctionArgument
    -> SchemaT
         r
         m
         (InputFieldsParser
            MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))))
-> SchemaT
     r
     m
     [InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [FunctionArgument]
userInputArgs FunctionArgument
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery)))
parseArgument

      let userArgsParser :: Parser
  MetadataObjId
  'Input
  n
  [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
userArgsParser = Name
-> Maybe Description
-> InputFieldsParser
     MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> Parser
     MetadataObjId
     'Input
     n
     [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Input m a
P.object Name
objectName Maybe Description
forall a. Maybe a
Nothing InputFieldsParser
  MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
argumentParsers

      let fieldDesc :: Description
fieldDesc =
            Text -> Description
G.Description
              (Text -> Description) -> Text -> Description
forall a b. (a -> b) -> a -> b
$ Text
"input parameters for computed field "
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ComputedFieldName
_cfiName
              ComputedFieldName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" defined on table "
              Text -> TableName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> TableName 'BigQuery
TableName
tableName

          argsField :: InputFieldsParser
  MetadataObjId
  n
  (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
argsField
            | [FunctionArgument] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FunctionArgument]
userInputArgs = Name
-> Maybe Description
-> Parser
     MetadataObjId
     'Input
     n
     [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> InputFieldsParser
     MetadataObjId
     n
     (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name._args (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
fieldDesc) Parser
  MetadataObjId
  'Input
  n
  [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
userArgsParser
            | Bool
otherwise = [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
forall a. a -> Maybe a
Just ([(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
 -> Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
-> InputFieldsParser
     MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> InputFieldsParser
     MetadataObjId
     n
     (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name
-> Maybe Description
-> Parser
     MetadataObjId
     'Input
     n
     [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> InputFieldsParser
     MetadataObjId n [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m a
P.field Name
Name._args (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
fieldDesc) Parser
  MetadataObjId
  'Input
  n
  [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
userArgsParser

      InputFieldsParser
  MetadataObjId
  n
  (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId
        n
        (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
        (InputFieldsParser
   MetadataObjId
   n
   (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
 -> SchemaT
      r
      m
      (InputFieldsParser
         MetadataObjId
         n
         (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))))
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId
        n
        (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))))
forall a b. (a -> b) -> a -> b
$ InputFieldsParser
  MetadataObjId
  n
  (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
argsField
        InputFieldsParser
  MetadataObjId
  n
  (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))])
-> (Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
    -> n (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))))
-> InputFieldsParser
     MetadataObjId
     n
     (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
forall (m :: * -> *) origin a b.
Monad m =>
InputFieldsParser origin m a
-> (a -> m b) -> InputFieldsParser origin m b
`P.bindFields` \Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
maybeInputArguments -> do
          let tableColumnInputs :: HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
tableColumnInputs = (ColumnName -> ArgumentExp (UnpreparedValue 'BigQuery))
-> HashMap Text ColumnName
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall v1 v2 k. (v1 -> v2) -> HashMap k v1 -> HashMap k v2
HashMap.map ColumnName -> ArgumentExp (UnpreparedValue 'BigQuery)
forall v. ColumnName -> ArgumentExp v
BigQuery.AETableColumn (HashMap Text ColumnName
 -> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery)))
-> HashMap Text ColumnName
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall a b. (a -> b) -> a -> b
$ (FunctionArgName -> Text)
-> HashMap FunctionArgName ColumnName -> HashMap Text ColumnName
forall k2 k1 v.
(Eq k2, Hashable k2) =>
(k1 -> k2) -> HashMap k1 v -> HashMap k2 v
HashMap.mapKeys FunctionArgName -> Text
getFuncArgNameTxt HashMap FunctionArgName ColumnName
ComputedFieldImplicitArguments 'BigQuery
_cffComputedFieldImplicitArgs
          FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
-> n (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
forall a. a -> n a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
 -> n (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))))
-> FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
-> n (FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
forall a b. (a -> b) -> a -> b
$ [ArgumentExp (UnpreparedValue 'BigQuery)]
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
-> FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
forall a. [a] -> HashMap Text a -> FunctionArgsExpG a
FunctionArgsExp [ArgumentExp (UnpreparedValue 'BigQuery)]
forall a. Monoid a => a
mempty (HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
 -> FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery)))
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
-> FunctionArgsExpG (ArgumentExp (UnpreparedValue 'BigQuery))
forall a b. (a -> b) -> a -> b
$ HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
-> ([(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
    -> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery)))
-> Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall a. Monoid a => a
mempty [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList Maybe [(Text, ArgumentExp (UnpreparedValue 'BigQuery))]
maybeInputArguments HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
-> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
forall a. Semigroup a => a -> a -> a
<> HashMap Text (ArgumentExp (UnpreparedValue 'BigQuery))
tableColumnInputs

    parseArgument :: BigQuery.FunctionArgument -> SchemaT r m (InputFieldsParser n (Text, BigQuery.ArgumentExp (IR.UnpreparedValue 'BigQuery)))
    parseArgument :: FunctionArgument
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery)))
parseArgument FunctionArgument
arg = do
      Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser <- ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'BigQuery r m n =>
ColumnType 'BigQuery
-> Nullability
-> SchemaT
     r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(BackendSchema b, MonadBuildSchema b r m n) =>
ColumnType b
-> Nullability
-> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser (ScalarType 'BigQuery -> ColumnType 'BigQuery
forall (b :: BackendType). ScalarType b -> ColumnType b
ColumnScalar (ScalarType 'BigQuery -> ColumnType 'BigQuery)
-> ScalarType 'BigQuery -> ColumnType 'BigQuery
forall a b. (a -> b) -> a -> b
$ FunctionArgument -> ScalarType
BigQuery._faType FunctionArgument
arg) (Bool -> Nullability
G.Nullability Bool
False)
      let argumentName :: Text
argumentName = FunctionArgName -> Text
getFuncArgNameTxt (FunctionArgName -> Text) -> FunctionArgName -> Text
forall a b. (a -> b) -> a -> b
$ FunctionArgument -> FunctionArgName
BigQuery._faName FunctionArgument
arg
      Name
fieldName <- Text -> SchemaT r m Name
forall (m :: * -> *). MonadError QErr m => Text -> m Name
textToName Text
argumentName
      let argParser :: InputFieldsParser
  MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
argParser = Name
-> Maybe Description
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
-> InputFieldsParser
     MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m a
P.field Name
fieldName Maybe Description
forall a. Maybe a
Nothing Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))
typedParser
      InputFieldsParser
  MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery)))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InputFieldsParser
   MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))
 -> SchemaT
      r
      m
      (InputFieldsParser
         MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))))
-> InputFieldsParser
     MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))
-> SchemaT
     r
     m
     (InputFieldsParser
        MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery)))
forall a b. (a -> b) -> a -> b
$ InputFieldsParser
  MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
argParser InputFieldsParser
  MetadataObjId n (ValueWithOrigin (ColumnValue 'BigQuery))
-> (ValueWithOrigin (ColumnValue 'BigQuery)
    -> n (Text, ArgumentExp (UnpreparedValue 'BigQuery)))
-> InputFieldsParser
     MetadataObjId n (Text, ArgumentExp (UnpreparedValue 'BigQuery))
forall (m :: * -> *) origin a b.
Monad m =>
InputFieldsParser origin m a
-> (a -> m b) -> InputFieldsParser origin m b
`P.bindFields` \ValueWithOrigin (ColumnValue 'BigQuery)
inputValue -> (Text, ArgumentExp (UnpreparedValue 'BigQuery))
-> n (Text, ArgumentExp (UnpreparedValue 'BigQuery))
forall a. a -> n a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Text
argumentName, UnpreparedValue 'BigQuery
-> ArgumentExp (UnpreparedValue 'BigQuery)
forall v. v -> ArgumentExp v
BigQuery.AEInput (UnpreparedValue 'BigQuery
 -> ArgumentExp (UnpreparedValue 'BigQuery))
-> UnpreparedValue 'BigQuery
-> ArgumentExp (UnpreparedValue 'BigQuery)
forall a b. (a -> b) -> a -> b
$ ValueWithOrigin (ColumnValue 'BigQuery)
-> UnpreparedValue 'BigQuery
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
IR.mkParameter ValueWithOrigin (ColumnValue 'BigQuery)
inputValue))