Skip to content

enhancement: Redshift#34

Merged
kndndrj merged 43 commits intokndndrj:masterfrom
MattiasMTS:mattias/feat-redshift
Sep 6, 2023
Merged

enhancement: Redshift#34
kndndrj merged 43 commits intokndndrj:masterfrom
MattiasMTS:mattias/feat-redshift

Conversation

@MattiasMTS
Copy link
Copy Markdown
Collaborator

👷 What has changed 👷

The focus of this PR is to open up this awesome plugin for Redshift users!

I'm opening this PR as a draft for early review. I'll push some more changes with respect to tests, documentation, etc


Redshift

  • Added a new client with a similar structure as the Postgres client but with some differences. Refactored the Layout schema for both clients to re-usable function.
  • Extended the layout to make use of VIEWS
  • Added more code actions to action 1 for both VIEWS and TABLES
  • Made upper case letters for keywords in helpers

Layout

  • added sorting with respect to history to get the latest query at the top and alphabetical on the schema

Logging

Extended the logging library with formatted functions and refactored a few use cases where this was needed.

Bash

I've shellfmt as formatter on nvim and I was in build.sh, which led to the formatted version. Let me know if you want me to revert this. Perhaps it is more worth adding a pre-commit-config.yaml to fix this for future stuff. We can add more configs with respect to sh, go, lua, etc.

@kndndrj
Copy link
Copy Markdown
Owner

kndndrj commented Aug 24, 2023

Hey @MattiasMTS thanks for the contribution!

The changes look nice - don't worry about fomatters (for bash I used something different - beutysh or something like that, but it doesn't matter)

The only thing which I'd like to ask you is that I just prepared a PR for database switching, so I'd like to ask you to revisit this PR once that is merged (I'll try to ping you here) It shouldn't be too complicated, but I expect a few merge confilicts.

@MattiasMTS
Copy link
Copy Markdown
Collaborator Author

Hey @MattiasMTS thanks for the contribution!

The changes look nice - don't worry about fomatters (for bash I used something different - beutysh or something like that, but it doesn't matter)

The only thing which I'd like to ask you is that I just prepared a PR for database switching, so I'd like to ask you to revisit this PR once that is merged (I'll try to ping you here) It shouldn't be too complicated, but I expect a few merge confilicts.

Sounds great! I had a gut feeling this was coming up, hence the draft PR.

I'll hold and rebase after you've merged database switching. Until then I'll pick up something in the backlog/issue.

Thanks for fast response! :)

@kndndrj
Copy link
Copy Markdown
Owner

kndndrj commented Aug 24, 2023

Here it is. I merged into master.

Until then I'll pick up something in the backlog/issue

whoa, nice :)

Also feel free to ask questions, I'd be happy to help :)

@MattiasMTS
Copy link
Copy Markdown
Collaborator Author

Here it is. I merged into master.

Until then I'll pick up something in the backlog/issue

whoa, nice :)

Also feel free to ask questions, I'd be happy to help :)

Sweet. I'll take a peak and rebase. 😋

@MattiasMTS MattiasMTS marked this pull request as ready for review August 25, 2023 18:32
@MattiasMTS
Copy link
Copy Markdown
Collaborator Author

This should now be ready for "real review". Thanks for the initial feedback @kndndrj ! I addressed the rebasing issues, main thing was the new list helper method which in this case needed to accept the vars argument that the helper:get uses as well in order to list the option difference for e.g. VIEW, TABLE, etc. Perhaps worth to add e.g. "Functions" here in the future.


client.go

NB I did some extension of the client.go file, which is to add the interfaces DatabaseClient and DatabaseConnetion. Also updated the return statement of some methods to return interfaces rather than the concrete result. It isn't idiomatic that methods return interfaces rather than the concrete stuff but this refactoring facilitated testing.

The interfaces were needed in order to add mock structs, see how I did it in the redshift_test.go file. Maybe this isn't the prettiest way of doing it. Let me know if you have any other ideas on how to do this and I'm more than happy to do it :)

history.go & result.go

Added SetCallBack and SetCustomHeader interface methods to. Updated the HistoryRows struct with placeholder method to fulfil the interface of models.IterResult. These were needed due to the return statement of the results now returning interfaces rather than the concrete stuff. Again, this made testing easier. Perhaps not the best way to do it since large interfaces become difficult to handle in the long run.. :/

@kndndrj
Copy link
Copy Markdown
Owner

kndndrj commented Aug 25, 2023

I did a quick review from my phone, and overall I like the changes - reminds me of some stuff that I forgot to clean up myself. I'd still like to take a closer look when I have some time though.

Thanks for the contribution and a detailed overview :)

@MattiasMTS
Copy link
Copy Markdown
Collaborator Author

Looking forward to it!

Thanks for awesome response and feedback during these PRs 😄

@MattiasMTS
Copy link
Copy Markdown
Collaborator Author

I'll add this as a reminder to myself to actually reconsider using the redshiftdata api https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/redshiftdata rather than using the database/sql package.

Copy link
Copy Markdown
Owner

@kndndrj kndndrj left a comment

Choose a reason for hiding this comment

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

Thanks again for submitting this PR and sorry that it took me so long to do a propper review.

I'd be really thankful if you address the changes, so we can merge this cool feature!

@@ -4,37 +4,44 @@
set -e
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice of you that you want to format the script, but it was formatter with a different formatter already 😅

I think we can remove these changes if you agree.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Deleted the commit. Totally agree. Is it worth adding some pre-commit-config in the future? 😋

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It would make sense, yeah. although I'm not the most familiar with those configs. If you want, you can come up with something

@MattiasMTS MattiasMTS requested a review from kndndrj September 2, 2023 13:58
Copy link
Copy Markdown
Owner

@kndndrj kndndrj left a comment

Choose a reason for hiding this comment

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

Except for the 2 minor nitpicks, I think the PR looks fine now.
I'll do a quick test and merge it today or tomorrow. Thanks again!

}

func (r *HistoryRows) SetCustomHeader(header models.Header) {
// no-op
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Are these methods an artifact of the deleted interface?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed they are c82b85e

---@param children _LayoutGo[] -- children to sort
---@param field string -- field to sort by
---@param ascending bool -- set to true to sort ascendingly
local function sortChildrenByField(children, field, ascending)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

cool, just snake case please 😅

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

15e5262 sorry, too much scala

Mattias Sjödin and others added 3 commits September 2, 2023 16:28
@kndndrj kndndrj merged commit 0261046 into kndndrj:master Sep 6, 2023
@kndndrj
Copy link
Copy Markdown
Owner

kndndrj commented Sep 6, 2023

thanks for the contribution. I tested some stuff and fixed what didn't work and added some extra stuff.

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.

2 participants