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

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

-- | Specifies skewed values in a table. Skewed values are those that occur
-- with very high frequency.
--
-- /See:/ 'newSkewedInfo' smart constructor.
data SkewedInfo = SkewedInfo'
  { -- | A mapping of skewed values to the columns that contain them.
    SkewedInfo -> Maybe (HashMap Text Text)
skewedColumnValueLocationMaps :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A list of values that appear so frequently as to be considered skewed.
    SkewedInfo -> Maybe [Text]
skewedColumnValues :: Prelude.Maybe [Prelude.Text],
    -- | A list of names of columns that contain skewed values.
    SkewedInfo -> Maybe [Text]
skewedColumnNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (SkewedInfo -> SkewedInfo -> Bool
(SkewedInfo -> SkewedInfo -> Bool)
-> (SkewedInfo -> SkewedInfo -> Bool) -> Eq SkewedInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SkewedInfo -> SkewedInfo -> Bool
$c/= :: SkewedInfo -> SkewedInfo -> Bool
== :: SkewedInfo -> SkewedInfo -> Bool
$c== :: SkewedInfo -> SkewedInfo -> Bool
Prelude.Eq, ReadPrec [SkewedInfo]
ReadPrec SkewedInfo
Int -> ReadS SkewedInfo
ReadS [SkewedInfo]
(Int -> ReadS SkewedInfo)
-> ReadS [SkewedInfo]
-> ReadPrec SkewedInfo
-> ReadPrec [SkewedInfo]
-> Read SkewedInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SkewedInfo]
$creadListPrec :: ReadPrec [SkewedInfo]
readPrec :: ReadPrec SkewedInfo
$creadPrec :: ReadPrec SkewedInfo
readList :: ReadS [SkewedInfo]
$creadList :: ReadS [SkewedInfo]
readsPrec :: Int -> ReadS SkewedInfo
$creadsPrec :: Int -> ReadS SkewedInfo
Prelude.Read, Int -> SkewedInfo -> ShowS
[SkewedInfo] -> ShowS
SkewedInfo -> String
(Int -> SkewedInfo -> ShowS)
-> (SkewedInfo -> String)
-> ([SkewedInfo] -> ShowS)
-> Show SkewedInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SkewedInfo] -> ShowS
$cshowList :: [SkewedInfo] -> ShowS
show :: SkewedInfo -> String
$cshow :: SkewedInfo -> String
showsPrec :: Int -> SkewedInfo -> ShowS
$cshowsPrec :: Int -> SkewedInfo -> ShowS
Prelude.Show, (forall x. SkewedInfo -> Rep SkewedInfo x)
-> (forall x. Rep SkewedInfo x -> SkewedInfo) -> Generic SkewedInfo
forall x. Rep SkewedInfo x -> SkewedInfo
forall x. SkewedInfo -> Rep SkewedInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SkewedInfo x -> SkewedInfo
$cfrom :: forall x. SkewedInfo -> Rep SkewedInfo x
Prelude.Generic)

-- |
-- Create a value of 'SkewedInfo' 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:
--
-- 'skewedColumnValueLocationMaps', 'skewedInfo_skewedColumnValueLocationMaps' - A mapping of skewed values to the columns that contain them.
--
-- 'skewedColumnValues', 'skewedInfo_skewedColumnValues' - A list of values that appear so frequently as to be considered skewed.
--
-- 'skewedColumnNames', 'skewedInfo_skewedColumnNames' - A list of names of columns that contain skewed values.
newSkewedInfo ::
  SkewedInfo
newSkewedInfo :: SkewedInfo
newSkewedInfo =
  SkewedInfo' :: Maybe (HashMap Text Text)
-> Maybe [Text] -> Maybe [Text] -> SkewedInfo
SkewedInfo'
    { $sel:skewedColumnValueLocationMaps:SkewedInfo' :: Maybe (HashMap Text Text)
skewedColumnValueLocationMaps =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:skewedColumnValues:SkewedInfo' :: Maybe [Text]
skewedColumnValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:skewedColumnNames:SkewedInfo' :: Maybe [Text]
skewedColumnNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | A mapping of skewed values to the columns that contain them.
skewedInfo_skewedColumnValueLocationMaps :: Lens.Lens' SkewedInfo (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
skewedInfo_skewedColumnValueLocationMaps :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SkewedInfo -> f SkewedInfo
skewedInfo_skewedColumnValueLocationMaps = (SkewedInfo -> Maybe (HashMap Text Text))
-> (SkewedInfo -> Maybe (HashMap Text Text) -> SkewedInfo)
-> Lens
     SkewedInfo
     SkewedInfo
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SkewedInfo' {Maybe (HashMap Text Text)
skewedColumnValueLocationMaps :: Maybe (HashMap Text Text)
$sel:skewedColumnValueLocationMaps:SkewedInfo' :: SkewedInfo -> Maybe (HashMap Text Text)
skewedColumnValueLocationMaps} -> Maybe (HashMap Text Text)
skewedColumnValueLocationMaps) (\s :: SkewedInfo
s@SkewedInfo' {} Maybe (HashMap Text Text)
a -> SkewedInfo
s {$sel:skewedColumnValueLocationMaps:SkewedInfo' :: Maybe (HashMap Text Text)
skewedColumnValueLocationMaps = Maybe (HashMap Text Text)
a} :: SkewedInfo) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> SkewedInfo -> f SkewedInfo)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SkewedInfo
-> f SkewedInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of values that appear so frequently as to be considered skewed.
skewedInfo_skewedColumnValues :: Lens.Lens' SkewedInfo (Prelude.Maybe [Prelude.Text])
skewedInfo_skewedColumnValues :: (Maybe [Text] -> f (Maybe [Text])) -> SkewedInfo -> f SkewedInfo
skewedInfo_skewedColumnValues = (SkewedInfo -> Maybe [Text])
-> (SkewedInfo -> Maybe [Text] -> SkewedInfo)
-> Lens SkewedInfo SkewedInfo (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SkewedInfo' {Maybe [Text]
skewedColumnValues :: Maybe [Text]
$sel:skewedColumnValues:SkewedInfo' :: SkewedInfo -> Maybe [Text]
skewedColumnValues} -> Maybe [Text]
skewedColumnValues) (\s :: SkewedInfo
s@SkewedInfo' {} Maybe [Text]
a -> SkewedInfo
s {$sel:skewedColumnValues:SkewedInfo' :: Maybe [Text]
skewedColumnValues = Maybe [Text]
a} :: SkewedInfo) ((Maybe [Text] -> f (Maybe [Text])) -> SkewedInfo -> f SkewedInfo)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SkewedInfo
-> f SkewedInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of names of columns that contain skewed values.
skewedInfo_skewedColumnNames :: Lens.Lens' SkewedInfo (Prelude.Maybe [Prelude.Text])
skewedInfo_skewedColumnNames :: (Maybe [Text] -> f (Maybe [Text])) -> SkewedInfo -> f SkewedInfo
skewedInfo_skewedColumnNames = (SkewedInfo -> Maybe [Text])
-> (SkewedInfo -> Maybe [Text] -> SkewedInfo)
-> Lens SkewedInfo SkewedInfo (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SkewedInfo' {Maybe [Text]
skewedColumnNames :: Maybe [Text]
$sel:skewedColumnNames:SkewedInfo' :: SkewedInfo -> Maybe [Text]
skewedColumnNames} -> Maybe [Text]
skewedColumnNames) (\s :: SkewedInfo
s@SkewedInfo' {} Maybe [Text]
a -> SkewedInfo
s {$sel:skewedColumnNames:SkewedInfo' :: Maybe [Text]
skewedColumnNames = Maybe [Text]
a} :: SkewedInfo) ((Maybe [Text] -> f (Maybe [Text])) -> SkewedInfo -> f SkewedInfo)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SkewedInfo
-> f SkewedInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SkewedInfo where
  parseJSON :: Value -> Parser SkewedInfo
parseJSON =
    String
-> (Object -> Parser SkewedInfo) -> Value -> Parser SkewedInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SkewedInfo"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe [Text] -> Maybe [Text] -> SkewedInfo
SkewedInfo'
            (Maybe (HashMap Text Text)
 -> Maybe [Text] -> Maybe [Text] -> SkewedInfo)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe [Text] -> Maybe [Text] -> SkewedInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SkewedColumnValueLocationMaps"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Text] -> Maybe [Text] -> SkewedInfo)
-> Parser (Maybe [Text]) -> Parser (Maybe [Text] -> SkewedInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SkewedColumnValues"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Text] -> SkewedInfo)
-> Parser (Maybe [Text]) -> Parser SkewedInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SkewedColumnNames"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SkewedInfo

instance Prelude.NFData SkewedInfo

instance Core.ToJSON SkewedInfo where
  toJSON :: SkewedInfo -> Value
toJSON SkewedInfo' {Maybe [Text]
Maybe (HashMap Text Text)
skewedColumnNames :: Maybe [Text]
skewedColumnValues :: Maybe [Text]
skewedColumnValueLocationMaps :: Maybe (HashMap Text Text)
$sel:skewedColumnNames:SkewedInfo' :: SkewedInfo -> Maybe [Text]
$sel:skewedColumnValues:SkewedInfo' :: SkewedInfo -> Maybe [Text]
$sel:skewedColumnValueLocationMaps:SkewedInfo' :: SkewedInfo -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SkewedColumnValueLocationMaps" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
skewedColumnValueLocationMaps,
            (Text
"SkewedColumnValues" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
skewedColumnValues,
            (Text
"SkewedColumnNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
skewedColumnNames
          ]
      )