TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

ETL Schema Validation

MLOps
Hard

Validate warehouse records against an ordered schema. Each schema entry contains column, type ("int", "float", or "str"), and nullable, with optional inclusive min and max bounds. The float schema type accepts Python integers and floats, but Boolean values do not count as integers.

For each column in schema order, check missing values, nullability, type, then range. After a missing value, valid nullable null, or failed type check, skip later checks for that column. Use exact errors "{column}: missing", "{column}: null", "{column}: expected {expected_type}, got {actual_type}", and "{column}: out of range". Return a list of result dictionaries in input order. Each dictionary contains record_index, is_valid, and errors.

Loading visualization...

Examples

Input: records = [{"name": "Alice", "age": 30, "score": 95.5}, {"name": "Bob", "age": 25, "score": 88}], schema = [{"column": "name", "type": "str", "nullable": false}, {"column": "age", "type": "int", "nullable": false, "min": 0, "max": 150}, {"column": "score", "type": "float", "nullable": false, "min": 0, "max": 100}]

Output: [{"record_index": 0, "is_valid": true, "errors": []}, {"record_index": 1, "is_valid": true, "errors": []}]

Explanation: Both records contain every field with accepted types and ranges.

Input: records = [{"name": "Alice", "age": "thirty", "score": 95.5}], schema = [{"column": "name", "type": "str", "nullable": false}, {"column": "age", "type": "int", "nullable": false, "min": 0, "max": 150}, {"column": "score", "type": "float", "nullable": false, "min": 0, "max": 100}]

Output: [{"record_index": 0, "is_valid": false, "errors": ["age: expected int, got str"]}]

Hint 1

Map each schema type name to a predicate using type(value).

Hint 2

Use continue after missing, nullable-null, and wrong-type cases to avoid extra errors.

Requirements

  • Validate columns in schema order
  • Apply presence, null, type, and range checks in that order
  • Produce the exact specified error messages
  • Return one named result dictionary per input record

Constraints

  • Records and schema entries are dictionaries
  • Supported types are int, float, and str
  • Range bounds apply only after a successful numeric type check
Try Similar Problems
Etl DeduplicationEtl Dependency OrchestrationFeature Store LookupMonitoring Metrics SelectionData Drift Detection

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: array

You must run your code first.
PrevNext

ETL Schema Validation

MLOps
Hard

Validate warehouse records against an ordered schema. Each schema entry contains column, type ("int", "float", or "str"), and nullable, with optional inclusive min and max bounds. The float schema type accepts Python integers and floats, but Boolean values do not count as integers.

For each column in schema order, check missing values, nullability, type, then range. After a missing value, valid nullable null, or failed type check, skip later checks for that column. Use exact errors "{column}: missing", "{column}: null", "{column}: expected {expected_type}, got {actual_type}", and "{column}: out of range". Return a list of result dictionaries in input order. Each dictionary contains record_index, is_valid, and errors.

Loading visualization...

Examples

Input: records = [{"name": "Alice", "age": 30, "score": 95.5}, {"name": "Bob", "age": 25, "score": 88}], schema = [{"column": "name", "type": "str", "nullable": false}, {"column": "age", "type": "int", "nullable": false, "min": 0, "max": 150}, {"column": "score", "type": "float", "nullable": false, "min": 0, "max": 100}]

Output: [{"record_index": 0, "is_valid": true, "errors": []}, {"record_index": 1, "is_valid": true, "errors": []}]

Explanation: Both records contain every field with accepted types and ranges.

Input: records = [{"name": "Alice", "age": "thirty", "score": 95.5}], schema = [{"column": "name", "type": "str", "nullable": false}, {"column": "age", "type": "int", "nullable": false, "min": 0, "max": 150}, {"column": "score", "type": "float", "nullable": false, "min": 0, "max": 100}]

Output: [{"record_index": 0, "is_valid": false, "errors": ["age: expected int, got str"]}]

Hint 1

Map each schema type name to a predicate using type(value).

Hint 2

Use continue after missing, nullable-null, and wrong-type cases to avoid extra errors.

Requirements

  • Validate columns in schema order
  • Apply presence, null, type, and range checks in that order
  • Produce the exact specified error messages
  • Return one named result dictionary per input record

Constraints

  • Records and schema entries are dictionaries
  • Supported types are int, float, and str
  • Range bounds apply only after a successful numeric type check
Try Similar Problems
Etl DeduplicationEtl Dependency OrchestrationFeature Store LookupMonitoring Metrics SelectionData Drift Detection

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: array

You must run your code first.