{-# 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.Athena.Types.Column
-- 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.Athena.Types.Column where

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

-- | Contains metadata for a column in a table.
--
-- /See:/ 'newColumn' smart constructor.
data Column = Column'
  { -- | The data type of the column.
    Column -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | Optional information about the column.
    Column -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The name of the column.
    Column -> Text
name :: Prelude.Text
  }
  deriving (Column -> Column -> Bool
(Column -> Column -> Bool)
-> (Column -> Column -> Bool) -> Eq Column
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Column -> Column -> Bool
$c/= :: Column -> Column -> Bool
== :: Column -> Column -> Bool
$c== :: Column -> Column -> Bool
Prelude.Eq, ReadPrec [Column]
ReadPrec Column
Int -> ReadS Column
ReadS [Column]
(Int -> ReadS Column)
-> ReadS [Column]
-> ReadPrec Column
-> ReadPrec [Column]
-> Read Column
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Column]
$creadListPrec :: ReadPrec [Column]
readPrec :: ReadPrec Column
$creadPrec :: ReadPrec Column
readList :: ReadS [Column]
$creadList :: ReadS [Column]
readsPrec :: Int -> ReadS Column
$creadsPrec :: Int -> ReadS Column
Prelude.Read, Int -> Column -> ShowS
[Column] -> ShowS
Column -> String
(Int -> Column -> ShowS)
-> (Column -> String) -> ([Column] -> ShowS) -> Show Column
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Column] -> ShowS
$cshowList :: [Column] -> ShowS
show :: Column -> String
$cshow :: Column -> String
showsPrec :: Int -> Column -> ShowS
$cshowsPrec :: Int -> Column -> ShowS
Prelude.Show, (forall x. Column -> Rep Column x)
-> (forall x. Rep Column x -> Column) -> Generic Column
forall x. Rep Column x -> Column
forall x. Column -> Rep Column x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Column x -> Column
$cfrom :: forall x. Column -> Rep Column x
Prelude.Generic)

-- |
-- Create a value of 'Column' 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:
--
-- 'type'', 'column_type' - The data type of the column.
--
-- 'comment', 'column_comment' - Optional information about the column.
--
-- 'name', 'column_name' - The name of the column.
newColumn ::
  -- | 'name'
  Prelude.Text ->
  Column
newColumn :: Text -> Column
newColumn Text
pName_ =
  Column' :: Maybe Text -> Maybe Text -> Text -> Column
Column'
    { $sel:type':Column' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:comment:Column' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Column' :: Text
name = Text
pName_
    }

-- | The data type of the column.
column_type :: Lens.Lens' Column (Prelude.Maybe Prelude.Text)
column_type :: (Maybe Text -> f (Maybe Text)) -> Column -> f Column
column_type = (Column -> Maybe Text)
-> (Column -> Maybe Text -> Column)
-> Lens Column Column (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Column' {Maybe Text
type' :: Maybe Text
$sel:type':Column' :: Column -> Maybe Text
type'} -> Maybe Text
type') (\s :: Column
s@Column' {} Maybe Text
a -> Column
s {$sel:type':Column' :: Maybe Text
type' = Maybe Text
a} :: Column)

-- | Optional information about the column.
column_comment :: Lens.Lens' Column (Prelude.Maybe Prelude.Text)
column_comment :: (Maybe Text -> f (Maybe Text)) -> Column -> f Column
column_comment = (Column -> Maybe Text)
-> (Column -> Maybe Text -> Column)
-> Lens Column Column (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Column' {Maybe Text
comment :: Maybe Text
$sel:comment:Column' :: Column -> Maybe Text
comment} -> Maybe Text
comment) (\s :: Column
s@Column' {} Maybe Text
a -> Column
s {$sel:comment:Column' :: Maybe Text
comment = Maybe Text
a} :: Column)

-- | The name of the column.
column_name :: Lens.Lens' Column Prelude.Text
column_name :: (Text -> f Text) -> Column -> f Column
column_name = (Column -> Text)
-> (Column -> Text -> Column) -> Lens Column Column Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Column' {Text
name :: Text
$sel:name:Column' :: Column -> Text
name} -> Text
name) (\s :: Column
s@Column' {} Text
a -> Column
s {$sel:name:Column' :: Text
name = Text
a} :: Column)

instance Core.FromJSON Column where
  parseJSON :: Value -> Parser Column
parseJSON =
    String -> (Object -> Parser Column) -> Value -> Parser Column
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Column"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Column
Column'
            (Maybe Text -> Maybe Text -> Text -> Column)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Text -> Column)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> Text -> Column)
-> Parser (Maybe Text) -> Parser (Text -> Column)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Comment")
            Parser (Text -> Column) -> Parser Text -> Parser Column
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
      )

instance Prelude.Hashable Column

instance Prelude.NFData Column