DBFunctor 0.1.1.1 → 0.1.2.0
raw patch · 4 files changed
+45/−15 lines, 4 filesdep −MissingHPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: MissingH
API changes (from Hackage documentation)
+ RTable.Core: RUTCTime :: !UTCTime -> RDataType
+ RTable.Core: [rutct] :: RDataType -> !UTCTime
- RTable.Core: (.) :: () => (b -> c) -> (a -> b) -> a -> c
+ RTable.Core: (.) :: (b -> c) -> (a -> b) -> a -> c
Files
- ChangeLog.md +3/−0
- DBFunctor.cabal +4/−7
- src/RTable/Core.hs +21/−8
- test/DBFTests.hs +17/−0
ChangeLog.md view
@@ -36,3 +36,6 @@ ### 0.1.1.1 - bumped a version number (the least significant) in order to upload on hackage a new version with correct github links +### 0.1.2.0+- Removed (indirect) dependency to random < 1.2 via package MissingH+- Added support for UTCTime in RDataType
DBFunctor.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 42409ae66ac976df4d4986bf050ccfb427ee448e1a583801ab3559a915aea5f5+-- hash: 0369a0eecf7c62ea8444410e1a78ae26decf5eb5502ebe8c9b0e7a549670f983 name: DBFunctor-version: 0.1.1.1+version: 0.1.2.0 synopsis: DBFunctor - Functional Data Management => ETL/ELT Data Processing in Haskell description: Please see the README on Github at https://github.com/nkarag/haskell-DBFunctor category: ETL@@ -38,8 +38,7 @@ hs-source-dirs: src build-depends:- MissingH- , base >=4.7 && <5+ base >=4.7 && <5 , bytestring , cassava , cereal@@ -62,7 +61,6 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: DBFunctor- , MissingH , base >=4.7 && <5 , bytestring , cassava@@ -87,7 +85,6 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: DBFunctor- , MissingH , base >=4.7 && <5 , bytestring , cassava
src/RTable/Core.hs view
@@ -261,6 +261,8 @@ ,RecordWildCards ,DeriveGeneric -- Allow automatic deriving of instances for the Generic typeclass (see Text.PrettyPrint.Tabulate.Example) ,DeriveDataTypeable -- Enable automatic deriving of instances for the Data typeclass (see Text.PrettyPrint.Tabulate.Example) + ,ExistentialQuantification + ,StandaloneDeriving {-- :set -XDeriveGeneric :set -XDeriveDataTypeable @@ -360,7 +362,7 @@ >>> let rop1 = RFilter (\t-> t<!>"col1" > 2) >>> -- define another filter operation col1 > 3 - >>> let rop2 = RFilter (\t-> t<!>"col1" > 3) + >>> let rop2 = RFilterStandaloneDeriving (\t-> t<!>"col1" > 3) >>> -- Composition of RTable operations via (.) (rop1 returns 2 RTuples and rop2 returns 1 RTuple) >>> printRTable $ (ropU rop2) . (ropU rop1) $ tab1 @@ -637,7 +639,7 @@ import GHC.Generics (Generic) import Control.DeepSeq -import Data.String.Utils (replace) +-- import Data.String.Utils (replace) import Data.Time.Clock (UTCTime(..), diffTimeToPicoseconds, secondsToDiffTime) import Data.Time.Calendar (Day, toGregorian, fromGregorian) @@ -752,10 +754,9 @@ -- This is a strict data type, meaning whenever we evaluate a value of type 'RDataType', -- there must be also evaluated all the fields it contains. data RDataType = - RInt { rint :: !Integer } - -- RChar { rchar :: Char } + RInt { rint :: !Integer } | RText { rtext :: !T.Text } - -- RString {rstring :: [Char]} + | RUTCTime { rutct :: !UTCTime} | RDate { rdate :: !T.Text ,dtformat :: !Text -- ^ e.g., "DD\/MM\/YYYY" @@ -764,8 +765,20 @@ | RDouble { rdouble :: !Double } -- RFloat { rfloat :: Float } | Null - deriving (Show,TB.Typeable, Read, Generic) -- http://stackoverflow.com/questions/6600380/what-is-haskells-data-typeable + deriving (Show, Read, Generic, TB.Typeable) -- http://stackoverflow.com/questions/6600380/what-is-haskells-data-typeable + +-- deriving instance Generic RDataType + +-- instance Show RDataType where +-- show _ = "hello" + +-- instance Read RDataType where +-- readsPrec _ input = +-- case input of +-- 'R':'N':'u':'m':rest -> [(read rest), ""] +-- _ -> [] + -- | In order to be able to force full evaluation up to Normal Form (NF) -- https://www.fpcomplete.com/blog/2017/09/all-about-strictness instance NFData RDataType @@ -1162,7 +1175,7 @@ -- * For minutes: @MI@, e.g., @"01"@, @"1"@, @"59"@ -- * For seconds: @SS@, e.g., @"01"@, @"1"@, @"59"@ -- --- Example of a typical format string is: @"DD\/MM\/YYYY HH:MI:SS@ +-- Example of a typical format string is: @"DD\/MM\/YYYY HH:MI:SS"@ -- -- If no valid format pattern is found then an 'UnsupportedTimeStampFormat' exception is thrown -- @@ -1179,7 +1192,7 @@ else let -- replace HH24 to HH - formatSpec = Data.String.Utils.replace "HH24" "HH" + -- formatSpec = Data.String.Utils.replace "HH24" "HH" ------ New logic
test/DBFTests.hs view
@@ -1191,6 +1191,23 @@ Where (\t -> t <!> "SK" == RInt 3)) ) + putStrLn "*** Test do-notation" + + putStrLn "This is from Julius" + printRTable $ juliusToRTable $ + EtlMapStart + :-> (EtlR $ + ROpStart + :. (Filter (From $ Tab rtab) $ FilterBy (\t -> t!"Name" == T.RText {T.rtext = "Karagiannidis"})) + :. (Join (TabL rtabNew12) (Previous) $ JoinOn (\t1 t2 -> t1!"Number" == t2!"Number")) + :. (Select ["Name","MyTime","Number", "ColNew2"] $ From Previous) + ) + + putStrLn "This is from do-notation" + printRTable $ do + result1 <- f (\t -> t!"Name" == T.RText {T.rtext = "Karagiannidis"}) rtabNew + result2 <- iJ (\t1 t2 -> t1!"Number" == t2!"Number") rtabNew12 (pure result1) + p ["Name","MyTime","Number", "ColNew2"] (pure result2) where myListAgg :: Text -> AggFunction