Skip to content

Commit

Permalink
fix(validation) Fail validation error silently instead of crashing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 authored Jul 1, 2022
1 parent bba75b6 commit 38552e0
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const getSchemaAggregationText = (
);
}
default:
throw new Error(`Unsupported schema aggregation assertion ${aggregation} provided.`);
console.error(`Unsupported schema aggregation assertion ${aggregation} provided.`);
return <Typography.Text>Dataset columns are</Typography.Text>;
}
};

Expand All @@ -62,7 +63,8 @@ const getRowsAggregationText = (aggregation: AssertionStdAggregation | undefined
case AssertionStdAggregation.Native:
return <Typography.Text>Dataset rows are</Typography.Text>;
default:
throw new Error(`Unsupported Dataset Rows Aggregation ${aggregation} provided`);
console.error(`Unsupported Dataset Rows Aggregation ${aggregation} provided`);
return <Typography.Text>Dataset rows are</Typography.Text>;
}
};

Expand All @@ -74,88 +76,90 @@ const getColumnAggregationText = (
aggregation: AssertionStdAggregation | undefined | null,
field: SchemaFieldRef | undefined,
) => {
let columnText = field?.path;
if (field === undefined) {
throw new Error(`Invalid field provided for Dataset Assertion with scope Column ${JSON.stringify(field)}`);
columnText = 'undefined';
console.error(`Invalid field provided for Dataset Assertion with scope Column ${JSON.stringify(field)}`);
}
switch (aggregation) {
// Hybrid Aggregations
case AssertionStdAggregation.UniqueCount: {
return (
<Typography.Text>
Unique value count for column <Typography.Text strong>{field.path}</Typography.Text> is
Unique value count for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.UniquePropotion: {
return (
<Typography.Text>
Unique value proportion for column <Typography.Text strong>{field.path}</Typography.Text> is
Unique value proportion for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.NullCount: {
return (
<Typography.Text>
Null count for column <Typography.Text strong>{field.path}</Typography.Text> is
Null count for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.NullProportion: {
return (
<Typography.Text>
Null proportion for column <Typography.Text strong>{field.path}</Typography.Text> is
Null proportion for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
// Numeric Aggregations
case AssertionStdAggregation.Min: {
return (
<Typography.Text>
Minimum value for column <Typography.Text strong>{field.path}</Typography.Text> is
Minimum value for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.Max: {
return (
<Typography.Text>
Maximum value for column <Typography.Text strong>{field.path}</Typography.Text> is
Maximum value for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.Mean: {
return (
<Typography.Text>
Mean value for column <Typography.Text strong>{field.path}</Typography.Text> is
Mean value for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.Median: {
return (
<Typography.Text>
Median value for column <Typography.Text strong>{field.path}</Typography.Text> is
Median value for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
case AssertionStdAggregation.Stddev: {
return (
<Typography.Text>
Standard deviation for column <Typography.Text strong>{field.path}</Typography.Text> is
Standard deviation for column <Typography.Text strong>{columnText}</Typography.Text> is
</Typography.Text>
);
}
// Native Aggregations
case AssertionStdAggregation.Native: {
return (
<Typography.Text>
Column <Typography.Text strong>{field.path}</Typography.Text> values are
Column <Typography.Text strong>{columnText}</Typography.Text> values are
</Typography.Text>
);
}
default:
// No aggregation on the column at hand. Treat the column as a set of values.
return (
<Typography.Text>
Column <Typography.Text strong>{field.path}</Typography.Text> values are
Column <Typography.Text strong>{columnText}</Typography.Text> values are
</Typography.Text>
);
}
Expand All @@ -177,7 +181,8 @@ const getAggregationText = (
case DatasetAssertionScope.DatasetColumn:
return getColumnAggregationText(aggregation, fields?.length === 1 ? fields[0] : undefined);
default:
throw new Error(`Unsupported Dataset Assertion scope ${scope} provided`);
console.error(`Unsupported Dataset Assertion scope ${scope} provided`);
return 'Dataset is';
}
};

Expand Down

0 comments on commit 38552e0

Please sign in to comment.