Skip to content
v2.273.0

Schema Class ​

Example ​

ts
declare const myDatabase: glue.Database;
new glue.S3Table(this, 'MyTable', {
  database: myDatabase,
  columns: [{
    name: 'data',
    type: glue.Schema.STRING,
  }],
  partitionKeys: [{
    name: 'date',
    type: glue.Schema.STRING,
  }],
  dataFormat: glue.DataFormat.JSON,
  partitionProjection: {
    date: glue.PartitionProjectionConfiguration.date({
      min: 'NOW-3YEARS',
      max: 'NOW',
      format: 'yyyy-MM-dd',
    }),
  },
});
python
# my_database: glue.Database

glue.S3Table(self, "MyTable",
    database=my_database,
    columns=[glue.Column(
        name="data",
        type=glue.Schema.STRING
    )],
    partition_keys=[glue.Column(
        name="date",
        type=glue.Schema.STRING
    )],
    data_format=glue.DataFormat.JSON,
    partition_projection={
        "date": glue.PartitionProjectionConfiguration.date(
            min="NOW-3YEARS",
            max="NOW",
            format="yyyy-MM-dd"
        )
    }
)
java
Database myDatabase;

S3Table.Builder.create(this, "MyTable")
        .database(myDatabase)
        .columns(List.of(Column.builder()
                .name("data")
                .type(Schema.STRING)
                .build()))
        .partitionKeys(List.of(Column.builder()
                .name("date")
                .type(Schema.STRING)
                .build()))
        .dataFormat(DataFormat.JSON)
        .partitionProjection(Map.of(
                "date", PartitionProjectionConfiguration.date(DatePartitionProjectionConfigurationProps.builder()
                        .min("NOW-3YEARS")
                        .max("NOW")
                        .format("yyyy-MM-dd")
                        .build())))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Glue.Alpha
Database myDatabase;

new S3Table(this, "MyTable", new S3TableProps {
    Database = myDatabase,
    Columns = new [] { new Column {
        Name = "data",
        Type = Schema.STRING
    } },
    PartitionKeys = new [] { new Column {
        Name = "date",
        Type = Schema.STRING
    } },
    DataFormat = DataFormat.JSON,
    PartitionProjection = new Dictionary<string, PartitionProjectionConfiguration> {
        { "date", PartitionProjectionConfiguration.Date(new DatePartitionProjectionConfigurationProps {
            Min = "NOW-3YEARS",
            Max = "NOW",
            Format = "yyyy-MM-dd"
        }) }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkgluealpha/v2
var myDatabase Database

glue.NewS3Table(this, jsii.String("MyTable"), &S3TableProps{
	Database: myDatabase,
	Columns: []Column{
		&Column{
			Name: jsii.String("data"),
			Type: glue.Schema_STRING(),
		},
	},
	PartitionKeys: []Column{
		&Column{
			Name: jsii.String("date"),
			Type: glue.Schema_STRING(),
		},
	},
	DataFormat: glue.DataFormat_JSON(),
	PartitionProjection: map[string]PartitionProjectionConfiguration{
		"date": glue.PartitionProjectionConfiguration_date(&DatePartitionProjectionConfigurationProps{
			"min": jsii.String("NOW-3YEARS"),
			"max": jsii.String("NOW"),
			"format": jsii.String("yyyy-MM-dd"),
		}),
	},
})

Initializer ​

ts
new Schema()
python
Schema()
java
new Schema()
csharp
new Schema()
go
NewSchema()

Properties ​

BIG_INTTypebig_intTypeBIG_INTTypeBIG_INTTypeBIG_INTTyperequiredstatic#
A 64-bit signed INTEGER in two’s complement format, with a minimum value of -2^63 and a maximum value of 2^63-1.
BINARYTypebinaryTypeBINARYTypeBINARYTypeBINARYTyperequiredstatic#
BOOLEANTypebooleanTypeBOOLEANTypeBOOLEANTypeBOOLEANTyperequiredstatic#
DATETypedateTypeDATETypeDATETypeDATETyperequiredstatic#
Date type.
DOUBLETypedoubleTypeDOUBLETypeDOUBLETypeDOUBLETyperequiredstatic#
FLOATTypefloatTypeFLOATTypeFLOATTypeFLOATTyperequiredstatic#
INTEGERTypeintegerTypeINTEGERTypeINTEGERTypeINTEGERTyperequiredstatic#
A 32-bit signed INTEGER in two’s complement format, with a minimum value of -2^31 and a maximum value of 2^31-1.
SMALL_INTTypesmall_intTypeSMALL_INTTypeSMALL_INTTypeSMALL_INTTyperequiredstatic#
A 16-bit signed INTEGER in two’s complement format, with a minimum value of -2^15 and a maximum value of 2^15-1.
STRINGTypestringTypeSTRINGTypeSTRINGTypeSTRINGTyperequiredstatic#
Arbitrary-length string type.
TIMESTAMPTypetimestampTypeTIMESTAMPTypeTIMESTAMPTypeTIMESTAMPTyperequiredstatic#
Timestamp type (date and time).
TINY_INTTypetiny_intTypeTINY_INTTypeTINY_INTTypeTINY_INTTyperequiredstatic#
A 8-bit signed INTEGER in two’s complement format, with a minimum value of -2^7 and a maximum value of 2^7-1.

Methods ​

array(itemType: Type): Type@staticmethod def array(item_type: Type) -> Typepublic static Type array(Type itemType)public static Type Array(Type itemType)func Array(ItemType Type) Typestatic#
Creates an array of some other type.
1 parameter

Parameters

  • itemTypeitem_typeitemTypeitemTypeItemType — type contained by the array.
char(length: number): Type@staticmethod def char(length: int | float) -> Typepublic static Type char(Number length)public static Type Char(double length)func Char(Length *float64) Typestatic#
Fixed length character data, with a specified length between 1 and 255.
1 parameter

Parameters

  • lengthlengthlengthlengthLength — length between 1 and 255.
custom(inputString: string, isPrimitive?: boolean): Type@staticmethod def custom(input_string: str, is_primitive: typing.Optional[bool] = None) -> Typepublic static Type custom(String inputString, Boolean isPrimitive)public static Type Custom(string inputString, bool? isPrimitive = null)func Custom(InputString *string, IsPrimitive *bool) Typestatic#
Creates a custom type from a raw Glue input string.

Escape hatch for column types the other Schema factories don't model. The inputString is emitted verbatim and is not validated.

2 parameters

Parameters

  • inputStringinput_stringinputStringinputStringInputString — the Glue input string for the type (for example interval_day_to_second).
  • isPrimitiveis_primitiveisPrimitiveisPrimitiveIsPrimitive — whether the type is a primitive (non-nested) data type.
decimal(precision: number, scale?: number): Type@staticmethod def decimal(precision: int | float, scale: typing.Optional[int | float] = None) -> Typepublic static Type decimal(Number precision, Number scale)public static Type Decimal(double precision, double? scale = null)func Decimal(Precision *float64, Scale *float64) Typestatic#
Creates a decimal type.
2 parameters

Parameters

  • precisionprecisionprecisionprecisionPrecision — the total number of digits, between 1 and 38.
  • scalescalescalescaleScale — the number of digits in the fractional part, between 0 and 38;
map(keyType: Type, valueType: Type): Type@staticmethod def map(key_type: Type, value_type: Type) -> Typepublic static Type map(Type keyType, Type valueType)public static Type Map(Type keyType, Type valueType)func Map(KeyType Type, ValueType Type) Typestatic#
Creates a map of some primitive key type to some value type.
2 parameters

Parameters

  • keyTypekey_typekeyTypekeyTypeKeyType — type of key, must be a primitive.
  • valueTypevalue_typevalueTypevalueTypeValueType — type fo the value indexed by the key.
struct(columns: Column[]): Type@staticmethod def struct(columns: typing.List[Column]) -> Typepublic static Type struct(List<Column> columns)public static Type Struct(Column[] columns)func Struct(Columns *[]Column) Typestatic#
Creates a nested structure containing individually named and typed columns.
1 parameter

Parameters

  • columnscolumnscolumnscolumnsColumns — the columns of the structure.
varchar(length: number): Type@staticmethod def varchar(length: int | float) -> Typepublic static Type varchar(Number length)public static Type Varchar(double length)func Varchar(Length *float64) Typestatic#
Variable length character data, with a specified length between 1 and 65535.
1 parameter

Parameters

  • lengthlengthlengthlengthLength — length between 1 and 65535.