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

Adds warnings to jobmapping validator #3155

Merged
merged 14 commits into from
Jan 17, 2025

Conversation

alishakawaguchi
Copy link
Contributor

@alishakawaguchi alishakawaguchi commented Jan 16, 2025

Screenshot 2025-01-16 at 2 55 08 PM

@alishakawaguchi alishakawaguchi added the enhancement New feature or request label Jan 16, 2025
@alishakawaguchi alishakawaguchi self-assigned this Jan 16, 2025
Copy link

linear bot commented Jan 16, 2025

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
neosync-docs ⬜️ Ignored (Inspect) Visit Preview Jan 17, 2025 6:35pm

Copy link

github-actions bot commented Jan 16, 2025

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 17, 2025, 6:37 PM

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 65.14745% with 130 lines in your changes missing coverage. Please review.

Project coverage is 30.25%. Comparing base (8d05584) to head (6b82401).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/job/job.go 0.00% 98 Missing ⚠️
backend/services/mgmt/v1alpha1/job-service/jobs.go 0.00% 23 Missing ⚠️
internal/job/jobmapping-validator.go 96.81% 5 Missing and 3 partials ⚠️
internal/benthos/benthos-builder/builders/sql.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3155      +/-   ##
==========================================
+ Coverage   29.70%   30.25%   +0.54%     
==========================================
  Files         372      374       +2     
  Lines       42926    42960      +34     
==========================================
+ Hits        12753    12996     +243     
+ Misses      28671    28459     -212     
- Partials     1502     1505       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nickzelei nickzelei left a comment

Choose a reason for hiding this comment

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

nice..left a few comments

@@ -26,3 +27,27 @@ func DedupeSliceOrdered[T comparable](input []T) []T {
}
return output
}

func DedupeSlice[T comparable](input []T) []T {
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I think we can actualy remove this function entirely and just use slices.Compact

return output
}

func CompareSlices(slice1, slice2 []string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this and use slices.Compare

backend/protos/mgmt/v1alpha1/job.proto Show resolved Hide resolved
Comment on lines 1089 to 1094
message ColumnWarning {
string schema = 1;
string table = 2;
string column = 3;
repeated string warnings = 5;
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add property descriptions (see ColumnError)

backend/protos/mgmt/v1alpha1/job.proto Show resolved Hide resolved
@@ -1765,6 +1766,7 @@ export async function validateJobMapping(
});
}),
connectionId: connectionId,
jobSource: jobSource,
Copy link
Member

Choose a reason for hiding this comment

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

how is the job source different from the connectionId? aren't they the same thing? Could connectionid go away in favor of just the job source?

Copy link
Member

Choose a reason for hiding this comment

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

I still have this question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep the validate job mapping endpoint flexible. It doesn't require the jobsource. If you just want to validate the mappings then all you need is mappings and connection_id. Like you could call it with the mappings and destination id and it will tell you all the missing tables

Copy link
Member

Choose a reason for hiding this comment

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

sounds good

@@ -109,6 +128,9 @@ export default function FormErrorsCard(props: Props): ReactElement {
function formErrorsToMessages(errors: FormError[]): string[] {
Copy link
Member

Choose a reason for hiding this comment

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

I'm very performance sensitive about things changing on the schema table page.
There are potentially a lot of form errors that can occur on this page...

It might be more efficient here to have a formErrorsToMessages function return an object that splits them.

interface FormErrorMesageResponse {
  errors: string[];
  warnings: string[];
}

Then loop through them and check the level.
That way you reduce the algorithm from O(2N) to just O(N)

Comment on lines 435 to 445
const values = form.getValues();
const connection = connections.find((c) => c.id === values.sourceId);
const job = data?.job;
try {
setIsValidatingMappings(true);
let jobsource: JobSource | undefined;
if (job && connection) {
jobsource = create(JobSourceSchema, {
options: toJobSourceOptions(values, job, connection, values.sourceId),
});
}
Copy link
Member

Choose a reason for hiding this comment

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

seems liek this logic is pretty similar to what is above in the validateMappings function, but it's not using the same conditional logic. ... should it be? they look pretty darn similar.

@@ -208,7 +207,7 @@ func (j *JobMappingsValidator) ValidateCircularDependencies(
}

for table, deps := range validForeignKeyDependencies {
validForeignKeyDependencies[table] = utils.DedupeSlice(deps)
validForeignKeyDependencies[table] = slices.Compact(deps)
Copy link
Member

Choose a reason for hiding this comment

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

heck yeah

Copy link
Member

@nickzelei nickzelei left a comment

Choose a reason for hiding this comment

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

lgtm, just the last question around needing the connection id if we also have the job source (maybe that thing doesnt have the conn id?)

@alishakawaguchi alishakawaguchi merged commit 8b6ea3e into main Jan 17, 2025
21 checks passed
@alishakawaguchi alishakawaguchi deleted the alisha/neos-1716-mapping-validator branch January 17, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants