# PartitionIndex

Struct · Stable

Properties of a Partition Index.

Used as argument in: [TableBase.addPartitionIndex](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_glue.TableBase.html#addpartitionindex)

- Source: [`aws-glue/lib/table-base.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-glue/lib/table-base.ts#L20)
- Type last changed: v2.270.0 · 17 Sep 2026

## Example

TypeScript:

```ts
declare const myTable: glue.S3Table;
myTable.addPartitionIndex({
  indexName: 'my-index',
  keyNames: ['year'],
});
```

Python:

```python
# my_table: glue.S3Table

my_table.add_partition_index(
    index_name="my-index",
    key_names=["year"]
)
```

Java:

```java
S3Table myTable;

myTable.addPartitionIndex(PartitionIndex.builder()
        .indexName("my-index")
        .keyNames(List.of("year"))
        .build());
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
S3Table myTable;

myTable.AddPartitionIndex(new PartitionIndex {
    IndexName = "my-index",
    KeyNames = new [] { "year" }
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myTable S3Table

myTable.AddPartitionIndex(&PartitionIndex{
	IndexName: jsii.String("my-index"),
	KeyNames: []*string{
		jsii.String("year"),
	},
})
```

## Properties

- `indexName`: string — The name of the partition index.

  **Default:** a name will be generated for you.

- `keyNames`: string[] (required) — The partition key names that comprise the partition index.

  The names must correspond to a name in the
  table's partition keys.
