# SPDREGIONCONSTRAINT

> SPDREGIONCONSTRAINT contains details on region demand constraint factors used in dispatch. SPDREGIONCONSTRAINTsets a LHS value.

> SPDREGIONCONSTRAINT is public data, and is available to all
> participants.
> 
> Source
> 
> SPDREGIONCONSTRAINT is updated whenever AEMO creates new regional
> constraints.

## Column Schema

### BIDTYPE

> AS Service type - relates to the BidType table; one of (RAISE6SEC, RAISE60SEC, RAISE5MIN, LOWER6SEC, LOWER60SEC, LOWER5MIN, RAISEREG, LOWERREG)

The SQL type is `VARCHAR2(10)`.
This is actually a factor/enum, with values:

- `ENERGY`

- `LOWERREG`

- `LOWER60SEC`

- `RAISE5MIN`

- `LOWER5MIN`

- `LOWER6SEC`

- `RAISE60SEC`

- `RAISE6SEC`

- `RAISEREG`

- `RAISE1SEC`

- `LOWER1SEC`

This column is mandatory, and a primary key.

### EFFECTIVEDATE

> Effective date of this record

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is mandatory, and a primary key.

Example: `2026/09/02 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### GENCONID

> Generic Constraint Identifier

SQL Type: `VARCHAR2(20)`
Polars Type: `pl.Categorical`

This column is mandatory, and a primary key.

Examples:

- `#R036725_001_RAMP_F`
- `#R036725_001_RAMP_V`
- `#R036725_002_RAMP_F`
- `#R036725_002_RAMP_V`
- `#R036725_003_RAMP_F`
- `#R036725_003_RAMP_V`
- `#R036725_004_RAMP_F`
- `#R036725_004_RAMP_V`
- `#R036725_005_RAMP_F`
- `#R036725_005_RAMP_V`

### REGIONID

> Region Identifier

For more information, see the [dedicated documentation page](../../guide/querying.md#region-id).

The SQL type is `VARCHAR2(10)`.
This is actually a factor/enum, with values:

- `QLD1`

- `VIC1`

- `TAS1`

- `NSW1`

- `SA1`

- `SNOWY1`

This column is mandatory, and a primary key.

### VERSIONNO

> Version no of this record for the effective date

SQL Type: `NUMBER(3,0)`
Polars Type: `pl.UInt16`

This column is mandatory, and a primary key.

Example: `1`

### FACTOR

> Constraint factor; one of (-1, 1)

SQL Type: `NUMBER(16,6)`
Polars Type: `pl.Float64`

This column is not mandatory.

Example: `1`

### LASTCHANGED

> Last date and time record changed

For more information, see the [dedicated documentation page](../../guide/querying.md#deduplication).

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2026/09/02 02:06:53`

## New Data Timing

> When AEMO creates new regional constraints

## Code Examples

### Polars

Explicitly listing every column, casting to enums, categoricals etc is not essential, but may speed up parsing.
Swapping `int` for `pl.UInt16`, `pl.Int32` would also speed up parsing. However some of the datatypes are inferred, so they may be wrong.

This code deduplicates for you.
Deduplication is normally only required across multiple months.

This code assumes that all columns are present, which may not be true for older files.

```python
import polars as pl
import polars.selectors as cs

# e.g. "2029/03/15 00:05:00"
dt_s_fmt = "%Y/%m/%d %H:%M:%S"

# Dates are represented as datetimes at midnight

d_fmt = "%Y/%m/%d 00:00:00"

csv_paths = ["SOMEFILE.CSV", "OTHERFILE.CSV"]

lf = (
    pl.concat(
        [
            pl.scan_csv(
                csv_path,  # must be unzipped beforehand
                skip_rows=1,  # skip the header
                infer_schema=False,  # much faster
            )
            .filter(cs.by_index(0) == "D")  # drop the footer
            .select(~cs.by_index(range(4)))  # drop metadata columns
            for csv_path in csv_paths
        ],
        how="diagonal_relaxed",
    )
    .with_columns(
        pl.col("LASTCHANGED").str.strptime(pl.Datetime, dt_s_fmt),
        pl.col("EFFECTIVEDATE").str.strptime(pl.Date, d_fmt),
    )
    .cast(
        {
            "BIDTYPE": pl.Enum(
                [
                    "ENERGY",
                    "LOWERREG",
                    "LOWER60SEC",
                    "RAISE5MIN",
                    "LOWER5MIN",
                    "LOWER6SEC",
                    "RAISE60SEC",
                    "RAISE6SEC",
                    "RAISEREG",
                    "RAISE1SEC",
                    "LOWER1SEC",
                ]
            ),
            "EFFECTIVEDATE": pl.Date(),
            "GENCONID": pl.Categorical,
            "REGIONID": pl.Enum(["QLD1", "VIC1", "TAS1", "NSW1", "SA1", "SNOWY1"]),
            "VERSIONNO": int,  # or pl.UInt16
            "FACTOR": pl.Float64,
        }
    )
    # Deduplicate
    # We want one row per ['BIDTYPE', 'EFFECTIVEDATE', 'GENCONID', 'REGIONID', 'VERSIONNO']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(
        subset=["BIDTYPE", "EFFECTIVEDATE", "GENCONID", "REGIONID", "VERSIONNO"],
        keep="last",
    )
)

```

### Nemosis

```py
from nemosis import dynamic_data_compiler

df = dynamic_data_compiler(
    '2024/01/01 00:00:00',
    '2024/01/31 00:00:00',
    "SPDREGIONCONSTRAINT",
    "data/"
)
```

## Example File

From [PUBLIC_ARCHIVE_SPDREGIONCONSTRAINT_FILE01_202609010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2026/MMSDM_2026_09/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_ARCHIVE%23SPDREGIONCONSTRAINT%23FILE01%23202609010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_SPDREGIONCONSTRAINT,AEMO,PUBLIC,2026/10/09,16:34:07,001791527647079,MONTHLY_ARCHIVE,001791527647079
    I,SPDRC,NULL,2,REGIONID,EFFECTIVEDATE,VERSIONNO,GENCONID,FACTOR,LASTCHANGED,BIDTYPE
    D,SPDRC,NULL,2,NSW1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWER5MIN
    D,SPDRC,NULL,2,NSW1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWERREG
    D,SPDRC,NULL,2,QLD1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWER5MIN
    D,SPDRC,NULL,2,QLD1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWERREG
    D,SPDRC,NULL,2,SA1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWER5MIN
    D,SPDRC,NULL,2,SA1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWERREG
    D,SPDRC,NULL,2,VIC1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWER5MIN
    D,SPDRC,NULL,2,VIC1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_V,1,"2026/09/02 02:06:53",LOWERREG
    D,SPDRC,NULL,2,NSW1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_F,1,"2026/09/02 02:06:53",LOWER5MIN
    D,SPDRC,NULL,2,NSW1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_F,1,"2026/09/02 02:06:53",LOWERREG
    D,SPDRC,NULL,2,QLD1,"2026/09/02 00:00:00",1,#R036725_004_RAMP_F,1,"2026/09/02 02:06:53",LOWER5MIN
    ...
    C,"END OF REPORT",117
    ```

## Availability

Visibility: Public

This table is in the public monthly [MMSDM archive](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/).

I have collated the list of all those files into one place, in [this CSV metadata file](../../manifests/per_table/csv/SPDREGIONCONSTRAINT.csv). (Columns `year`, `month`, `url`, `compressed_size` in bytes).

The earliest available data is month 1 of 2015.
The most recent available data is month 9 of 2026.

!!! warning Warning
    There are some months with no files.

## Data Size

Each year of data is approximately
12 KB when zipped,
116 KB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`BIDTYPE`](#bidtype)

- [`EFFECTIVEDATE`](#effectivedate)

- [`GENCONID`](#genconid)

- [`REGIONID`](#regionid)

- [`VERSIONNO`](#versionno)

The transaction type is ["insert"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#INSERT), which means that you will usually not see duplicate data.
If you do, you can deduplicate based on the primary keys, without sorting first.
Rows from different files with the same primary keys should have the same values.

[PDR Loader configuration](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip) is:

| Report Name | Report Subtype | Version |
|---------------|-------------------|-----------|
| SPDRC | NULL  | 2 |

This means that the CSV files start with metadata columns:

```csv
I,SPDRC,NULL,2,...
D,SPDRC,NULL,2,...
```

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

[This page as JSON](../json/tables/SPDREGIONCONSTRAINT/bespoke.json) (schema documented [here](https://gitlab.com/MatthewDavis/mms-schema/-/blob/master/schema.py?ref_type=heads), but may change)

Download a [JSON Schema](../json/tables/SPDREGIONCONSTRAINT/json-schema.json) specification for this table.

[Official AEMO schema documentation](https://nemweb.com.au/Reports/Current/MMSDataModelReport/Electricity/ElectricityDataModelReport_files/Elec29.htm#96)

## Other Information

Package: [GENERIC_CONSTRAINT](../packages/GENERIC_CONSTRAINT.md)
