Skip to content

Commit

Permalink
Add bad data option to create connection form
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeisen committed Dec 14, 2023
1 parent 1aa80a2 commit af12090
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
9 changes: 8 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,14 @@ export interface components {
schemas: {
AvroFormat: {
confluentSchemaRegistry?: boolean;
embeddedSchema?: boolean;
intoUnstructuredJson?: boolean;
rawDatums?: boolean;
readerSchema?: string;
/** Format: int32 */
schemaId?: number | null;
};
/** @enum {string} */
BadData: "drop" | "fail";
Checkpoint: {
backend: string;
/** Format: int32 */
Expand Down Expand Up @@ -239,6 +243,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 +368,8 @@ export interface components {
confluentSchemaRegistry?: boolean;
debezium?: boolean;
includeSchema?: boolean;
/** Format: int32 */
schemaId?: number | null;
timestampFormat?: components["schemas"]["TimestampFormat"];
unstructured?: boolean;
};
Expand Down
39 changes: 39 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,22 @@ 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.value} value={o.name}>
{o.name}
</option>
))}
</Select>
</FormControl>

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

0 comments on commit af12090

Please sign in to comment.