{-# LANGUAGE GADTs #-}{-|
The Algebra module provides the internal datatypes used for
constructing algebaric plans. It is not recommended to use these
datatypes directly instead it is adviced the to use the functions
provided by the module Ferry.Algebra.Data.Create
-}moduleDatabase.Ferry.Algebra.Data.AlgebrawhereimportNumeric(showFFloat)-- | The column data type is used to represent the table structure while-- compiling ferry core into an algebraic plan-- The col column contains the column number and the type of its contents-- The NCol column is used to group columns that together form an element of a record-- , its string argument is used to represent the field name.dataColumnwhereCol::Int->ATy->ColumnNCol::String->Columns->Columnderiving(Show)-- | One table can have multiple columns typeColumns=[Column]-- | Sorting rows in a directiondataSortDir=Asc|Descderiving(Eq,Ord)dataAggrType=Avg|Max|Min|Sum|Count|All|Prod|Distderiving(Eq,Ord)instanceShowAggrTypewhereshowAvg="avg"showMax="max"showMin="min"showSum="sum"showCount="count"showAll="all"showProd="prod"showDist="distinct"-- | The show instance results in values that are accepted in the xml plan.instanceShowSortDirwhereshowAsc="ascending"showDesc="descending"-- | Algebraic types-- At this level we do not have any structural types anymore-- those are represented by columns. ASur is used for surrogate-- values that occur for nested lists.dataATywhereAInt::ATyAStr::ATyABool::ATyADec::ATyADouble::ATyANat::ATyASur::ATyderiving(Eq,Ord)-- | Show the algebraic types in a way that is compatible with -- the xml plan.instanceShowATywhereshowAInt="int"showAStr="str"showABool="bool"showADec="dec"showADouble="dbl"showANat="nat"showASur="nat"-- | Wrapper around values that can occur in an algebraic plan dataAValwhereVInt::Integer->AValVStr::String->AValVBool::Bool->AValVDouble::Double->AValVDec::Float->AValVNat::Integer->AValderiving(Eq,Ord)-- | Show the values in the way compatible with the xml plan.instanceShowAValwhereshow(VIntx)=showxshow(VStrx)=xshow(VBoolTrue)="true"show(VBoolFalse)="false"show(VDoublex)=showxshow(VDecx)=showFFloat(Just2)x""show(VNatx)=showx-- | Pair of a type and a valuetypeATyVal=(ATy,AVal)-- | Attribute name or column nametypeAttrName=String-- | Result attribute name, used as type synonym where the name for a result column of a computation is needed typeResAttrName=AttrName-- | Sort attribute name, used as type synonym where a column for sorting is neededtypeSortAttrName=AttrName-- | Partition attribute name, used as a synonym where the name for the partitioning column is expected by the rownum operatortypePartAttrName=AttrName-- | New attribute name, used to represent the new column name when renaming columnstypeNewAttrName=AttrName-- | Old attribute name, used to represent the old column name when renaming columnstypeOldAttrName=AttrName-- | Selection attribute name, used to represent the column containing the selection booleantypeSelAttrName=AttrName-- | Left attribute name, used to represent the left argument when applying binary operatorstypeLeftAttrName=AttrName-- | Right attribute name, used to represent the right argument when applying binary operatorstypeRightAttrName=AttrName---- | Name of a database tabletypeTableName=String-- | List of table attribute information consisting of (column name, new column name, type of column)typeTableAttrInf=[(AttrName,AttrName,ATy)]-- | Key of a database table, a key consists of multiple column namestypeKeyInfo=[AttrName]-- | Multiple keystypeKeyInfos=[KeyInfo]-- | Sort information, a list (ordered in sorting priority), of pair of columns and their sort direction--typeSortInf=[(SortAttrName,SortDir)]-- | Projection information, a list of new attribute names, and their old names.typeProjInf=[(NewAttrName,OldAttrName)]-- | A tuple is a list of valuestypeTuple=[AVal]-- | Schema information, represents a table structure, the first element of the tuple is the column name the second its type.typeSchemaInfos=[(AttrName,ATy)]typeSemInfRowNum=(ResAttrName,SortInf,MaybePartAttrName)-- | Information that specifies how to perform the rank operation.-- its first element is the column where the output of the operation is inserted-- the second element represents the sorting criteria that determine the ranking.typeSemInfRank=(ResAttrName,SortInf)-- | Information that specifies a projectiontypeSemInfProj=ProjInf-- | Information that specifies which column contains the conditionaltypeSemInfSel=SelAttrName-- | Information that specifies how to select element at a certain positiontypeSemInfPosSel=(Int,SortInf,MaybePartAttrName)-- | Information on how to perform an eq-join. The first element represents the column from the-- first table that has to be equal to the column in the second table represented by the second-- element in the pair.typeSemInfEqJoin=(LeftAttrName,RightAttrName)-- | Information what to put in a literate tabletypeSemInfLitTable=[Tuple]-- | Information for accessing a database tabletypeSemInfTableRef=(TableName,TableAttrInf,KeyInfos)-- | Information what column, the first element, to attach to a table and what its content would be, the second element.typeSemInfAttach=(ResAttrName,ATyVal)typeSemInfCast=(ResAttrName,AttrName,ATy)-- | Information on how to perform a binary operation-- The first element is the function that is to be performed-- The second element the column name for its result-- The third element is the left argument for the operator-- The fourth element is the right argument for the operatortypeSemBinOp=(String,ResAttrName,LeftAttrName,RightAttrName)typeSemUnOp=(ResAttrName,AttrName)typeSemInfAggr=([(AggrType,ResAttrName,MaybeAttrName)],MaybePartAttrName)typeAlgNode=Int-- | Algebraic operations. These operation do not reference their own children directly-- they only contain the information that is needed to perform the operation.dataAlgebrawhereRowNum::SemInfRowNum->AlgNode->Algebra-- Should have one child-- RowId :: SemInfRowId -> Algebra -- should have one childRowRank::SemInfRank->AlgNode->Algebra-- should have one childRank::SemInfRank->AlgNode->Algebra-- should have one childProj::SemInfProj->AlgNode->Algebra-- should have one child Sel::SemInfSel->AlgNode->Algebra-- should have one child PosSel::SemInfPosSel->AlgNode->Algebra-- should have one childCross::AlgNode->AlgNode->Algebra-- should have two childrenEqJoin::SemInfEqJoin->AlgNode->AlgNode->Algebra-- should have two children -- SemiJoin :: SemInfEqJoin -> Algebra -- should have two children -- ThetaJoin :: SemInfThetaJoin -> Algebra -- should have two childrenDisjUnion::AlgNode->AlgNode->Algebra-- should have two childrenDifference::AlgNode->AlgNode->Algebra-- should have two childrenDistinct::AlgNode->Algebra-- should have one childLitTable::SemInfLitTable->SchemaInfos->AlgebraEmptyTable::SchemaInfos->AlgebraTableRef::SemInfTableRef->AlgebraAttach::SemInfAttach->AlgNode->Algebra-- should have one childFunBinOp::SemBinOp->AlgNode->Algebra-- should have one childCast::SemInfCast->AlgNode->Algebra-- should have one child-- FunNumEq :: SemInfBinOp -> Algebra -- should have one child-- FunNumGt :: SemInfBinOp -> Algebra -- should have one child-- Fun1To1 :: SemInfFun1To1 -> Algebra -- should have one child-- FunBoolAnd :: SemInfBinOp -> Algebra -- should have one child -- FunBoolOr :: SemInfBinOp -> Algebra -- should have one childFunBoolNot::SemUnOp->AlgNode->Algebra-- should have one childAggr::SemInfAggr->AlgNode->Algebra-- should have one child-- FunAggrCnt :: SemInfFunAggrCnt -> Algebra -- should have one child-- SerializeRel :: SemInfSerRel -> Algebra -- should have two childrenderiving(Show,Eq,Ord)