Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bad data option to create connection form #452

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion arroyo-console/src/gen/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ export interface components {
schemas: {
AvroFormat: {
confluentSchemaRegistry?: boolean;
embeddedSchema?: boolean;
intoUnstructuredJson?: boolean;
rawDatums?: boolean;
readerSchema?: string;
/** Format: int32 */
schemaId?: number | null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwylde looks like we missed this in #422

};
BadData: OneOf<[{
fail: Record<string, never>;
}, {
drop: Record<string, never>;
}]>;
Checkpoint: {
backend: string;
/** Format: int32 */
Expand Down Expand Up @@ -239,6 +246,7 @@ export interface components {
name: string;
};
ConnectionSchema: {
badData?: components["schemas"]["BadData"] | null;
definition?: components["schemas"]["SchemaDefinition"] | null;
fields: (components["schemas"]["SourceField"])[];
format?: components["schemas"]["Format"] | null;
Expand Down Expand Up @@ -363,6 +371,8 @@ export interface components {
confluentSchemaRegistry?: boolean;
debezium?: boolean;
includeSchema?: boolean;
/** Format: int32 */
schemaId?: number | null;
timestampFormat?: components["schemas"]["TimestampFormat"];
unstructured?: boolean;
};
Expand Down
44 changes: 44 additions & 0 deletions arroyo-console/src/routes/connections/DefineSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export const DefineSchema = ({
type DataFormatOption = { name: string; value: string; el?: ReactElement; disabled?: boolean };
const [selectedFormat, setSelectedFormat] = useState<string | undefined>(undefined);
const [selectedFraming, setSelectedFraming] = useState<string | undefined>(undefined);
const [selectedBadData, setSelectedBadData] = useState<string | undefined>(undefined);

let { connectionProfiles, connectionProfilesLoading } = useConnectionProfiles();

Expand Down Expand Up @@ -334,6 +335,16 @@ export const DefineSchema = ({
},
];

type BadDataOption = {
name: string;
value: components['schemas']['BadData'];
};

const badDataOptions: BadDataOption[] = [
{ name: 'Fail', value: { fail: {} } },
{ name: 'Drop', value: { drop: {} } },
];

const onFormatChange = (e: ChangeEvent<DataFormatOption>) => {
let format = String(e.target.value);
setSelectedFormat(format);
Expand Down Expand Up @@ -368,6 +379,18 @@ export const DefineSchema = ({
});
};

const onBadDataChange: ChangeEventHandler<HTMLSelectElement> = e => {
setSelectedBadData(e.target.value);
setState({
...state,
schema: {
...state.schema,
fields: [],
badData: badDataOptions.find(f => f.name == e.target.value)?.value,
},
});
};

return (
<Stack spacing={8}>
<FormControl>
Expand All @@ -385,6 +408,27 @@ export const DefineSchema = ({
</FormHelperText>
</FormControl>

<FormControl>
<FormLabel>Bad Data</FormLabel>
<Select
maxW={'lg'}
placeholder="Select option"
value={selectedBadData}
onChange={onBadDataChange}
>
{badDataOptions.map(o => (
<option key={o.name} value={o.name}>
{o.name}
</option>
))}
</Select>
<FormHelperText maxW={'lg'}>
This option describes how the job should handle data that doesn't match the defined
schema. 'Fail' will cause the job to fail, while 'Drop' will cause the job to drop
(ignore) bad data.
</FormHelperText>
</FormControl>

<FormControl>
<FormLabel>Data format</FormLabel>
<Select
Expand Down