Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixing key-value after adding version
  • Loading branch information
gabe-lyons committed Aug 13, 2021
commit 7f94a98dd526c3c130f1ee9fbc1540654ef8cf08
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import translateFieldPath from '../schema/utils/translateFieldPath';
import translateFieldPath from '../../schema/utils/translateFieldPath';

describe('translateFieldPath', () => {
it('translates qualified unions', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import translateFieldPathSegment from '../schema/utils/translateFieldPathSegment';
import translateFieldPathSegment from '../../schema/utils/translateFieldPathSegment';

describe('translateFieldPathSegment', () => {
it('translates unions', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { SchemaFieldDataType } from '../../../../../../types.generated';
import { filterKeyFieldPath } from '../../schema/utils/utils';

describe('utils', () => {
describe('filterKeyFieldPath', () => {
it('allows keys when looking for keys', () => {
expect(
filterKeyFieldPath(true, {
fieldPath: '[version=2.0].[key=True].[type=long].field',
nullable: false,
type: SchemaFieldDataType.Number,
recursive: false,
}),
).toEqual(true);
});
it('blocks non-keys when looking for keys', () => {
expect(
filterKeyFieldPath(true, {
fieldPath: '[version=2.0].[type=long].field',
nullable: false,
type: SchemaFieldDataType.Number,
recursive: false,
}),
).toEqual(false);
});

it('allows non-keys when looking for non-keys', () => {
expect(
filterKeyFieldPath(false, {
fieldPath: '[version=2.0].[type=long].field',
nullable: false,
type: SchemaFieldDataType.Number,
recursive: false,
}),
).toEqual(true);
});

it('blocks keys when looking for non-keys', () => {
expect(
filterKeyFieldPath(false, {
fieldPath: '[version=2.0].[key=True].[type=long].field',
nullable: false,
type: SchemaFieldDataType.Number,
recursive: false,
}),
).toEqual(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function SchemaView({
});

const hasKeySchema = useMemo(
() => (schema?.fields?.findIndex((field) => field.fieldPath.startsWith(KEY_SCHEMA_PREFIX)) || -1) !== -1,
() => (schema?.fields?.findIndex((field) => field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1) || -1) !== -1,
[schema],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function convertEditableSchemaMetadataForUpdate(
}

export function filterKeyFieldPath(showKeySchema: boolean, field: SchemaField) {
return field.fieldPath.startsWith(KEY_SCHEMA_PREFIX) ? showKeySchema : !showKeySchema;
return field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1 ? showKeySchema : !showKeySchema;
}

export function downgradeV2FieldPath(fieldPath?: string | null) {
Expand Down
19 changes: 17 additions & 2 deletions metadata-ingestion/examples/mce_files/bootstrap_mce.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
},
"fields": [
{
"fieldPath": "field_foo_2",
"fieldPath": "[version=2.0].[type=boolean].field_foo_2",
"jsonPath": null,
"nullable": false,
"description": {
Expand All @@ -224,7 +224,7 @@
"recursive": false
},
{
"fieldPath": "field_bar",
"fieldPath": "[version=2.0].[type=boolean].field_bar",
"jsonPath": null,
"nullable": false,
"description": {
Expand All @@ -237,6 +237,21 @@
},
"nativeDataType": "boolean",
"recursive": false
},
{
"fieldPath": "[version=2.0].[key=True].[type=int].id",
"jsonPath": null,
"nullable": false,
"description": {
"string": "Id specifying which partition the message should go to"
},
"type": {
"type": {
"com.linkedin.pegasus2avro.schema.BooleanType": {}
}
},
"nativeDataType": "boolean",
"recursive": false
}
],
"primaryKeys": null,
Expand Down