{-# 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.Partition
-- 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.Partition 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.StorageDescriptor
import qualified Amazonka.Prelude as Prelude

-- | Represents a slice of table data.
--
-- /See:/ 'newPartition' smart constructor.
data Partition = Partition'
  { -- | The ID of the Data Catalog in which the partition resides.
    Partition -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The time at which the partition was created.
    Partition -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the catalog database in which to create the partition.
    Partition -> Maybe Text
databaseName :: Prelude.Maybe Prelude.Text,
    -- | The last time at which the partition was accessed.
    Partition -> Maybe POSIX
lastAccessTime :: Prelude.Maybe Data.POSIX,
    -- | The last time at which column statistics were computed for this
    -- partition.
    Partition -> Maybe POSIX
lastAnalyzedTime :: Prelude.Maybe Data.POSIX,
    -- | These key-value pairs define partition parameters.
    Partition -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Provides information about the physical location where the partition is
    -- stored.
    Partition -> Maybe StorageDescriptor
storageDescriptor :: Prelude.Maybe StorageDescriptor,
    -- | The name of the database table in which to create the partition.
    Partition -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | The values of the partition.
    Partition -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Partition -> Partition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Partition -> Partition -> Bool
$c/= :: Partition -> Partition -> Bool
== :: Partition -> Partition -> Bool
$c== :: Partition -> Partition -> Bool
Prelude.Eq, ReadPrec [Partition]
ReadPrec Partition
Int -> ReadS Partition
ReadS [Partition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Partition]
$creadListPrec :: ReadPrec [Partition]
readPrec :: ReadPrec Partition
$creadPrec :: ReadPrec Partition
readList :: ReadS [Partition]
$creadList :: ReadS [Partition]
readsPrec :: Int -> ReadS Partition
$creadsPrec :: Int -> ReadS Partition
Prelude.Read, Int -> Partition -> ShowS
[Partition] -> ShowS
Partition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Partition] -> ShowS
$cshowList :: [Partition] -> ShowS
show :: Partition -> String
$cshow :: Partition -> String
showsPrec :: Int -> Partition -> ShowS
$cshowsPrec :: Int -> Partition -> ShowS
Prelude.Show, forall x. Rep Partition x -> Partition
forall x. Partition -> Rep Partition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Partition x -> Partition
$cfrom :: forall x. Partition -> Rep Partition x
Prelude.Generic)

-- |
-- Create a value of 'Partition' 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:
--
-- 'catalogId', 'partition_catalogId' - The ID of the Data Catalog in which the partition resides.
--
-- 'creationTime', 'partition_creationTime' - The time at which the partition was created.
--
-- 'databaseName', 'partition_databaseName' - The name of the catalog database in which to create the partition.
--
-- 'lastAccessTime', 'partition_lastAccessTime' - The last time at which the partition was accessed.
--
-- 'lastAnalyzedTime', 'partition_lastAnalyzedTime' - The last time at which column statistics were computed for this
-- partition.
--
-- 'parameters', 'partition_parameters' - These key-value pairs define partition parameters.
--
-- 'storageDescriptor', 'partition_storageDescriptor' - Provides information about the physical location where the partition is
-- stored.
--
-- 'tableName', 'partition_tableName' - The name of the database table in which to create the partition.
--
-- 'values', 'partition_values' - The values of the partition.
newPartition ::
  Partition
newPartition :: Partition
newPartition =
  Partition'
    { $sel:catalogId:Partition' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Partition' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:Partition' :: Maybe Text
databaseName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastAccessTime:Partition' :: Maybe POSIX
lastAccessTime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastAnalyzedTime:Partition' :: Maybe POSIX
lastAnalyzedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:Partition' :: Maybe (HashMap Text Text)
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:storageDescriptor:Partition' :: Maybe StorageDescriptor
storageDescriptor = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:Partition' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing,
      $sel:values:Partition' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Data Catalog in which the partition resides.
partition_catalogId :: Lens.Lens' Partition (Prelude.Maybe Prelude.Text)
partition_catalogId :: Lens' Partition (Maybe Text)
partition_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:Partition' :: Partition -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: Partition
s@Partition' {} Maybe Text
a -> Partition
s {$sel:catalogId:Partition' :: Maybe Text
catalogId = Maybe Text
a} :: Partition)

-- | The time at which the partition was created.
partition_creationTime :: Lens.Lens' Partition (Prelude.Maybe Prelude.UTCTime)
partition_creationTime :: Lens' Partition (Maybe UTCTime)
partition_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Partition' :: Partition -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Partition
s@Partition' {} Maybe POSIX
a -> Partition
s {$sel:creationTime:Partition' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Partition) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the catalog database in which to create the partition.
partition_databaseName :: Lens.Lens' Partition (Prelude.Maybe Prelude.Text)
partition_databaseName :: Lens' Partition (Maybe Text)
partition_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe Text
databaseName :: Maybe Text
$sel:databaseName:Partition' :: Partition -> Maybe Text
databaseName} -> Maybe Text
databaseName) (\s :: Partition
s@Partition' {} Maybe Text
a -> Partition
s {$sel:databaseName:Partition' :: Maybe Text
databaseName = Maybe Text
a} :: Partition)

-- | The last time at which the partition was accessed.
partition_lastAccessTime :: Lens.Lens' Partition (Prelude.Maybe Prelude.UTCTime)
partition_lastAccessTime :: Lens' Partition (Maybe UTCTime)
partition_lastAccessTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe POSIX
lastAccessTime :: Maybe POSIX
$sel:lastAccessTime:Partition' :: Partition -> Maybe POSIX
lastAccessTime} -> Maybe POSIX
lastAccessTime) (\s :: Partition
s@Partition' {} Maybe POSIX
a -> Partition
s {$sel:lastAccessTime:Partition' :: Maybe POSIX
lastAccessTime = Maybe POSIX
a} :: Partition) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The last time at which column statistics were computed for this
-- partition.
partition_lastAnalyzedTime :: Lens.Lens' Partition (Prelude.Maybe Prelude.UTCTime)
partition_lastAnalyzedTime :: Lens' Partition (Maybe UTCTime)
partition_lastAnalyzedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe POSIX
lastAnalyzedTime :: Maybe POSIX
$sel:lastAnalyzedTime:Partition' :: Partition -> Maybe POSIX
lastAnalyzedTime} -> Maybe POSIX
lastAnalyzedTime) (\s :: Partition
s@Partition' {} Maybe POSIX
a -> Partition
s {$sel:lastAnalyzedTime:Partition' :: Maybe POSIX
lastAnalyzedTime = Maybe POSIX
a} :: Partition) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | These key-value pairs define partition parameters.
partition_parameters :: Lens.Lens' Partition (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
partition_parameters :: Lens' Partition (Maybe (HashMap Text Text))
partition_parameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:Partition' :: Partition -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: Partition
s@Partition' {} Maybe (HashMap Text Text)
a -> Partition
s {$sel:parameters:Partition' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: Partition) 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

-- | Provides information about the physical location where the partition is
-- stored.
partition_storageDescriptor :: Lens.Lens' Partition (Prelude.Maybe StorageDescriptor)
partition_storageDescriptor :: Lens' Partition (Maybe StorageDescriptor)
partition_storageDescriptor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe StorageDescriptor
storageDescriptor :: Maybe StorageDescriptor
$sel:storageDescriptor:Partition' :: Partition -> Maybe StorageDescriptor
storageDescriptor} -> Maybe StorageDescriptor
storageDescriptor) (\s :: Partition
s@Partition' {} Maybe StorageDescriptor
a -> Partition
s {$sel:storageDescriptor:Partition' :: Maybe StorageDescriptor
storageDescriptor = Maybe StorageDescriptor
a} :: Partition)

-- | The name of the database table in which to create the partition.
partition_tableName :: Lens.Lens' Partition (Prelude.Maybe Prelude.Text)
partition_tableName :: Lens' Partition (Maybe Text)
partition_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe Text
tableName :: Maybe Text
$sel:tableName:Partition' :: Partition -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: Partition
s@Partition' {} Maybe Text
a -> Partition
s {$sel:tableName:Partition' :: Maybe Text
tableName = Maybe Text
a} :: Partition)

-- | The values of the partition.
partition_values :: Lens.Lens' Partition (Prelude.Maybe [Prelude.Text])
partition_values :: Lens' Partition (Maybe [Text])
partition_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Partition' {Maybe [Text]
values :: Maybe [Text]
$sel:values:Partition' :: Partition -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: Partition
s@Partition' {} Maybe [Text]
a -> Partition
s {$sel:values:Partition' :: Maybe [Text]
values = Maybe [Text]
a} :: Partition) 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

instance Data.FromJSON Partition where
  parseJSON :: Value -> Parser Partition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Partition"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe (HashMap Text Text)
-> Maybe StorageDescriptor
-> Maybe Text
-> Maybe [Text]
-> Partition
Partition'
            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
"CatalogId")
            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
"CreationTime")
            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
"DatabaseName")
            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
"LastAccessTime")
            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
"LastAnalyzedTime")
            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
"Parameters" 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 (Maybe a)
Data..:? Key
"StorageDescriptor")
            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
"TableName")
            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
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Partition where
  hashWithSalt :: Int -> Partition -> Int
hashWithSalt Int
_salt Partition' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe StorageDescriptor
values :: Maybe [Text]
tableName :: Maybe Text
storageDescriptor :: Maybe StorageDescriptor
parameters :: Maybe (HashMap Text Text)
lastAnalyzedTime :: Maybe POSIX
lastAccessTime :: Maybe POSIX
databaseName :: Maybe Text
creationTime :: Maybe POSIX
catalogId :: Maybe Text
$sel:values:Partition' :: Partition -> Maybe [Text]
$sel:tableName:Partition' :: Partition -> Maybe Text
$sel:storageDescriptor:Partition' :: Partition -> Maybe StorageDescriptor
$sel:parameters:Partition' :: Partition -> Maybe (HashMap Text Text)
$sel:lastAnalyzedTime:Partition' :: Partition -> Maybe POSIX
$sel:lastAccessTime:Partition' :: Partition -> Maybe POSIX
$sel:databaseName:Partition' :: Partition -> Maybe Text
$sel:creationTime:Partition' :: Partition -> Maybe POSIX
$sel:catalogId:Partition' :: Partition -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastAccessTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastAnalyzedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StorageDescriptor
storageDescriptor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData Partition where
  rnf :: Partition -> ()
rnf Partition' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe StorageDescriptor
values :: Maybe [Text]
tableName :: Maybe Text
storageDescriptor :: Maybe StorageDescriptor
parameters :: Maybe (HashMap Text Text)
lastAnalyzedTime :: Maybe POSIX
lastAccessTime :: Maybe POSIX
databaseName :: Maybe Text
creationTime :: Maybe POSIX
catalogId :: Maybe Text
$sel:values:Partition' :: Partition -> Maybe [Text]
$sel:tableName:Partition' :: Partition -> Maybe Text
$sel:storageDescriptor:Partition' :: Partition -> Maybe StorageDescriptor
$sel:parameters:Partition' :: Partition -> Maybe (HashMap Text Text)
$sel:lastAnalyzedTime:Partition' :: Partition -> Maybe POSIX
$sel:lastAccessTime:Partition' :: Partition -> Maybe POSIX
$sel:databaseName:Partition' :: Partition -> Maybe Text
$sel:creationTime:Partition' :: Partition -> Maybe POSIX
$sel:catalogId:Partition' :: Partition -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastAccessTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastAnalyzedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StorageDescriptor
storageDescriptor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values