pythonamazon-web-servicesaws-glueaws-cdk

AWS Glue: Cannot define an array of struct with AWS CDK


I'm trying to create a glue table with a column that maps to an array of struct with a defined schema. Using the aws_glue_alpha experimental construct, definition of an array of struct is possible only via this code syntax

glue.Schema.array(
    input_string='struct',
    is_primitive=False,
)

I want to do something like

glue.Schema.array(
  glue.Schema.struct(
       columns=[...]
)    
)

How can I achieve this?

How can you explain these examples work that do exactly what I want?


Solution

  • By inspecting the source code of the npm package, I understood what exactly is that inputString parameter. Essentially, every schema method returns a Type instance which has two properties: inputString & isPrimitive. What I tried (and worked out) is storing a struct definition in a separate variable and pass it to the array method like

    glue.Schema.array(input_string=my_struct.input_string, is_primitive=my_struct.is_primitive