queryparser-0.1.0.1: Analysis and parsing library for SQL queries.

Safe HaskellNone
LanguageHaskell2010

Database.Sql.Util.Eval

Synopsis

Documentation

data EvalContext e Source #

Instances

Monad m => MonadReader (EvalContext e) (EvalT e t m) Source # 

Methods

ask :: EvalT e t m (EvalContext e) #

local :: (EvalContext e -> EvalContext e) -> EvalT e t m a -> EvalT e t m a #

reader :: (EvalContext e -> a) -> EvalT e t m a #

newtype EvalT e (t :: ContextType) m a Source #

Constructors

EvalT (ReaderT (EvalContext e) (ExceptT String m) a) 

Instances

MonadWriter w m => MonadWriter w (EvalT e t m) Source # 

Methods

writer :: (a, w) -> EvalT e t m a #

tell :: w -> EvalT e t m () #

listen :: EvalT e t m a -> EvalT e t m (a, w) #

pass :: EvalT e t m (a, w -> w) -> EvalT e t m a #

MonadState s m => MonadState s (EvalT e t m) Source # 

Methods

get :: EvalT e t m s #

put :: s -> EvalT e t m () #

state :: (s -> (a, s)) -> EvalT e t m a #

Monad m => MonadError String (EvalT e t m) Source # 

Methods

throwError :: String -> EvalT e t m a #

catchError :: EvalT e t m a -> (String -> EvalT e t m a) -> EvalT e t m a #

Monad m => MonadReader (EvalContext e) (EvalT e t m) Source # 

Methods

ask :: EvalT e t m (EvalContext e) #

local :: (EvalContext e -> EvalContext e) -> EvalT e t m a -> EvalT e t m a #

reader :: (EvalContext e -> a) -> EvalT e t m a #

Monad m => Monad (EvalT e t m) Source # 

Methods

(>>=) :: EvalT e t m a -> (a -> EvalT e t m b) -> EvalT e t m b #

(>>) :: EvalT e t m a -> EvalT e t m b -> EvalT e t m b #

return :: a -> EvalT e t m a #

fail :: String -> EvalT e t m a #

Functor m => Functor (EvalT e t m) Source # 

Methods

fmap :: (a -> b) -> EvalT e t m a -> EvalT e t m b #

(<$) :: a -> EvalT e t m b -> EvalT e t m a #

Monad m => Applicative (EvalT e t m) Source # 

Methods

pure :: a -> EvalT e t m a #

(<*>) :: EvalT e t m (a -> b) -> EvalT e t m a -> EvalT e t m b #

liftA2 :: (a -> b -> c) -> EvalT e t m a -> EvalT e t m b -> EvalT e t m c #

(*>) :: EvalT e t m a -> EvalT e t m b -> EvalT e t m b #

(<*) :: EvalT e t m a -> EvalT e t m b -> EvalT e t m a #

type Eval e t = EvalT e t Identity Source #

class Evaluate e q where Source #

Minimal complete definition

eval

Associated Types

type EvalResult e q :: * Source #

Methods

eval :: Proxy e -> q -> EvalResult e q Source #

Instances

Evaluation e => Evaluate e (Constant a) Source # 

Associated Types

type EvalResult e (Constant a) :: * Source #

Methods

eval :: Proxy * e -> Constant a -> EvalResult e (Constant a) Source #

Evaluation e => Evaluate e (Offset a) Source # 

Associated Types

type EvalResult e (Offset a) :: * Source #

Methods

eval :: Proxy * e -> Offset a -> EvalResult e (Offset a) Source #

Evaluation e => Evaluate e (Limit a) Source # 

Associated Types

type EvalResult e (Limit a) :: * Source #

Methods

eval :: Proxy * e -> Limit a -> EvalResult e (Limit a) Source #

Evaluation e => Evaluate e (Expr ResolvedNames Range) Source # 
Evaluation e => Evaluate e (Selection ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectTimeseries ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectHaving ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectGroup ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectWhere ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectColumns ResolvedNames Range) Source #

SelectColumns tells us how to map from the records provided by the FROM to (unfiltered, &c) records provided by our select. Evaluating it gives us that function.

Evaluation e => Evaluate e (JoinCondition ResolvedNames Range) Source # 
Evaluation e => Evaluate e (Tablish ResolvedNames Range) Source # 
Evaluation e => Evaluate e (SelectFrom ResolvedNames Range) Source # 
Evaluation e => Evaluate e (Select ResolvedNames Range) Source # 
Evaluation e => Evaluate e (Query ResolvedNames Range) Source # 

class (Monad (EvalRow e), Monad (EvalMonad e), Traversable (EvalRow e)) => Evaluation e where Source #

Associated Types

type EvalValue e :: * Source #

type EvalRow e :: * -> * Source #

type EvalMonad e :: * -> * Source #

Methods

addItems :: Proxy e -> EvalRow e [EvalValue e] -> EvalRow e [EvalValue e] -> EvalT e TableContext (EvalMonad e) (EvalRow e [EvalValue e]) Source #

removeItems :: Proxy e -> EvalRow e [EvalValue e] -> EvalRow e [EvalValue e] -> EvalT e TableContext (EvalMonad e) (EvalRow e [EvalValue e]) Source #

unionItems :: Proxy e -> EvalRow e [EvalValue e] -> EvalRow e [EvalValue e] -> EvalT e TableContext (EvalMonad e) (EvalRow e [EvalValue e]) Source #

intersectItems :: Proxy e -> EvalRow e [EvalValue e] -> EvalRow e [EvalValue e] -> EvalT e TableContext (EvalMonad e) (EvalRow e [EvalValue e]) Source #

distinctItems :: Proxy e -> EvalRow e [EvalValue e] -> EvalRow e [EvalValue e] Source #

offsetItems :: Proxy e -> Int -> RecordSet e -> RecordSet e Source #

limitItems :: Proxy e -> Int -> RecordSet e -> RecordSet e Source #

filterBy :: Expr ResolvedNames Range -> RecordSet e -> EvalT e TableContext (EvalMonad e) (RecordSet e) Source #

inList :: EvalValue e -> [EvalValue e] -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

inSubquery :: EvalValue e -> EvalRow e [EvalValue e] -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

existsSubquery :: EvalRow e [EvalValue e] -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

atTimeZone :: EvalValue e -> EvalValue e -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleConstant :: Proxy e -> Constant a -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleCases :: Proxy e -> [(Expr ResolvedNames Range, Expr ResolvedNames Range)] -> Maybe (Expr ResolvedNames Range) -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleFunction :: Proxy e -> FunctionName Range -> Distinct -> [Expr ResolvedNames Range] -> [(ParamName Range, Expr ResolvedNames Range)] -> Maybe (Filter ResolvedNames Range) -> Maybe (OverSubExpr ResolvedNames Range) -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleGroups :: [RColumnRef ()] -> EvalRow e ([EvalValue e], EvalRow e [EvalValue e]) -> EvalRow e (RecordSet e) Source #

handleLike :: Proxy e -> Operator a -> Maybe (Escape ResolvedNames Range) -> Pattern ResolvedNames Range -> Expr ResolvedNames Range -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleOrder :: Proxy e -> [Order ResolvedNames Range] -> RecordSet e -> EvalT e TableContext (EvalMonad e) (RecordSet e) Source #

handleSubquery :: EvalRow e [EvalValue e] -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleJoin :: Proxy e -> JoinType a -> JoinCondition ResolvedNames Range -> RecordSet e -> RecordSet e -> EvalT e TableContext (EvalMonad e) (RecordSet e) Source #

handleStructField :: Expr ResolvedNames Range -> StructFieldName a -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

handleTypeCast :: CastFailureAction -> Expr ResolvedNames Range -> DataType a -> EvalT e ExprContext (EvalMonad e) (EvalValue e) Source #

binop :: Proxy e -> Text -> Maybe (EvalValue e -> EvalValue e -> EvalT e ExprContext (EvalMonad e) (EvalValue e)) Source #

unop :: Proxy e -> Text -> Maybe (EvalValue e -> EvalT e ExprContext (EvalMonad e) (EvalValue e)) Source #

Instances

Evaluation Concrete Source # 

Associated Types

type EvalValue Concrete :: * Source #

type EvalRow Concrete :: * -> * Source #

type EvalMonad Concrete :: * -> * Source #

Methods

addItems :: Proxy * Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete TableContext (EvalMonad Concrete) (EvalRow Concrete [EvalValue Concrete]) Source #

removeItems :: Proxy * Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete TableContext (EvalMonad Concrete) (EvalRow Concrete [EvalValue Concrete]) Source #

unionItems :: Proxy * Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete TableContext (EvalMonad Concrete) (EvalRow Concrete [EvalValue Concrete]) Source #

intersectItems :: Proxy * Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete TableContext (EvalMonad Concrete) (EvalRow Concrete [EvalValue Concrete]) Source #

distinctItems :: Proxy * Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalRow Concrete [EvalValue Concrete] Source #

offsetItems :: Proxy * Concrete -> Int -> RecordSet Concrete -> RecordSet Concrete Source #

limitItems :: Proxy * Concrete -> Int -> RecordSet Concrete -> RecordSet Concrete Source #

filterBy :: Expr ResolvedNames Range -> RecordSet Concrete -> EvalT Concrete TableContext (EvalMonad Concrete) (RecordSet Concrete) Source #

inList :: EvalValue Concrete -> [EvalValue Concrete] -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

inSubquery :: EvalValue Concrete -> EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

existsSubquery :: EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

atTimeZone :: EvalValue Concrete -> EvalValue Concrete -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleConstant :: Proxy * Concrete -> Constant a -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleCases :: Proxy * Concrete -> [(Expr ResolvedNames Range, Expr ResolvedNames Range)] -> Maybe (Expr ResolvedNames Range) -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleFunction :: Proxy * Concrete -> FunctionName Range -> Distinct -> [Expr ResolvedNames Range] -> [(ParamName Range, Expr ResolvedNames Range)] -> Maybe (Filter ResolvedNames Range) -> Maybe (OverSubExpr ResolvedNames Range) -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleGroups :: [RColumnRef ()] -> EvalRow Concrete ([EvalValue Concrete], EvalRow Concrete [EvalValue Concrete]) -> EvalRow Concrete (RecordSet Concrete) Source #

handleLike :: Proxy * Concrete -> Operator a -> Maybe (Escape ResolvedNames Range) -> Pattern ResolvedNames Range -> Expr ResolvedNames Range -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleOrder :: Proxy * Concrete -> [Order ResolvedNames Range] -> RecordSet Concrete -> EvalT Concrete TableContext (EvalMonad Concrete) (RecordSet Concrete) Source #

handleSubquery :: EvalRow Concrete [EvalValue Concrete] -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleJoin :: Proxy * Concrete -> JoinType a -> JoinCondition ResolvedNames Range -> RecordSet Concrete -> RecordSet Concrete -> EvalT Concrete TableContext (EvalMonad Concrete) (RecordSet Concrete) Source #

handleStructField :: Expr ResolvedNames Range -> StructFieldName a -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

handleTypeCast :: CastFailureAction -> Expr ResolvedNames Range -> DataType a -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete) Source #

binop :: Proxy * Concrete -> Text -> Maybe (EvalValue Concrete -> EvalValue Concrete -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete)) Source #

unop :: Proxy * Concrete -> Text -> Maybe (EvalValue Concrete -> EvalT Concrete ExprContext (EvalMonad Concrete) (EvalValue Concrete)) Source #

Evaluation ColumnLineage Source # 

Associated Types

type EvalValue ColumnLineage :: * Source #

type EvalRow ColumnLineage :: * -> * Source #

type EvalMonad ColumnLineage :: * -> * Source #

Methods

addItems :: Proxy * ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (EvalRow ColumnLineage [EvalValue ColumnLineage]) Source #

removeItems :: Proxy * ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (EvalRow ColumnLineage [EvalValue ColumnLineage]) Source #

unionItems :: Proxy * ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (EvalRow ColumnLineage [EvalValue ColumnLineage]) Source #

intersectItems :: Proxy * ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (EvalRow ColumnLineage [EvalValue ColumnLineage]) Source #

distinctItems :: Proxy * ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalRow ColumnLineage [EvalValue ColumnLineage] Source #

offsetItems :: Proxy * ColumnLineage -> Int -> RecordSet ColumnLineage -> RecordSet ColumnLineage Source #

limitItems :: Proxy * ColumnLineage -> Int -> RecordSet ColumnLineage -> RecordSet ColumnLineage Source #

filterBy :: Expr ResolvedNames Range -> RecordSet ColumnLineage -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (RecordSet ColumnLineage) Source #

inList :: EvalValue ColumnLineage -> [EvalValue ColumnLineage] -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

inSubquery :: EvalValue ColumnLineage -> EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

existsSubquery :: EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

atTimeZone :: EvalValue ColumnLineage -> EvalValue ColumnLineage -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleConstant :: Proxy * ColumnLineage -> Constant a -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleCases :: Proxy * ColumnLineage -> [(Expr ResolvedNames Range, Expr ResolvedNames Range)] -> Maybe (Expr ResolvedNames Range) -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleFunction :: Proxy * ColumnLineage -> FunctionName Range -> Distinct -> [Expr ResolvedNames Range] -> [(ParamName Range, Expr ResolvedNames Range)] -> Maybe (Filter ResolvedNames Range) -> Maybe (OverSubExpr ResolvedNames Range) -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleGroups :: [RColumnRef ()] -> EvalRow ColumnLineage ([EvalValue ColumnLineage], EvalRow ColumnLineage [EvalValue ColumnLineage]) -> EvalRow ColumnLineage (RecordSet ColumnLineage) Source #

handleLike :: Proxy * ColumnLineage -> Operator a -> Maybe (Escape ResolvedNames Range) -> Pattern ResolvedNames Range -> Expr ResolvedNames Range -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleOrder :: Proxy * ColumnLineage -> [Order ResolvedNames Range] -> RecordSet ColumnLineage -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (RecordSet ColumnLineage) Source #

handleSubquery :: EvalRow ColumnLineage [EvalValue ColumnLineage] -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleJoin :: Proxy * ColumnLineage -> JoinType a -> JoinCondition ResolvedNames Range -> RecordSet ColumnLineage -> RecordSet ColumnLineage -> EvalT ColumnLineage TableContext (EvalMonad ColumnLineage) (RecordSet ColumnLineage) Source #

handleStructField :: Expr ResolvedNames Range -> StructFieldName a -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

handleTypeCast :: CastFailureAction -> Expr ResolvedNames Range -> DataType a -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage) Source #

binop :: Proxy * ColumnLineage -> Text -> Maybe (EvalValue ColumnLineage -> EvalValue ColumnLineage -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage)) Source #

unop :: Proxy * ColumnLineage -> Text -> Maybe (EvalValue ColumnLineage -> EvalT ColumnLineage ExprContext (EvalMonad ColumnLineage) (EvalValue ColumnLineage)) Source #

makeRowMap :: [RColumnRef ()] -> [a] -> Map (RColumnRef ()) a Source #

data Direction a Source #

Constructors

Ascending a 
Descending a 

Instances

Eq a => Eq (Direction a) Source # 

Methods

(==) :: Direction a -> Direction a -> Bool #

(/=) :: Direction a -> Direction a -> Bool #

Ord a => Ord (Direction a) Source #