pub struct ODCSImporter { /* private fields */ }Expand description
ODCS parser service for parsing Open Data Contract Standard YAML files. Handles ODCS v3.1.0 (primary format) and legacy ODCL formats (converted to ODCS).
Implementations§
Source§impl ODCSImporter
impl ODCSImporter
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ODCS parser instance.
§Example
use data_modelling_core::import::odcs::ODCSImporter;
let mut importer = ODCSImporter::new();Sourcepub fn import(
&mut self,
yaml_content: &str,
) -> Result<ImportResult, ImportError>
pub fn import( &mut self, yaml_content: &str, ) -> Result<ImportResult, ImportError>
Import ODCS/ODCL YAML content and create Table (SDK interface).
Supports ODCS v3.1.0 (primary), legacy ODCL formats (converted to ODCS), and Liquibase formats.
§Arguments
yaml_content- ODCS/ODCL YAML content as a string
§Returns
An ImportResult containing the extracted table and any parse errors.
§Example
use data_modelling_core::import::odcs::ODCSImporter;
let mut importer = ODCSImporter::new();
let yaml = r#"
apiVersion: v3.1.0
kind: DataContract
id: 550e8400-e29b-41d4-a716-446655440000
version: 1.0.0
name: users
schema:
- name: users
properties:
- name: id
logicalType: bigint
"#;
let result = importer.import(yaml).unwrap();
assert_eq!(result.tables.len(), 1);Sourcepub fn import_contract(
&mut self,
yaml_content: &str,
) -> Result<ODCSContract, ImportError>
pub fn import_contract( &mut self, yaml_content: &str, ) -> Result<ODCSContract, ImportError>
Import ODCS YAML content and return an ODCSContract (new v2 API).
This method returns the native ODCS contract structure, which properly models the ODCS v3.1.0 three-level hierarchy:
- Contract level (apiVersion, domain, etc.)
- Schema level (tables/views with physicalName, businessName, etc.)
- Property level (columns with all metadata)
This API provides lossless round-trip import/export and supports multi-table contracts.
§Arguments
yaml_content- ODCS YAML content as a string
§Returns
An ODCSContract containing the full contract with all schemas and properties.
§Example
use data_modelling_core::import::odcs::ODCSImporter;
let mut importer = ODCSImporter::new();
let yaml = r#"
apiVersion: v3.1.0
kind: DataContract
id: 550e8400-e29b-41d4-a716-446655440000
version: 1.0.0
name: my-contract
domain: retail
schema:
- name: users
physicalName: tbl_users
properties:
- name: id
logicalType: integer
primaryKey: true
- name: email
logicalType: string
required: true
"#;
let contract = importer.import_contract(yaml).unwrap();
assert_eq!(contract.name, "my-contract");
assert_eq!(contract.schema.len(), 1);
assert_eq!(contract.schema[0].name, "users");Sourcepub fn parse_table(
&mut self,
yaml_content: &str,
) -> Result<(Table, Vec<ParserError>)>
pub fn parse_table( &mut self, yaml_content: &str, ) -> Result<(Table, Vec<ParserError>)>
Parse ODCS/ODCL YAML content and create Table (public method for native app use).
This method returns the full Table object with all metadata, suitable for use in
native applications that need direct access to the parsed table structure.
For API use, prefer the import() method which returns ImportResult.
§Returns
Returns a tuple of (Table, list of errors/warnings). Errors list is empty if parsing is successful.
Sourcepub fn parse_struct_type_from_string(
&self,
field_name: &str,
type_str: &str,
field_data: &Map<String, JsonValue>,
) -> Result<Vec<Column>>
pub fn parse_struct_type_from_string( &self, field_name: &str, type_str: &str, field_data: &Map<String, JsonValue>, ) -> Result<Vec<Column>>
Parse STRUCT type definition from string (e.g., “ARRAY<STRUCT<ID: STRING, NAME: STRING>>”). Parse STRUCT type from string and create nested columns This is public so it can be used by SQL importer to parse STRUCT types