Skip to content

Commit

Permalink
add table errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alishakawaguchi committed Jan 23, 2025
1 parent cbc4604 commit 9e3bc93
Show file tree
Hide file tree
Showing 13 changed files with 1,984 additions and 1,379 deletions.
2,456 changes: 1,329 additions & 1,127 deletions backend/gen/go/protos/mgmt/v1alpha1/job.pb.go

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions backend/gen/go/protos/mgmt/v1alpha1/job.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 37 additions & 12 deletions backend/protos/mgmt/v1alpha1/job.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1195,26 +1195,49 @@ message DatabaseError {
enum DatabaseErrorCode {
// Default unspecified value
DATABASE_ERROR_CODE_UNSPECIFIED = 0;
// Table not found in source database
DATABASE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE = 1;
// Unsupported circular dependency detected
DATABASE_ERROR_CODE_UNSUPPORTED_CIRCULAR_DEPENDENCY_AT_LEAST_ONE_NULLABLE = 2;
DATABASE_ERROR_CODE_UNSUPPORTED_CIRCULAR_DEPENDENCY_AT_LEAST_ONE_NULLABLE = 1;
// Virtual foreign key column mismatch
DATABASE_ERROR_CODE_VFK_COLUMN_MISMATCH = 2;
}

// Database error report
message DatabaseErrorReport {
// The error code
DatabaseErrorCode code = 1;
// The error message
string message = 2;
}
}

message TableError {
// The schema of the table
string schema = 1;
// The table of the error
string table = 2;
// The list of error reports
repeated TableErrorReport error_reports = 3;

// An enumeration of table error codes
enum TableErrorCode {
// Default unspecified value
TABLE_ERROR_CODE_UNSPECIFIED = 0;
// Table not found in source database
TABLE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE = 1;
// Virtual foreign key source table not found in mapping
DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING = 3;
TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING = 2;
// Virtual foreign key source table not found in source
DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE = 4;
TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE = 3;
// Virtual foreign key target table not found in mapping
DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING = 5;
TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING = 4;
// Virtual foreign key target table not found in source
DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE = 6;
// Virtual foreign key column mismatch
DATABASE_ERROR_CODE_VFK_COLUMN_MISMATCH = 7;
TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE = 5;
}

// Database error report
message DatabaseErrorReport {
message TableErrorReport {
// The error code
DatabaseErrorCode code = 1;
TableErrorCode code = 1;
// The error message
string message = 2;
}
Expand All @@ -1223,10 +1246,12 @@ message DatabaseError {
message ValidateJobMappingsResponse {
// The list of column errors
repeated ColumnError column_errors = 1;
// The database error
// The list of database errors
DatabaseError database_errors = 2;
// The list of column warnings
repeated ColumnWarning column_warnings = 3;
// The list of table errors
repeated TableError table_errors = 4;
}

message VirtualForeignKey {
Expand Down
11 changes: 11 additions & 0 deletions backend/services/mgmt/v1alpha1/job-service/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,16 @@ func (s *Service) ValidateJobMappings(
ErrorReports: dbErrReports,
}

tableErrors := []*mgmtv1alpha1.TableError{}
for tableName, errs := range result.TableErrors {
schema, table := sqlmanager_shared.SplitTableKey(tableName)
tableErrors = append(tableErrors, &mgmtv1alpha1.TableError{
Schema: schema,
Table: table,
ErrorReports: errs,
})
}

colErrors := []*mgmtv1alpha1.ColumnError{}
for tableName, colMap := range result.ColumnErrors {
for col, errors := range colMap {
Expand Down Expand Up @@ -1605,6 +1615,7 @@ func (s *Service) ValidateJobMappings(

return connect.NewResponse(&mgmtv1alpha1.ValidateJobMappingsResponse{
DatabaseErrors: dbErrors,
TableErrors: tableErrors,
ColumnErrors: colErrors,
ColumnWarnings: colWarnings,
}), nil
Expand Down
58 changes: 52 additions & 6 deletions docs/openapi/mgmt/v1alpha1/job.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ components:
title: DatabaseErrorCode
enum:
- DATABASE_ERROR_CODE_UNSPECIFIED
- DATABASE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE
- DATABASE_ERROR_CODE_UNSUPPORTED_CIRCULAR_DEPENDENCY_AT_LEAST_ONE_NULLABLE
- DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING
- DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE
- DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING
- DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE
- DATABASE_ERROR_CODE_VFK_COLUMN_MISMATCH
description: An enumeration of database error codes
mgmt.v1alpha1.GenerateEmailType:
Expand Down Expand Up @@ -167,6 +162,17 @@ components:
- HASH_TYPE_MD5
- HASH_TYPE_SHA256
- HASH_TYPE_SHA512
mgmt.v1alpha1.TableError.TableErrorCode:
type: string
title: TableErrorCode
enum:
- TABLE_ERROR_CODE_UNSPECIFIED
- TABLE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE
- TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING
- TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE
- TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING
- TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE
description: An enumeration of table error codes
google.protobuf.Timestamp:
type: string
format: date-time
Expand Down Expand Up @@ -4141,6 +4147,40 @@ components:
type: object
title: SetRunContextsResponse
additionalProperties: false
mgmt.v1alpha1.TableError:
type: object
properties:
schema:
type: string
title: schema
description: The schema of the table
table:
type: string
title: table
description: The table of the error
errorReports:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.TableError.TableErrorReport'
title: error_reports
description: The list of error reports
title: TableError
additionalProperties: false
mgmt.v1alpha1.TableError.TableErrorReport:
type: object
properties:
code:
allOf:
- $ref: '#/components/schemas/mgmt.v1alpha1.TableError.TableErrorCode'
title: code
description: The error code
message:
type: string
title: message
description: The error message
title: TableErrorReport
additionalProperties: false
description: Database error report
mgmt.v1alpha1.TerminateJobRunRequest:
type: object
properties:
Expand Down Expand Up @@ -5373,13 +5413,19 @@ components:
allOf:
- $ref: '#/components/schemas/mgmt.v1alpha1.DatabaseError'
title: database_errors
description: The database error
description: The list of database errors
columnWarnings:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.ColumnWarning'
title: column_warnings
description: The list of column warnings
tableErrors:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.TableError'
title: table_errors
description: The list of table errors
title: ValidateJobMappingsResponse
additionalProperties: false
mgmt.v1alpha1.VirtualForeignConstraint:
Expand Down
58 changes: 52 additions & 6 deletions docs/openapi/neosync.mgmt.v1alpha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8964,13 +8964,8 @@ components:
title: DatabaseErrorCode
enum:
- DATABASE_ERROR_CODE_UNSPECIFIED
- DATABASE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE
- >-
DATABASE_ERROR_CODE_UNSUPPORTED_CIRCULAR_DEPENDENCY_AT_LEAST_ONE_NULLABLE
- DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING
- DATABASE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE
- DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING
- DATABASE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE
- DATABASE_ERROR_CODE_VFK_COLUMN_MISMATCH
description: An enumeration of database error codes
mgmt.v1alpha1.GetActiveJobHooksByTimingRequest.Timing:
Expand Down Expand Up @@ -9019,6 +9014,17 @@ components:
- LOG_WINDOW_FIFTEEN_MIN
- LOG_WINDOW_ONE_HOUR
- LOG_WINDOW_ONE_DAY
mgmt.v1alpha1.TableError.TableErrorCode:
type: string
title: TableErrorCode
enum:
- TABLE_ERROR_CODE_UNSPECIFIED
- TABLE_ERROR_CODE_TABLE_NOT_FOUND_IN_SOURCE
- TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_MAPPING
- TABLE_ERROR_CODE_VFK_SOURCE_TABLE_NOT_FOUND_IN_SOURCE
- TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_MAPPING
- TABLE_ERROR_CODE_VFK_TARGET_TABLE_NOT_FOUND_IN_SOURCE
description: An enumeration of table error codes
mgmt.v1alpha1.ActivityFailure:
type: object
properties:
Expand Down Expand Up @@ -12380,6 +12386,40 @@ components:
type: object
title: SetRunContextsResponse
additionalProperties: false
mgmt.v1alpha1.TableError:
type: object
properties:
schema:
type: string
title: schema
description: The schema of the table
table:
type: string
title: table
description: The table of the error
errorReports:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.TableError.TableErrorReport'
title: error_reports
description: The list of error reports
title: TableError
additionalProperties: false
mgmt.v1alpha1.TableError.TableErrorReport:
type: object
properties:
code:
allOf:
- $ref: '#/components/schemas/mgmt.v1alpha1.TableError.TableErrorCode'
title: code
description: The error code
message:
type: string
title: message
description: The error message
title: TableErrorReport
additionalProperties: false
description: Database error report
mgmt.v1alpha1.TerminateJobRunRequest:
type: object
properties:
Expand Down Expand Up @@ -12616,13 +12656,19 @@ components:
allOf:
- $ref: '#/components/schemas/mgmt.v1alpha1.DatabaseError'
title: database_errors
description: The database error
description: The list of database errors
columnWarnings:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.ColumnWarning'
title: column_warnings
description: The list of column warnings
tableErrors:
type: array
items:
$ref: '#/components/schemas/mgmt.v1alpha1.TableError'
title: table_errors
description: The list of table errors
title: ValidateJobMappingsResponse
additionalProperties: false
mgmt.v1alpha1.VirtualForeignConstraint:
Expand Down
Loading

0 comments on commit 9e3bc93

Please sign in to comment.