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

updated initialization process #4

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

nikitajain1998
Copy link
Collaborator

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to README are included in PR

@nikitajain1998 nikitajain1998 marked this pull request as ready for review December 4, 2024 04:44
config/config_test.go Outdated Show resolved Hide resolved
storage/spanner.go Show resolved Hide resolved
utils/utils.go Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add apache license header

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added License header

}

// Extract attributes from the table
attributes := make(map[string]string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to scan entire table? Should this be simply output.Table.AttributeDefinitions

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TableDescription.html#DDB-Type-TableDescription-AttributeDefinitions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AttributeDefinitions does not specify the roles of these attributes (i.e., whether they are HASH or RANGE keys), it only contains the attribute names and their data types.
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TableDescription.html#DDB-Type-TableDescription-KeySchema

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add a config to limit number of rows being scanned here to infer attributes. This code without limit may scan whole table which may be very expensive in case of large databases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added dynamo_query_limit

}

func createTable(ctx context.Context, db, ddl string) error {
adminClient, err := Admindatabase.NewDatabaseAdminClient(ctx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Create adminClient once and reuse in createDatabase and createTables

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

api/v1/db.go Outdated
@@ -59,7 +59,7 @@ func RouteRequest(c *gin.Context) {
case "UpdateItem":
Update(c)
default:
c.JSON(errors.New("ValidationException", "Invalid X-Amz-Target header value of" + amzTarget).
c.JSON(errors.New("ValidationException", "Invalid X-Amz-Target header value of"+amzTarget).
Copy link
Collaborator

Choose a reason for hiding this comment

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

space around + as well as after of

Copy link
Collaborator Author

@nikitajain1998 nikitajain1998 Jan 20, 2025

Choose a reason for hiding this comment

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

It seems that spaces around + are being removed automatically when the code is saved due to linter. Added space after of.

}

// Extract attributes from the table
attributes := make(map[string]string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add a config to limit number of rows being scanned here to infer attributes. This code without limit may scan whole table which may be very expensive in case of large databases.

@taherkl
Copy link
Collaborator

taherkl commented Jan 20, 2025

@TanmayVartak All comments are resolve. please provide your approval to merge.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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