generateRandom is a special type ClickHouse DBMS table
function which generatesRandom data for given schema
You can use this function in Haskell with given wrapper
{-# LANGUAGE
DataKinds
, DeriveAnyClass
, DerivingStrategies
, OverloadedStrings
#-}
import ClickHaskell
ReadableFrom, generateRandom
(
, openNativeConnection, defaultCredentialsColumns, Column
, ChString, ChUUID, DateTime
,
)import Data.ByteString (ByteString)
import Data.Int (Int64)
import Data.Word (Word32)
import GHC.Generics (Generic)
main :: IO ()
= do
main <- openNativeConnection defaultCredentials
connection <-
_
generateRandom@ExampleColumns
@ExampleData
connection1, 5, 10)
(1
pure
pure ()
{- Before GHC 9.8 its better to use standalone deriving
since type errors occures exact on deriving declaration.
-}
deriving instance ReadableFrom (Columns ExampleColumns) ExampleData
type ExampleColumns =
Column "a1" Int64
'[ Column "a2" ChString
, Column "a3" (DateTime "")
, Column "a4" ChUUID
,
]
data ExampleData = MkExampleData
a1 :: Int64
{ a2 :: ByteString
, a4 :: ChUUID
, a3 :: Word32
,
}deriving (Generic, Show)