{-# 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.DateColumnStatisticsData
-- 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.DateColumnStatisticsData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines column statistics supported for timestamp data columns.
--
-- /See:/ 'newDateColumnStatisticsData' smart constructor.
data DateColumnStatisticsData = DateColumnStatisticsData'
  { -- | The highest value in the column.
    DateColumnStatisticsData -> Maybe POSIX
maximumValue :: Prelude.Maybe Core.POSIX,
    -- | The lowest value in the column.
    DateColumnStatisticsData -> Maybe POSIX
minimumValue :: Prelude.Maybe Core.POSIX,
    -- | The number of null values in the column.
    DateColumnStatisticsData -> Natural
numberOfNulls :: Prelude.Natural,
    -- | The number of distinct values in a column.
    DateColumnStatisticsData -> Natural
numberOfDistinctValues :: Prelude.Natural
  }
  deriving (DateColumnStatisticsData -> DateColumnStatisticsData -> Bool
(DateColumnStatisticsData -> DateColumnStatisticsData -> Bool)
-> (DateColumnStatisticsData -> DateColumnStatisticsData -> Bool)
-> Eq DateColumnStatisticsData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DateColumnStatisticsData -> DateColumnStatisticsData -> Bool
$c/= :: DateColumnStatisticsData -> DateColumnStatisticsData -> Bool
== :: DateColumnStatisticsData -> DateColumnStatisticsData -> Bool
$c== :: DateColumnStatisticsData -> DateColumnStatisticsData -> Bool
Prelude.Eq, ReadPrec [DateColumnStatisticsData]
ReadPrec DateColumnStatisticsData
Int -> ReadS DateColumnStatisticsData
ReadS [DateColumnStatisticsData]
(Int -> ReadS DateColumnStatisticsData)
-> ReadS [DateColumnStatisticsData]
-> ReadPrec DateColumnStatisticsData
-> ReadPrec [DateColumnStatisticsData]
-> Read DateColumnStatisticsData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DateColumnStatisticsData]
$creadListPrec :: ReadPrec [DateColumnStatisticsData]
readPrec :: ReadPrec DateColumnStatisticsData
$creadPrec :: ReadPrec DateColumnStatisticsData
readList :: ReadS [DateColumnStatisticsData]
$creadList :: ReadS [DateColumnStatisticsData]
readsPrec :: Int -> ReadS DateColumnStatisticsData
$creadsPrec :: Int -> ReadS DateColumnStatisticsData
Prelude.Read, Int -> DateColumnStatisticsData -> ShowS
[DateColumnStatisticsData] -> ShowS
DateColumnStatisticsData -> String
(Int -> DateColumnStatisticsData -> ShowS)
-> (DateColumnStatisticsData -> String)
-> ([DateColumnStatisticsData] -> ShowS)
-> Show DateColumnStatisticsData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DateColumnStatisticsData] -> ShowS
$cshowList :: [DateColumnStatisticsData] -> ShowS
show :: DateColumnStatisticsData -> String
$cshow :: DateColumnStatisticsData -> String
showsPrec :: Int -> DateColumnStatisticsData -> ShowS
$cshowsPrec :: Int -> DateColumnStatisticsData -> ShowS
Prelude.Show, (forall x.
 DateColumnStatisticsData -> Rep DateColumnStatisticsData x)
-> (forall x.
    Rep DateColumnStatisticsData x -> DateColumnStatisticsData)
-> Generic DateColumnStatisticsData
forall x.
Rep DateColumnStatisticsData x -> DateColumnStatisticsData
forall x.
DateColumnStatisticsData -> Rep DateColumnStatisticsData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DateColumnStatisticsData x -> DateColumnStatisticsData
$cfrom :: forall x.
DateColumnStatisticsData -> Rep DateColumnStatisticsData x
Prelude.Generic)

-- |
-- Create a value of 'DateColumnStatisticsData' 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:
--
-- 'maximumValue', 'dateColumnStatisticsData_maximumValue' - The highest value in the column.
--
-- 'minimumValue', 'dateColumnStatisticsData_minimumValue' - The lowest value in the column.
--
-- 'numberOfNulls', 'dateColumnStatisticsData_numberOfNulls' - The number of null values in the column.
--
-- 'numberOfDistinctValues', 'dateColumnStatisticsData_numberOfDistinctValues' - The number of distinct values in a column.
newDateColumnStatisticsData ::
  -- | 'numberOfNulls'
  Prelude.Natural ->
  -- | 'numberOfDistinctValues'
  Prelude.Natural ->
  DateColumnStatisticsData
newDateColumnStatisticsData :: Natural -> Natural -> DateColumnStatisticsData
newDateColumnStatisticsData
  Natural
pNumberOfNulls_
  Natural
pNumberOfDistinctValues_ =
    DateColumnStatisticsData' :: Maybe POSIX
-> Maybe POSIX -> Natural -> Natural -> DateColumnStatisticsData
DateColumnStatisticsData'
      { $sel:maximumValue:DateColumnStatisticsData' :: Maybe POSIX
maximumValue =
          Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:minimumValue:DateColumnStatisticsData' :: Maybe POSIX
minimumValue = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:numberOfNulls:DateColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_,
        $sel:numberOfDistinctValues:DateColumnStatisticsData' :: Natural
numberOfDistinctValues = Natural
pNumberOfDistinctValues_
      }

-- | The highest value in the column.
dateColumnStatisticsData_maximumValue :: Lens.Lens' DateColumnStatisticsData (Prelude.Maybe Prelude.UTCTime)
dateColumnStatisticsData_maximumValue :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DateColumnStatisticsData -> f DateColumnStatisticsData
dateColumnStatisticsData_maximumValue = (DateColumnStatisticsData -> Maybe POSIX)
-> (DateColumnStatisticsData
    -> Maybe POSIX -> DateColumnStatisticsData)
-> Lens
     DateColumnStatisticsData
     DateColumnStatisticsData
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateColumnStatisticsData' {Maybe POSIX
maximumValue :: Maybe POSIX
$sel:maximumValue:DateColumnStatisticsData' :: DateColumnStatisticsData -> Maybe POSIX
maximumValue} -> Maybe POSIX
maximumValue) (\s :: DateColumnStatisticsData
s@DateColumnStatisticsData' {} Maybe POSIX
a -> DateColumnStatisticsData
s {$sel:maximumValue:DateColumnStatisticsData' :: Maybe POSIX
maximumValue = Maybe POSIX
a} :: DateColumnStatisticsData) ((Maybe POSIX -> f (Maybe POSIX))
 -> DateColumnStatisticsData -> f DateColumnStatisticsData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DateColumnStatisticsData
-> f DateColumnStatisticsData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The lowest value in the column.
dateColumnStatisticsData_minimumValue :: Lens.Lens' DateColumnStatisticsData (Prelude.Maybe Prelude.UTCTime)
dateColumnStatisticsData_minimumValue :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DateColumnStatisticsData -> f DateColumnStatisticsData
dateColumnStatisticsData_minimumValue = (DateColumnStatisticsData -> Maybe POSIX)
-> (DateColumnStatisticsData
    -> Maybe POSIX -> DateColumnStatisticsData)
-> Lens
     DateColumnStatisticsData
     DateColumnStatisticsData
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateColumnStatisticsData' {Maybe POSIX
minimumValue :: Maybe POSIX
$sel:minimumValue:DateColumnStatisticsData' :: DateColumnStatisticsData -> Maybe POSIX
minimumValue} -> Maybe POSIX
minimumValue) (\s :: DateColumnStatisticsData
s@DateColumnStatisticsData' {} Maybe POSIX
a -> DateColumnStatisticsData
s {$sel:minimumValue:DateColumnStatisticsData' :: Maybe POSIX
minimumValue = Maybe POSIX
a} :: DateColumnStatisticsData) ((Maybe POSIX -> f (Maybe POSIX))
 -> DateColumnStatisticsData -> f DateColumnStatisticsData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DateColumnStatisticsData
-> f DateColumnStatisticsData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The number of null values in the column.
dateColumnStatisticsData_numberOfNulls :: Lens.Lens' DateColumnStatisticsData Prelude.Natural
dateColumnStatisticsData_numberOfNulls :: (Natural -> f Natural)
-> DateColumnStatisticsData -> f DateColumnStatisticsData
dateColumnStatisticsData_numberOfNulls = (DateColumnStatisticsData -> Natural)
-> (DateColumnStatisticsData
    -> Natural -> DateColumnStatisticsData)
-> Lens
     DateColumnStatisticsData DateColumnStatisticsData Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateColumnStatisticsData' {Natural
numberOfNulls :: Natural
$sel:numberOfNulls:DateColumnStatisticsData' :: DateColumnStatisticsData -> Natural
numberOfNulls} -> Natural
numberOfNulls) (\s :: DateColumnStatisticsData
s@DateColumnStatisticsData' {} Natural
a -> DateColumnStatisticsData
s {$sel:numberOfNulls:DateColumnStatisticsData' :: Natural
numberOfNulls = Natural
a} :: DateColumnStatisticsData)

-- | The number of distinct values in a column.
dateColumnStatisticsData_numberOfDistinctValues :: Lens.Lens' DateColumnStatisticsData Prelude.Natural
dateColumnStatisticsData_numberOfDistinctValues :: (Natural -> f Natural)
-> DateColumnStatisticsData -> f DateColumnStatisticsData
dateColumnStatisticsData_numberOfDistinctValues = (DateColumnStatisticsData -> Natural)
-> (DateColumnStatisticsData
    -> Natural -> DateColumnStatisticsData)
-> Lens
     DateColumnStatisticsData DateColumnStatisticsData Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateColumnStatisticsData' {Natural
numberOfDistinctValues :: Natural
$sel:numberOfDistinctValues:DateColumnStatisticsData' :: DateColumnStatisticsData -> Natural
numberOfDistinctValues} -> Natural
numberOfDistinctValues) (\s :: DateColumnStatisticsData
s@DateColumnStatisticsData' {} Natural
a -> DateColumnStatisticsData
s {$sel:numberOfDistinctValues:DateColumnStatisticsData' :: Natural
numberOfDistinctValues = Natural
a} :: DateColumnStatisticsData)

instance Core.FromJSON DateColumnStatisticsData where
  parseJSON :: Value -> Parser DateColumnStatisticsData
parseJSON =
    String
-> (Object -> Parser DateColumnStatisticsData)
-> Value
-> Parser DateColumnStatisticsData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DateColumnStatisticsData"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX -> Natural -> Natural -> DateColumnStatisticsData
DateColumnStatisticsData'
            (Maybe POSIX
 -> Maybe POSIX -> Natural -> Natural -> DateColumnStatisticsData)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX -> Natural -> Natural -> DateColumnStatisticsData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumValue")
            Parser
  (Maybe POSIX -> Natural -> Natural -> DateColumnStatisticsData)
-> Parser (Maybe POSIX)
-> Parser (Natural -> Natural -> DateColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinimumValue")
            Parser (Natural -> Natural -> DateColumnStatisticsData)
-> Parser Natural -> Parser (Natural -> DateColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NumberOfNulls")
            Parser (Natural -> DateColumnStatisticsData)
-> Parser Natural -> Parser DateColumnStatisticsData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NumberOfDistinctValues")
      )

instance Prelude.Hashable DateColumnStatisticsData

instance Prelude.NFData DateColumnStatisticsData

instance Core.ToJSON DateColumnStatisticsData where
  toJSON :: DateColumnStatisticsData -> Value
toJSON DateColumnStatisticsData' {Natural
Maybe POSIX
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
minimumValue :: Maybe POSIX
maximumValue :: Maybe POSIX
$sel:numberOfDistinctValues:DateColumnStatisticsData' :: DateColumnStatisticsData -> Natural
$sel:numberOfNulls:DateColumnStatisticsData' :: DateColumnStatisticsData -> Natural
$sel:minimumValue:DateColumnStatisticsData' :: DateColumnStatisticsData -> Maybe POSIX
$sel:maximumValue:DateColumnStatisticsData' :: DateColumnStatisticsData -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaximumValue" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
maximumValue,
            (Text
"MinimumValue" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
minimumValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"NumberOfNulls" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
numberOfNulls),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"NumberOfDistinctValues"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
numberOfDistinctValues
              )
          ]
      )