{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.ColumnStatistics where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.ColumnStatisticsData
import qualified Amazonka.Lens as Lens
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 :: Core.POSIX,
    -- | A @ColumnStatisticData@ object that contains the statistics data values.
    ColumnStatistics -> ColumnStatisticsData
statisticsData :: ColumnStatisticsData
  }
  deriving (ColumnStatistics -> ColumnStatistics -> Bool
(ColumnStatistics -> ColumnStatistics -> Bool)
-> (ColumnStatistics -> ColumnStatistics -> Bool)
-> Eq ColumnStatistics
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]
(Int -> ReadS ColumnStatistics)
-> ReadS [ColumnStatistics]
-> ReadPrec ColumnStatistics
-> ReadPrec [ColumnStatistics]
-> Read 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
(Int -> ColumnStatistics -> ShowS)
-> (ColumnStatistics -> String)
-> ([ColumnStatistics] -> ShowS)
-> Show ColumnStatistics
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. ColumnStatistics -> Rep ColumnStatistics x)
-> (forall x. Rep ColumnStatistics x -> ColumnStatistics)
-> Generic ColumnStatistics
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' :: Text -> Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics
ColumnStatistics'
      { $sel:columnName:ColumnStatistics' :: Text
columnName = Text
pColumnName_,
        $sel:columnType:ColumnStatistics' :: Text
columnType = Text
pColumnType_,
        $sel:analyzedTime:ColumnStatistics' :: POSIX
analyzedTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
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 :: (Text -> f Text) -> ColumnStatistics -> f ColumnStatistics
columnStatistics_columnName = (ColumnStatistics -> Text)
-> (ColumnStatistics -> Text -> ColumnStatistics)
-> Lens ColumnStatistics ColumnStatistics Text Text
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 :: (Text -> f Text) -> ColumnStatistics -> f ColumnStatistics
columnStatistics_columnType = (ColumnStatistics -> Text)
-> (ColumnStatistics -> Text -> ColumnStatistics)
-> Lens ColumnStatistics ColumnStatistics Text Text
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 :: (UTCTime -> f UTCTime) -> ColumnStatistics -> f ColumnStatistics
columnStatistics_analyzedTime = (ColumnStatistics -> POSIX)
-> (ColumnStatistics -> POSIX -> ColumnStatistics)
-> Lens ColumnStatistics ColumnStatistics POSIX POSIX
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) ((POSIX -> f POSIX) -> ColumnStatistics -> f ColumnStatistics)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ColumnStatistics
-> f ColumnStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A @ColumnStatisticData@ object that contains the statistics data values.
columnStatistics_statisticsData :: Lens.Lens' ColumnStatistics ColumnStatisticsData
columnStatistics_statisticsData :: (ColumnStatisticsData -> f ColumnStatisticsData)
-> ColumnStatistics -> f ColumnStatistics
columnStatistics_statisticsData = (ColumnStatistics -> ColumnStatisticsData)
-> (ColumnStatistics -> ColumnStatisticsData -> ColumnStatistics)
-> Lens
     ColumnStatistics
     ColumnStatistics
     ColumnStatisticsData
     ColumnStatisticsData
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 Core.FromJSON ColumnStatistics where
  parseJSON :: Value -> Parser ColumnStatistics
parseJSON =
    String
-> (Object -> Parser ColumnStatistics)
-> Value
-> Parser ColumnStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ColumnStatistics"
      ( \Object
x ->
          Text -> Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics
ColumnStatistics'
            (Text -> Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics)
-> Parser Text
-> Parser
     (Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ColumnName")
            Parser (Text -> POSIX -> ColumnStatisticsData -> ColumnStatistics)
-> Parser Text
-> Parser (POSIX -> ColumnStatisticsData -> ColumnStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ColumnType")
            Parser (POSIX -> ColumnStatisticsData -> ColumnStatistics)
-> Parser POSIX
-> Parser (ColumnStatisticsData -> ColumnStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AnalyzedTime")
            Parser (ColumnStatisticsData -> ColumnStatistics)
-> Parser ColumnStatisticsData -> Parser ColumnStatistics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ColumnStatisticsData
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StatisticsData")
      )

instance Prelude.Hashable ColumnStatistics

instance Prelude.NFData ColumnStatistics

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ColumnName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
columnName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ColumnType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
columnType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AnalyzedTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
analyzedTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"StatisticsData" Text -> ColumnStatisticsData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ColumnStatisticsData
statisticsData)
          ]
      )