{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Glue.Types.ColumnStatistics
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.ColumnStatistics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.ColumnStatisticsData
import qualified Amazonka.Prelude as Prelude

-- | Represents the generated column-level statistics for a table or
-- partition.
--
-- /See:/ 'newColumnStatistics' smart constructor.
data ColumnStatistics = ColumnStatistics'
  { -- | Name of column which statistics belong to.
    ColumnStatistics -> Text
columnName :: Prelude.Text,
    -- | The data type of the column.
    ColumnStatistics -> Text
columnType :: Prelude.Text,
    -- | The timestamp of when column statistics were generated.
    ColumnStatistics -> POSIX
analyzedTime :: Data.POSIX,
    -- | A @ColumnStatisticData@ object that contains the statistics data values.
    ColumnStatistics -> ColumnStatisticsData
statisticsData :: ColumnStatisticsData
  }
  deriving (ColumnStatistics -> ColumnStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnStatistics -> ColumnStatistics -> Bool
$c/= :: ColumnStatistics -> ColumnStatistics -> Bool
== :: ColumnStatistics -> ColumnStatistics -> Bool
$c== :: ColumnStatistics -> ColumnStatistics -> Bool
Prelude.Eq, ReadPrec [ColumnStatistics]
ReadPrec ColumnStatistics
Int -> ReadS ColumnStatistics
ReadS [ColumnStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnStatistics]
$creadListPrec :: ReadPrec [ColumnStatistics]
readPrec :: ReadPrec ColumnStatistics
$creadPrec :: ReadPrec ColumnStatistics
readList :: ReadS [ColumnStatistics]
$creadList :: ReadS [ColumnStatistics]
readsPrec :: Int -> ReadS ColumnStatistics
$creadsPrec :: Int -> ReadS ColumnStatistics
Prelude.Read, Int -> ColumnStatistics -> ShowS
[ColumnStatistics] -> ShowS
ColumnStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnStatistics] -> ShowS
$cshowList :: [ColumnStatistics] -> ShowS
show :: ColumnStatistics -> String
$cshow :: ColumnStatistics -> String
showsPrec :: Int -> ColumnStatistics -> ShowS
$cshowsPrec :: Int -> ColumnStatistics -> ShowS
Prelude.Show, forall x. Rep ColumnStatistics x -> ColumnStatistics
forall x. ColumnStatistics -> Rep ColumnStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnStatistics x -> ColumnStatistics
$cfrom :: forall x. ColumnStatistics -> Rep ColumnStatistics x
Prelude.Generic)

-- |
-- Create a value of 'ColumnStatistics' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'columnName', 'columnStatistics_columnName' - Name of column which statistics belong to.
--
-- 'columnType', 'columnStatistics_columnType' - The data type of the column.
--
-- 'analyzedTime', 'columnStatistics_analyzedTime' - The timestamp of when column statistics were generated.
--
-- 'statisticsData', 'columnStatistics_statisticsData' - A @ColumnStatisticData@ object that contains the statistics data values.
newColumnStatistics ::
  -- | 'columnName'
  Prelude.Text ->
  -- | 'columnType'
  Prelude.Text ->
  -- | 'analyzedTime'
  Prelude.UTCTime ->
  -- | 'statisticsData'
  ColumnStatisticsData ->
  ColumnStatistics
newColumnStatistics :: Text -> Text -> UTCTime -> ColumnStatisticsData -> ColumnStatistics
newColumnStatistics
  Text
pColumnName_
  Text
pColumnType_
  UTCTime
pAnalyzedTime_
  ColumnStatisticsData
pStatisticsData_ =
    ColumnStatistics'
      { $sel:columnName:ColumnStatistics' :: Text
columnName = Text
pColumnName_,
        $sel:columnType:ColumnStatistics' :: Text
columnType = Text
pColumnType_,
        $sel:analyzedTime:ColumnStatistics' :: POSIX
analyzedTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pAnalyzedTime_,
        $sel:statisticsData:ColumnStatistics' :: ColumnStatisticsData
statisticsData = ColumnStatisticsData
pStatisticsData_
      }

-- | Name of column which statistics belong to.
columnStatistics_columnName :: Lens.Lens' ColumnStatistics Prelude.Text
columnStatistics_columnName :: Lens' ColumnStatistics Text
columnStatistics_columnName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatistics' {Text
columnName :: Text
$sel:columnName:ColumnStatistics' :: ColumnStatistics -> Text
columnName} -> Text
columnName) (\s :: ColumnStatistics
s@ColumnStatistics' {} Text
a -> ColumnStatistics
s {$sel:columnName:ColumnStatistics' :: Text
columnName = Text
a} :: ColumnStatistics)

-- | The data type of the column.
columnStatistics_columnType :: Lens.Lens' ColumnStatistics Prelude.Text
columnStatistics_columnType :: Lens' ColumnStatistics Text
columnStatistics_columnType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatistics' {Text
columnType :: Text
$sel:columnType:ColumnStatistics' :: ColumnStatistics -> Text
columnType} -> Text
columnType) (\s :: ColumnStatistics
s@ColumnStatistics' {} Text
a -> ColumnStatistics
s {$sel:columnType:ColumnStatistics' :: Text
columnType = Text
a} :: ColumnStatistics)

-- | The timestamp of when column statistics were generated.
columnStatistics_analyzedTime :: Lens.Lens' ColumnStatistics Prelude.UTCTime
columnStatistics_analyzedTime :: Lens' ColumnStatistics UTCTime
columnStatistics_analyzedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatistics' {POSIX
analyzedTime :: POSIX
$sel:analyzedTime:ColumnStatistics' :: ColumnStatistics -> POSIX
analyzedTime} -> POSIX
analyzedTime) (\s :: ColumnStatistics
s@ColumnStatistics' {} POSIX
a -> ColumnStatistics
s {$sel:analyzedTime:ColumnStatistics' :: POSIX
analyzedTime = POSIX
a} :: ColumnStatistics) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A @ColumnStatisticData@ object that contains the statistics data values.
columnStatistics_statisticsData :: Lens.Lens' ColumnStatistics ColumnStatisticsData
columnStatistics_statisticsData :: Lens' ColumnStatistics ColumnStatisticsData
columnStatistics_statisticsData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnStatistics' {ColumnStatisticsData
statisticsData :: ColumnStatisticsData
$sel:statisticsData:ColumnStatistics' :: ColumnStatistics -> ColumnStatisticsData
statisticsData} -> ColumnStatisticsData
statisticsData) (\s :: ColumnStatistics
s@ColumnStatistics' {} ColumnStatisticsData
a -> ColumnStatistics
s {$sel:statisticsData:ColumnStatistics' :: ColumnStatisticsData
statisticsData = ColumnStatisticsData
a} :: ColumnStatistics)

instance Data.FromJSON ColumnStatistics where
  parseJSON :: Value -> Parser ColumnStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnStatistics"
      ( \Object
x ->
          Text -> Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics
ColumnStatistics'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ColumnName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ColumnType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AnalyzedTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"StatisticsData")
      )

instance Prelude.Hashable ColumnStatistics where
  hashWithSalt :: Int -> ColumnStatistics -> Int
hashWithSalt Int
_salt ColumnStatistics' {Text
POSIX
ColumnStatisticsData
statisticsData :: ColumnStatisticsData
analyzedTime :: POSIX
columnType :: Text
columnName :: Text
$sel:statisticsData:ColumnStatistics' :: ColumnStatistics -> ColumnStatisticsData
$sel:analyzedTime:ColumnStatistics' :: ColumnStatistics -> POSIX
$sel:columnType:ColumnStatistics' :: ColumnStatistics -> Text
$sel:columnName:ColumnStatistics' :: ColumnStatistics -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
columnName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
columnType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
analyzedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ColumnStatisticsData
statisticsData

instance Prelude.NFData ColumnStatistics where
  rnf :: ColumnStatistics -> ()
rnf ColumnStatistics' {Text
POSIX
ColumnStatisticsData
statisticsData :: ColumnStatisticsData
analyzedTime :: POSIX
columnType :: Text
columnName :: Text
$sel:statisticsData:ColumnStatistics' :: ColumnStatistics -> ColumnStatisticsData
$sel:analyzedTime:ColumnStatistics' :: ColumnStatistics -> POSIX
$sel:columnType:ColumnStatistics' :: ColumnStatistics -> Text
$sel:columnName:ColumnStatistics' :: ColumnStatistics -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
columnName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
columnType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
analyzedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ColumnStatisticsData
statisticsData

instance Data.ToJSON ColumnStatistics where
  toJSON :: ColumnStatistics -> Value
toJSON ColumnStatistics' {Text
POSIX
ColumnStatisticsData
statisticsData :: ColumnStatisticsData
analyzedTime :: POSIX
columnType :: Text
columnName :: Text
$sel:statisticsData:ColumnStatistics' :: ColumnStatistics -> ColumnStatisticsData
$sel:analyzedTime:ColumnStatistics' :: ColumnStatistics -> POSIX
$sel:columnType:ColumnStatistics' :: ColumnStatistics -> Text
$sel:columnName:ColumnStatistics' :: ColumnStatistics -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ColumnName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
columnName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ColumnType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
columnType),
            forall a. a -> Maybe a
Prelude.Just (Key
"AnalyzedTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
analyzedTime),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"StatisticsData" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ColumnStatisticsData
statisticsData)
          ]
      )