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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.DecimalNumber
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'DecimalColumnStatisticsData' 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', 'decimalColumnStatisticsData_maximumValue' - The highest value in the column.
--
-- 'minimumValue', 'decimalColumnStatisticsData_minimumValue' - The lowest value in the column.
--
-- 'numberOfNulls', 'decimalColumnStatisticsData_numberOfNulls' - The number of null values in the column.
--
-- 'numberOfDistinctValues', 'decimalColumnStatisticsData_numberOfDistinctValues' - The number of distinct values in a column.
newDecimalColumnStatisticsData ::
  -- | 'numberOfNulls'
  Prelude.Natural ->
  -- | 'numberOfDistinctValues'
  Prelude.Natural ->
  DecimalColumnStatisticsData
newDecimalColumnStatisticsData :: Natural -> Natural -> DecimalColumnStatisticsData
newDecimalColumnStatisticsData
  Natural
pNumberOfNulls_
  Natural
pNumberOfDistinctValues_ =
    DecimalColumnStatisticsData' :: Maybe DecimalNumber
-> Maybe DecimalNumber
-> Natural
-> Natural
-> DecimalColumnStatisticsData
DecimalColumnStatisticsData'
      { $sel:maximumValue:DecimalColumnStatisticsData' :: Maybe DecimalNumber
maximumValue =
          Maybe DecimalNumber
forall a. Maybe a
Prelude.Nothing,
        $sel:minimumValue:DecimalColumnStatisticsData' :: Maybe DecimalNumber
minimumValue = Maybe DecimalNumber
forall a. Maybe a
Prelude.Nothing,
        $sel:numberOfNulls:DecimalColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_,
        $sel:numberOfDistinctValues:DecimalColumnStatisticsData' :: Natural
numberOfDistinctValues =
          Natural
pNumberOfDistinctValues_
      }

-- | The highest value in the column.
decimalColumnStatisticsData_maximumValue :: Lens.Lens' DecimalColumnStatisticsData (Prelude.Maybe DecimalNumber)
decimalColumnStatisticsData_maximumValue :: (Maybe DecimalNumber -> f (Maybe DecimalNumber))
-> DecimalColumnStatisticsData -> f DecimalColumnStatisticsData
decimalColumnStatisticsData_maximumValue = (DecimalColumnStatisticsData -> Maybe DecimalNumber)
-> (DecimalColumnStatisticsData
    -> Maybe DecimalNumber -> DecimalColumnStatisticsData)
-> Lens
     DecimalColumnStatisticsData
     DecimalColumnStatisticsData
     (Maybe DecimalNumber)
     (Maybe DecimalNumber)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecimalColumnStatisticsData' {Maybe DecimalNumber
maximumValue :: Maybe DecimalNumber
$sel:maximumValue:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Maybe DecimalNumber
maximumValue} -> Maybe DecimalNumber
maximumValue) (\s :: DecimalColumnStatisticsData
s@DecimalColumnStatisticsData' {} Maybe DecimalNumber
a -> DecimalColumnStatisticsData
s {$sel:maximumValue:DecimalColumnStatisticsData' :: Maybe DecimalNumber
maximumValue = Maybe DecimalNumber
a} :: DecimalColumnStatisticsData)

-- | The lowest value in the column.
decimalColumnStatisticsData_minimumValue :: Lens.Lens' DecimalColumnStatisticsData (Prelude.Maybe DecimalNumber)
decimalColumnStatisticsData_minimumValue :: (Maybe DecimalNumber -> f (Maybe DecimalNumber))
-> DecimalColumnStatisticsData -> f DecimalColumnStatisticsData
decimalColumnStatisticsData_minimumValue = (DecimalColumnStatisticsData -> Maybe DecimalNumber)
-> (DecimalColumnStatisticsData
    -> Maybe DecimalNumber -> DecimalColumnStatisticsData)
-> Lens
     DecimalColumnStatisticsData
     DecimalColumnStatisticsData
     (Maybe DecimalNumber)
     (Maybe DecimalNumber)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecimalColumnStatisticsData' {Maybe DecimalNumber
minimumValue :: Maybe DecimalNumber
$sel:minimumValue:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Maybe DecimalNumber
minimumValue} -> Maybe DecimalNumber
minimumValue) (\s :: DecimalColumnStatisticsData
s@DecimalColumnStatisticsData' {} Maybe DecimalNumber
a -> DecimalColumnStatisticsData
s {$sel:minimumValue:DecimalColumnStatisticsData' :: Maybe DecimalNumber
minimumValue = Maybe DecimalNumber
a} :: DecimalColumnStatisticsData)

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

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

instance Core.FromJSON DecimalColumnStatisticsData where
  parseJSON :: Value -> Parser DecimalColumnStatisticsData
parseJSON =
    String
-> (Object -> Parser DecimalColumnStatisticsData)
-> Value
-> Parser DecimalColumnStatisticsData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DecimalColumnStatisticsData"
      ( \Object
x ->
          Maybe DecimalNumber
-> Maybe DecimalNumber
-> Natural
-> Natural
-> DecimalColumnStatisticsData
DecimalColumnStatisticsData'
            (Maybe DecimalNumber
 -> Maybe DecimalNumber
 -> Natural
 -> Natural
 -> DecimalColumnStatisticsData)
-> Parser (Maybe DecimalNumber)
-> Parser
     (Maybe DecimalNumber
      -> Natural -> Natural -> DecimalColumnStatisticsData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DecimalNumber)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumValue")
            Parser
  (Maybe DecimalNumber
   -> Natural -> Natural -> DecimalColumnStatisticsData)
-> Parser (Maybe DecimalNumber)
-> Parser (Natural -> Natural -> DecimalColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DecimalNumber)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinimumValue")
            Parser (Natural -> Natural -> DecimalColumnStatisticsData)
-> Parser Natural
-> Parser (Natural -> DecimalColumnStatisticsData)
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 -> DecimalColumnStatisticsData)
-> Parser Natural -> Parser DecimalColumnStatisticsData
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 DecimalColumnStatisticsData

instance Prelude.NFData DecimalColumnStatisticsData

instance Core.ToJSON DecimalColumnStatisticsData where
  toJSON :: DecimalColumnStatisticsData -> Value
toJSON DecimalColumnStatisticsData' {Natural
Maybe DecimalNumber
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
minimumValue :: Maybe DecimalNumber
maximumValue :: Maybe DecimalNumber
$sel:numberOfDistinctValues:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Natural
$sel:numberOfNulls:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Natural
$sel:minimumValue:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Maybe DecimalNumber
$sel:maximumValue:DecimalColumnStatisticsData' :: DecimalColumnStatisticsData -> Maybe DecimalNumber
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaximumValue" Text -> DecimalNumber -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DecimalNumber -> Pair) -> Maybe DecimalNumber -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DecimalNumber
maximumValue,
            (Text
"MinimumValue" Text -> DecimalNumber -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DecimalNumber -> Pair) -> Maybe DecimalNumber -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DecimalNumber
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
              )
          ]
      )