Adds an option to choose if fact tables are persistent.

pull/1/head
Abhinav Sarkar 2016-01-07 03:01:50 +05:30
parent 4a7682320b
commit 5b35b03a1a
3 changed files with 7 additions and 5 deletions

View File

@ -53,7 +53,7 @@ writeFiles outputDir env@Env{..} = do
where where
dimTables = [ (fact, extractDimensionTables env fact) | fact <- envFacts ] dimTables = [ (fact, extractDimensionTables env fact) | fact <- envFacts ]
factTables = [ (fact, extractFactTable env fact) | fact <- envFacts ] factTables = [ (fact, extractFactTable env fact) | fact <- envFacts, factTablePersistent fact ]
dimTableDefnSQLs = [ (Create, tableName table, unlines . map sqlStr $ dimensionTableDefnSQL env table) dimTableDefnSQLs = [ (Create, tableName table, unlines . map sqlStr $ dimensionTableDefnSQL env table)
| (_, tabs) <- dimTables | (_, tabs) <- dimTables

View File

@ -67,6 +67,7 @@ instance FromJSON FactColumn where
instance FromJSON Fact where instance FromJSON Fact where
parseJSON (Object o) = Fact <$> o .: "name" parseJSON (Object o) = Fact <$> o .: "name"
<*> o .: "tablename" <*> o .: "tablename"
<*> o .:? "persistent" .!= True
<*> o .:? "parentfacts" .!= [] <*> o .:? "parentfacts" .!= []
<*> o .: "columns" <*> o .: "columns"
parseJSON o = fail $ "Cannot parse fact: " ++ show o parseJSON o = fail $ "Cannot parse fact: " ++ show o

View File

@ -42,10 +42,11 @@ timeUnitToSeconds Day = 24 * timeUnitToSeconds Hour
timeUnitToSeconds Week = 7 * timeUnitToSeconds Day timeUnitToSeconds Week = 7 * timeUnitToSeconds Day
data Fact = Fact data Fact = Fact
{ factName :: !TableName { factName :: !TableName
, factTableName :: !TableName , factTableName :: !TableName
, factParentNames :: ![TableName] , factTablePersistent :: !Bool
, factColumns :: ![FactColumn] , factParentNames :: ![TableName]
, factColumns :: ![FactColumn]
} deriving (Eq, Show) } deriving (Eq, Show)
data FactColumn = DimTime !ColumnName data FactColumn = DimTime !ColumnName