{-# 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.DropNullFields
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.DropNullFields where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.NullCheckBoxList
import Amazonka.Glue.Types.NullValueField
import qualified Amazonka.Prelude as Prelude

-- | Specifies a transform that removes columns from the dataset if all
-- values in the column are \'null\'. By default, Glue Studio will
-- recognize null objects, but some values such as empty strings, strings
-- that are \"null\", -1 integers or other placeholders such as zeros, are
-- not automatically recognized as nulls.
--
-- /See:/ 'newDropNullFields' smart constructor.
data DropNullFields = DropNullFields'
  { -- | A structure that represents whether certain values are recognized as
    -- null values for removal.
    DropNullFields -> Maybe NullCheckBoxList
nullCheckBoxList :: Prelude.Maybe NullCheckBoxList,
    -- | A structure that specifies a list of NullValueField structures that
    -- represent a custom null value such as zero or other value being used as
    -- a null placeholder unique to the dataset.
    --
    -- The @DropNullFields@ transform removes custom null values only if both
    -- the value of the null placeholder and the datatype match the data.
    DropNullFields -> Maybe [NullValueField]
nullTextList :: Prelude.Maybe [NullValueField],
    -- | The name of the transform node.
    DropNullFields -> Text
name :: Prelude.Text,
    -- | The data inputs identified by their node names.
    DropNullFields -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DropNullFields -> DropNullFields -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DropNullFields -> DropNullFields -> Bool
$c/= :: DropNullFields -> DropNullFields -> Bool
== :: DropNullFields -> DropNullFields -> Bool
$c== :: DropNullFields -> DropNullFields -> Bool
Prelude.Eq, ReadPrec [DropNullFields]
ReadPrec DropNullFields
Int -> ReadS DropNullFields
ReadS [DropNullFields]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DropNullFields]
$creadListPrec :: ReadPrec [DropNullFields]
readPrec :: ReadPrec DropNullFields
$creadPrec :: ReadPrec DropNullFields
readList :: ReadS [DropNullFields]
$creadList :: ReadS [DropNullFields]
readsPrec :: Int -> ReadS DropNullFields
$creadsPrec :: Int -> ReadS DropNullFields
Prelude.Read, Int -> DropNullFields -> ShowS
[DropNullFields] -> ShowS
DropNullFields -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DropNullFields] -> ShowS
$cshowList :: [DropNullFields] -> ShowS
show :: DropNullFields -> String
$cshow :: DropNullFields -> String
showsPrec :: Int -> DropNullFields -> ShowS
$cshowsPrec :: Int -> DropNullFields -> ShowS
Prelude.Show, forall x. Rep DropNullFields x -> DropNullFields
forall x. DropNullFields -> Rep DropNullFields x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DropNullFields x -> DropNullFields
$cfrom :: forall x. DropNullFields -> Rep DropNullFields x
Prelude.Generic)

-- |
-- Create a value of 'DropNullFields' 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:
--
-- 'nullCheckBoxList', 'dropNullFields_nullCheckBoxList' - A structure that represents whether certain values are recognized as
-- null values for removal.
--
-- 'nullTextList', 'dropNullFields_nullTextList' - A structure that specifies a list of NullValueField structures that
-- represent a custom null value such as zero or other value being used as
-- a null placeholder unique to the dataset.
--
-- The @DropNullFields@ transform removes custom null values only if both
-- the value of the null placeholder and the datatype match the data.
--
-- 'name', 'dropNullFields_name' - The name of the transform node.
--
-- 'inputs', 'dropNullFields_inputs' - The data inputs identified by their node names.
newDropNullFields ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  DropNullFields
newDropNullFields :: Text -> NonEmpty Text -> DropNullFields
newDropNullFields Text
pName_ NonEmpty Text
pInputs_ =
  DropNullFields'
    { $sel:nullCheckBoxList:DropNullFields' :: Maybe NullCheckBoxList
nullCheckBoxList = forall a. Maybe a
Prelude.Nothing,
      $sel:nullTextList:DropNullFields' :: Maybe [NullValueField]
nullTextList = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DropNullFields' :: Text
name = Text
pName_,
      $sel:inputs:DropNullFields' :: NonEmpty Text
inputs = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInputs_
    }

-- | A structure that represents whether certain values are recognized as
-- null values for removal.
dropNullFields_nullCheckBoxList :: Lens.Lens' DropNullFields (Prelude.Maybe NullCheckBoxList)
dropNullFields_nullCheckBoxList :: Lens' DropNullFields (Maybe NullCheckBoxList)
dropNullFields_nullCheckBoxList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropNullFields' {Maybe NullCheckBoxList
nullCheckBoxList :: Maybe NullCheckBoxList
$sel:nullCheckBoxList:DropNullFields' :: DropNullFields -> Maybe NullCheckBoxList
nullCheckBoxList} -> Maybe NullCheckBoxList
nullCheckBoxList) (\s :: DropNullFields
s@DropNullFields' {} Maybe NullCheckBoxList
a -> DropNullFields
s {$sel:nullCheckBoxList:DropNullFields' :: Maybe NullCheckBoxList
nullCheckBoxList = Maybe NullCheckBoxList
a} :: DropNullFields)

-- | A structure that specifies a list of NullValueField structures that
-- represent a custom null value such as zero or other value being used as
-- a null placeholder unique to the dataset.
--
-- The @DropNullFields@ transform removes custom null values only if both
-- the value of the null placeholder and the datatype match the data.
dropNullFields_nullTextList :: Lens.Lens' DropNullFields (Prelude.Maybe [NullValueField])
dropNullFields_nullTextList :: Lens' DropNullFields (Maybe [NullValueField])
dropNullFields_nullTextList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropNullFields' {Maybe [NullValueField]
nullTextList :: Maybe [NullValueField]
$sel:nullTextList:DropNullFields' :: DropNullFields -> Maybe [NullValueField]
nullTextList} -> Maybe [NullValueField]
nullTextList) (\s :: DropNullFields
s@DropNullFields' {} Maybe [NullValueField]
a -> DropNullFields
s {$sel:nullTextList:DropNullFields' :: Maybe [NullValueField]
nullTextList = Maybe [NullValueField]
a} :: DropNullFields) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the transform node.
dropNullFields_name :: Lens.Lens' DropNullFields Prelude.Text
dropNullFields_name :: Lens' DropNullFields Text
dropNullFields_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropNullFields' {Text
name :: Text
$sel:name:DropNullFields' :: DropNullFields -> Text
name} -> Text
name) (\s :: DropNullFields
s@DropNullFields' {} Text
a -> DropNullFields
s {$sel:name:DropNullFields' :: Text
name = Text
a} :: DropNullFields)

-- | The data inputs identified by their node names.
dropNullFields_inputs :: Lens.Lens' DropNullFields (Prelude.NonEmpty Prelude.Text)
dropNullFields_inputs :: Lens' DropNullFields (NonEmpty Text)
dropNullFields_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropNullFields' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:DropNullFields' :: DropNullFields -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: DropNullFields
s@DropNullFields' {} NonEmpty Text
a -> DropNullFields
s {$sel:inputs:DropNullFields' :: NonEmpty Text
inputs = NonEmpty Text
a} :: DropNullFields) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON DropNullFields where
  parseJSON :: Value -> Parser DropNullFields
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DropNullFields"
      ( \Object
x ->
          Maybe NullCheckBoxList
-> Maybe [NullValueField]
-> Text
-> NonEmpty Text
-> DropNullFields
DropNullFields'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NullCheckBoxList")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NullTextList" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Inputs")
      )

instance Prelude.Hashable DropNullFields where
  hashWithSalt :: Int -> DropNullFields -> Int
hashWithSalt Int
_salt DropNullFields' {Maybe [NullValueField]
Maybe NullCheckBoxList
NonEmpty Text
Text
inputs :: NonEmpty Text
name :: Text
nullTextList :: Maybe [NullValueField]
nullCheckBoxList :: Maybe NullCheckBoxList
$sel:inputs:DropNullFields' :: DropNullFields -> NonEmpty Text
$sel:name:DropNullFields' :: DropNullFields -> Text
$sel:nullTextList:DropNullFields' :: DropNullFields -> Maybe [NullValueField]
$sel:nullCheckBoxList:DropNullFields' :: DropNullFields -> Maybe NullCheckBoxList
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NullCheckBoxList
nullCheckBoxList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NullValueField]
nullTextList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
inputs

instance Prelude.NFData DropNullFields where
  rnf :: DropNullFields -> ()
rnf DropNullFields' {Maybe [NullValueField]
Maybe NullCheckBoxList
NonEmpty Text
Text
inputs :: NonEmpty Text
name :: Text
nullTextList :: Maybe [NullValueField]
nullCheckBoxList :: Maybe NullCheckBoxList
$sel:inputs:DropNullFields' :: DropNullFields -> NonEmpty Text
$sel:name:DropNullFields' :: DropNullFields -> Text
$sel:nullTextList:DropNullFields' :: DropNullFields -> Maybe [NullValueField]
$sel:nullCheckBoxList:DropNullFields' :: DropNullFields -> Maybe NullCheckBoxList
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NullCheckBoxList
nullCheckBoxList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [NullValueField]
nullTextList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
inputs

instance Data.ToJSON DropNullFields where
  toJSON :: DropNullFields -> Value
toJSON DropNullFields' {Maybe [NullValueField]
Maybe NullCheckBoxList
NonEmpty Text
Text
inputs :: NonEmpty Text
name :: Text
nullTextList :: Maybe [NullValueField]
nullCheckBoxList :: Maybe NullCheckBoxList
$sel:inputs:DropNullFields' :: DropNullFields -> NonEmpty Text
$sel:name:DropNullFields' :: DropNullFields -> Text
$sel:nullTextList:DropNullFields' :: DropNullFields -> Maybe [NullValueField]
$sel:nullCheckBoxList:DropNullFields' :: DropNullFields -> Maybe NullCheckBoxList
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NullCheckBoxList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NullCheckBoxList
nullCheckBoxList,
            (Key
"NullTextList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [NullValueField]
nullTextList,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Inputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
inputs)
          ]
      )