shema
Derive macro to generate database schema code from Rust struct
All parameters are specified via shema
Struct parameters
firehose_schema- Enables firehose schema generationfirehose_partition_code- Enables code generation to access partition informationfirehose_parquet_schema- Enables parquet schema generation similar to AWS Glue's one
Field parameters
json- Specifies that field is to be encoded as json object (automatically derived for std's collections)enumeration- Specifies that field is to be encoded as enumeration (Depending on database, it will be encoded as string or object)index- Specifies that field is to be indexed by underlying database engine (e.g. to be declared a partition key in AWS glue schema)firehose_date_index- Specifies field to be used as timestamp withinfirehoseschema which will produceyear,monthanddayfields. Requires to be oftimestamptype. E.g. time::OffsetDateTimerename- Tells to use different name for the field. Argument MUST be string specified asrename = "new_name"
Firehose date index
If specified firehose output will expect RFC3339 encoded string as output during serialization
You should configure HIVE json deserializer with possible RFC3339 formats.
Terraform Reference: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_firehose_delivery_stream#timestamp_formats-1
Schema output
Following constants will be declared for affected structs:
SHEMA_TABLE_NAME- table name in lower caseSHEMA_FIREHOSE_SCHEMA- Firehose glue table schema. If enabled.SHEMA_FIREHOSE_PARQUET_SCHEMA- Partquet schema compatible with firehose data stream. If enabled.
Following methods will be defined for affected structs
firehose_partition_keys_ref- Returns tuple with references to partition keysfirehose_partition_keys- Returns tuple with owned values of partition keysfirehose_s3_path_prefix- Returnsfmt::Displaytype that writes full path prefix for S3 destination object
Firehose specifics
Firehose schema expects flat structure, so any complex struct or array must be serialized as strings
use fs;
use Shema;
//Build context is relative to root of workspace so we point to crate's path
pub
assert_eq!;