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

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

-- | Defines column statistics supported for character sequence data values.
--
-- /See:/ 'newStringColumnStatisticsData' smart constructor.
data StringColumnStatisticsData = StringColumnStatisticsData'
  { -- | The size of the longest string in the column.
    StringColumnStatisticsData -> Natural
maximumLength :: Prelude.Natural,
    -- | The average string length in the column.
    StringColumnStatisticsData -> Double
averageLength :: Prelude.Double,
    -- | The number of null values in the column.
    StringColumnStatisticsData -> Natural
numberOfNulls :: Prelude.Natural,
    -- | The number of distinct values in a column.
    StringColumnStatisticsData -> Natural
numberOfDistinctValues :: Prelude.Natural
  }
  deriving (StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
(StringColumnStatisticsData -> StringColumnStatisticsData -> Bool)
-> (StringColumnStatisticsData
    -> StringColumnStatisticsData -> Bool)
-> Eq StringColumnStatisticsData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
$c/= :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
== :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
$c== :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
Prelude.Eq, ReadPrec [StringColumnStatisticsData]
ReadPrec StringColumnStatisticsData
Int -> ReadS StringColumnStatisticsData
ReadS [StringColumnStatisticsData]
(Int -> ReadS StringColumnStatisticsData)
-> ReadS [StringColumnStatisticsData]
-> ReadPrec StringColumnStatisticsData
-> ReadPrec [StringColumnStatisticsData]
-> Read StringColumnStatisticsData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StringColumnStatisticsData]
$creadListPrec :: ReadPrec [StringColumnStatisticsData]
readPrec :: ReadPrec StringColumnStatisticsData
$creadPrec :: ReadPrec StringColumnStatisticsData
readList :: ReadS [StringColumnStatisticsData]
$creadList :: ReadS [StringColumnStatisticsData]
readsPrec :: Int -> ReadS StringColumnStatisticsData
$creadsPrec :: Int -> ReadS StringColumnStatisticsData
Prelude.Read, Int -> StringColumnStatisticsData -> ShowS
[StringColumnStatisticsData] -> ShowS
StringColumnStatisticsData -> String
(Int -> StringColumnStatisticsData -> ShowS)
-> (StringColumnStatisticsData -> String)
-> ([StringColumnStatisticsData] -> ShowS)
-> Show StringColumnStatisticsData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringColumnStatisticsData] -> ShowS
$cshowList :: [StringColumnStatisticsData] -> ShowS
show :: StringColumnStatisticsData -> String
$cshow :: StringColumnStatisticsData -> String
showsPrec :: Int -> StringColumnStatisticsData -> ShowS
$cshowsPrec :: Int -> StringColumnStatisticsData -> ShowS
Prelude.Show, (forall x.
 StringColumnStatisticsData -> Rep StringColumnStatisticsData x)
-> (forall x.
    Rep StringColumnStatisticsData x -> StringColumnStatisticsData)
-> Generic StringColumnStatisticsData
forall x.
Rep StringColumnStatisticsData x -> StringColumnStatisticsData
forall x.
StringColumnStatisticsData -> Rep StringColumnStatisticsData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StringColumnStatisticsData x -> StringColumnStatisticsData
$cfrom :: forall x.
StringColumnStatisticsData -> Rep StringColumnStatisticsData x
Prelude.Generic)

-- |
-- Create a value of 'StringColumnStatisticsData' 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:
--
-- 'maximumLength', 'stringColumnStatisticsData_maximumLength' - The size of the longest string in the column.
--
-- 'averageLength', 'stringColumnStatisticsData_averageLength' - The average string length in the column.
--
-- 'numberOfNulls', 'stringColumnStatisticsData_numberOfNulls' - The number of null values in the column.
--
-- 'numberOfDistinctValues', 'stringColumnStatisticsData_numberOfDistinctValues' - The number of distinct values in a column.
newStringColumnStatisticsData ::
  -- | 'maximumLength'
  Prelude.Natural ->
  -- | 'averageLength'
  Prelude.Double ->
  -- | 'numberOfNulls'
  Prelude.Natural ->
  -- | 'numberOfDistinctValues'
  Prelude.Natural ->
  StringColumnStatisticsData
newStringColumnStatisticsData :: Natural
-> Double -> Natural -> Natural -> StringColumnStatisticsData
newStringColumnStatisticsData
  Natural
pMaximumLength_
  Double
pAverageLength_
  Natural
pNumberOfNulls_
  Natural
pNumberOfDistinctValues_ =
    StringColumnStatisticsData' :: Natural
-> Double -> Natural -> Natural -> StringColumnStatisticsData
StringColumnStatisticsData'
      { $sel:maximumLength:StringColumnStatisticsData' :: Natural
maximumLength =
          Natural
pMaximumLength_,
        $sel:averageLength:StringColumnStatisticsData' :: Double
averageLength = Double
pAverageLength_,
        $sel:numberOfNulls:StringColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_,
        $sel:numberOfDistinctValues:StringColumnStatisticsData' :: Natural
numberOfDistinctValues =
          Natural
pNumberOfDistinctValues_
      }

-- | The size of the longest string in the column.
stringColumnStatisticsData_maximumLength :: Lens.Lens' StringColumnStatisticsData Prelude.Natural
stringColumnStatisticsData_maximumLength :: (Natural -> f Natural)
-> StringColumnStatisticsData -> f StringColumnStatisticsData
stringColumnStatisticsData_maximumLength = (StringColumnStatisticsData -> Natural)
-> (StringColumnStatisticsData
    -> Natural -> StringColumnStatisticsData)
-> Lens
     StringColumnStatisticsData
     StringColumnStatisticsData
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringColumnStatisticsData' {Natural
maximumLength :: Natural
$sel:maximumLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
maximumLength} -> Natural
maximumLength) (\s :: StringColumnStatisticsData
s@StringColumnStatisticsData' {} Natural
a -> StringColumnStatisticsData
s {$sel:maximumLength:StringColumnStatisticsData' :: Natural
maximumLength = Natural
a} :: StringColumnStatisticsData)

-- | The average string length in the column.
stringColumnStatisticsData_averageLength :: Lens.Lens' StringColumnStatisticsData Prelude.Double
stringColumnStatisticsData_averageLength :: (Double -> f Double)
-> StringColumnStatisticsData -> f StringColumnStatisticsData
stringColumnStatisticsData_averageLength = (StringColumnStatisticsData -> Double)
-> (StringColumnStatisticsData
    -> Double -> StringColumnStatisticsData)
-> Lens
     StringColumnStatisticsData StringColumnStatisticsData Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringColumnStatisticsData' {Double
averageLength :: Double
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
averageLength} -> Double
averageLength) (\s :: StringColumnStatisticsData
s@StringColumnStatisticsData' {} Double
a -> StringColumnStatisticsData
s {$sel:averageLength:StringColumnStatisticsData' :: Double
averageLength = Double
a} :: StringColumnStatisticsData)

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

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

instance Core.FromJSON StringColumnStatisticsData where
  parseJSON :: Value -> Parser StringColumnStatisticsData
parseJSON =
    String
-> (Object -> Parser StringColumnStatisticsData)
-> Value
-> Parser StringColumnStatisticsData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StringColumnStatisticsData"
      ( \Object
x ->
          Natural
-> Double -> Natural -> Natural -> StringColumnStatisticsData
StringColumnStatisticsData'
            (Natural
 -> Double -> Natural -> Natural -> StringColumnStatisticsData)
-> Parser Natural
-> Parser
     (Double -> Natural -> Natural -> StringColumnStatisticsData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaximumLength")
            Parser (Double -> Natural -> Natural -> StringColumnStatisticsData)
-> Parser Double
-> Parser (Natural -> Natural -> StringColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AverageLength")
            Parser (Natural -> Natural -> StringColumnStatisticsData)
-> Parser Natural -> Parser (Natural -> StringColumnStatisticsData)
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 -> StringColumnStatisticsData)
-> Parser Natural -> Parser StringColumnStatisticsData
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 StringColumnStatisticsData

instance Prelude.NFData StringColumnStatisticsData

instance Core.ToJSON StringColumnStatisticsData where
  toJSON :: StringColumnStatisticsData -> Value
toJSON StringColumnStatisticsData' {Double
Natural
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfDistinctValues:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:numberOfNulls:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
$sel:maximumLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
..} =
    [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
"MaximumLength" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maximumLength),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AverageLength" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
averageLength),
            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
              )
          ]
      )