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

Renamed count headings in schema summary of html/txt report and fixed all cases to add to invalid count #2073

Merged
merged 12 commits into from
Dec 18, 2024

Conversation

priyanshi-yb
Copy link
Contributor

@priyanshi-yb priyanshi-yb commented Dec 12, 2024

Describe the changes in this pull request

1.Changes in the Analyze schema HTML/TXT reports and Assess-migration HTML report for
Total Count -> Total Objects
Valid Count -> Object Without Issues
Invalid Count -> Object With Issues
2. Fixed all the reporting issue cases to add to the invalid count based on object names
3. Fixed all the test cases expected files for this

Fixes

  1. [Voyager] Invalid Count reported in analyze schema is not covering all cases #2028
  2. Invalid Count field rename to something like IssuesInObject #2043

Describe if there are any user-facing changes

Changes in the Analyze schema HTML/TXT reports and Assess-migration HTML report for
Total Count -> Total Objects
Valid Count -> Object Without Issues
Invalid Count -> Object With Issues
Screenshot 2024-12-18 at 6 13 51 PM
Screenshot 2024-12-18 at 6 14 01 PM
Screenshot 2024-12-18 at 6 14 07 PM

How was this pull request tested?

Manually tested the HTML and TXT formats

Does your PR have changes that can cause upgrade issues?

Component Breaking changes?
MetaDB No
Name registry json No
Data File Descriptor Json No
Export Snapshot Status Json No
Import Data State No
Export Status Json No
Data .sql files of tables No
Export and import data queue No
Schema Dump No
AssessmentDB No
Sizing DB No
Migration Assessment Report Json No
Callhome Json No
YugabyteD Tables No
TargetDB Metadata Tables No

@priyanshi-yb priyanshi-yb force-pushed the priyanshi/invalid-cnt-rename-fix branch from 9d84e02 to b04558a Compare December 13, 2024 11:32
Copy link
Collaborator

@makalaaneesh makalaaneesh left a comment

Choose a reason for hiding this comment

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

LGTM with comments

@@ -371,16 +371,6 @@
"GH": "https://github.com/YugaByte/yugabyte-db/issues/1131",
"MinimumVersionsFixedIn": null
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

how come this went away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as discussed -
As I now added invalid count for this regex -

else if spc := alterViewRegex.FindStringSubmatch(sqlInfo.stmt); spc != nil {
			summaryMap["VIEW"].invalidCount[sqlInfo.objName] = true
			reportCase(fpath, "ALTER VIEW not supported yet.",
				"https://github.com/YugaByte/yugabyte-db/issues/1131", "", "VIEW", spc[1], sqlInfo.formattedStmt, UNSUPPORTED_FEATURES, "")
		}

and hence this is not going in this condition -

_, err := queryparser.Parse(sqlStmtInfo.stmt)
if err != nil { //if the Stmt is not already report by any of the regexes
	if !summaryMap[objType].invalidCount[sqlStmtInfo.objName] {
		reason := fmt.Sprintf("%s - '%s'", UNSUPPORTED_PG_SYNTAX, err.Error())
		reportCase(fpath, reason, "https://github.com/yugabyte/yb-voyager/issues/1625",
			"Fix the schema as per PG syntax", objType, sqlStmtInfo.objName, sqlStmtInfo.formattedStmt, UNSUPPORTED_FEATURES, "")
	}

@@ -8,6 +8,7 @@
{
"ObjectType": "SCHEMA",
"TotalCount": 1,
"InvalidCount": 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the logic for determining when a SCHEMA is invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is this Create schema with elements regex case -

CREATE SCHEMA hollywood
    CREATE TABLE films (title text, release date, awards text[])
    CREATE VIEW winners AS
        SELECT title, release FROM films WHERE awards IS NOT NULL;

createSchemaRegex.MatchString(sqlInfo.stmt) {
			summaryMap["SCHEMA"].invalidCount[sqlInfo.objName] = true
			reportCase(fpath, "CREATE SCHEMA with elements not supported yet.",

yb-voyager/cmd/analyzeSchema.go Show resolved Hide resolved
return newQueryIssue(deferrableConstraintIssue, objectType, objectName, sqlStatement, map[string]interface{}{})
func NewDeferrableConstraintIssue(objectType string, objectName string, sqlStatement string, constraintName string) QueryIssue {
details := map[string]interface{}{
"ConstraintName": constraintName,
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a constant for this.

Object Type : {{ .ObjectType }}
- Total Count : {{ .TotalCount }}
- Valid Count : {{ sub .TotalCount .InvalidCount }}
- Objects With Issues Count : {{ .InvalidCount }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets name it Objects With Issues, Count is unnecessary.
Also lets rename InvalidCount variable to ObjectsWithIssues ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But before renaming InvalidCount we need to see if the json payloads sent to yugabyted and callhome would also change. Are we using the InvalidCount field directly there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest renaming
TotalCount -> TotalObjects
ValidCount -> ObjectsWithoutIssues
InvalidCount -> ObjectWithIssues

Copy link
Contributor Author

@priyanshi-yb priyanshi-yb Dec 18, 2024

Choose a reason for hiding this comment

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

Also lets rename InvalidCount variable to ObjectsWithIssues ?

No, we discussed this and didn't do it intentionally as it will effect json struct and will then effect yugabyted and callhome as we use it as is.
This is just UI change for HTML and TEXT reports only

Copy link
Collaborator

@sanyamsinghal sanyamsinghal Dec 18, 2024

Choose a reason for hiding this comment

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

we discussed this and didn't do it intentionally as it will effect json struct and will then effect yugabyted and callhome as we use it as is.

yeah but lets add a TODO, so that whenever we bump up the version of yugabyted payload we can consider changing this also.

@@ -254,10 +236,6 @@ var alterTableAddPKOnPartitionIssue = issue.Issue{

func NewAlterTableAddPKOnPartiionIssue(objectType string, objectName string, SqlStatement string) QueryIssue {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: SqlStatement -> sqlStatement

Comment on lines +652 to +682
var constraintIssues = []string{
queryissue.EXCLUSION_CONSTRAINTS,
queryissue.DEFERRABLE_CONSTRAINTS,
queryissue.PK_UK_ON_COMPLEX_DATATYPE,
}
/*
TODO:
// unsupportedIndexIssue
// ObjectType = INDEX
// ObjectName = idx_name ON table_name
// invalidCount.Type = INDEX
// invalidCount.Name = ObjectName (because this is fully qualified)
// DisplayName = ObjectName

// deferrableConstraintIssue
// ObjectType = TABLE
// ObjectName = table_name
// invalidCount.Type = TABLE
// invalidCount.Name = ObjectName
// DisplayName = table_name (constraint_name) (!= ObjectName)

// Solutions
// 1. Define a issue.ObjectDisplayName
// 2. Keep it in issue.Details and write logic in UI layer to construct display name.
*/
displayObjectName := issueInstance.ObjectName

constraintName, ok := issueInstance.Details[queryissue.CONSTRAINT_NAME]
if slices.Contains(constraintIssues, issueInstance.Type) && ok {
//In case of constraint issues we add constraint name to the object name as well
displayObjectName = fmt.Sprintf("%s, constraint: (%s)", issueInstance.ObjectName, constraintName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

building displaying name can be a different logic for different issue type.

How about having a function queryissue.GetDisplayObjectName() for the time being.

func GetDisplayObjectName(issueInstance QueryIssue) string {
}

We might need this display name in the assess migration also? How are we dealing it in assess right now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also sort of running into the need for this with regex functions. I want to display the function names used...

But I think this needs a bit of discussion, there are so many fields out there 😅 it has become confusing. Shall we take this up separately @sanyamsinghal @priyanshi-yb ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure. Agree, its becoming a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, sure

@priyanshi-yb priyanshi-yb changed the title Rename Invalid count to Objects with issues count in html/txt analyze report and fixed all cases to add to invalid count Renamed count headings in schema summary of html/txt report and fixed all cases to add to invalid count Dec 18, 2024
@priyanshi-yb priyanshi-yb merged commit 736fcee into main Dec 18, 2024
42 checks passed
@priyanshi-yb priyanshi-yb deleted the priyanshi/invalid-cnt-rename-fix branch December 18, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants