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

Added sql test code and modified some code of sql.go #80

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

bourbonkk
Copy link
Contributor

@bourbonkk bourbonkk commented Jan 30, 2023

Added sql test code. #31

I want to help with your project.
Is this project still going on? It doesn't seem to be active.
I want to make it easy for other users to use by writing a lot of test examples.
And the golang version is 1.14 right?
invite me to slack

@jbguerraz
Copy link
Contributor

Hello @bourbonkk

Thank you for your contribution :)

If you wanna add a test for sql queries, maybe the best place is here https://github.com/grafadruid/go-druid/blob/master/query.go , actually, in a query_test.go file to add. If you're about examples, then see https://github.com/grafadruid/go-druid/tree/master/examples

It started from go 1.14 but no issue to update that, still, it'll works with most recent golang versions AFAIK.

The project is active and used; it doesn't move so much since it's quite complete and stable, so far so good :)

There are still Druid (community) extensions to support and tests to add here and there probably.

I've updated the slack invite link, here it is: https://join.slack.com/t/grafadruid/shared_invite/zt-1ohtquqg3-25ka1yV4Kkig0lt5XzfmeA

Cheers,

@vigith
Copy link
Collaborator

vigith commented Feb 2, 2023

+1, we use go-druid actively in production

@bourbonkk
Copy link
Contributor Author

Thank you for your explanation.
@jbguerraz
I'll make the edits you described and commit again. Thank you.

Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Type string `json:"type,omitempty"`
Value interface{} `json:"value,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were cases where the type of value was INTEGER or FLOAT, so I changed it to an interface.

@@ -25,8 +25,11 @@ func NewSQL() *SQL {
return s
}

func NewSQLParameter() *SQLParameter {
p := &SQLParameter{}
func NewSQLParameter(Type string, Value interface{}) SQLParameter {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified to allow use of SQLParameter's constructor.

@@ -60,6 +63,11 @@ func (s *SQL) SetParameters(parameters []SQLParameter) *SQL {
return s
}

func (s *SQL) SetContext(context map[string]interface{}) *SQL {
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 added the SetContext method of the SQL struct because it did not exist.

"testing"
)

func TestSelectSQL(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a comparison test of query builder and actual output.

assert.JSONEq(t, expected, string(expressionJSON))
}

func TestAllSetterSQL(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a comparison test when all methods are changed to true

)

func main() {
d, err := druid.NewClient("http://localhost:8888")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example of using SQL query

@bourbonkk bourbonkk changed the title Added sql test code. Added sql test code and modified some code of sql.go Feb 3, 2023
@raakasf
Copy link
Contributor

raakasf commented Feb 7, 2023

LGTM but I'll get @vigith approve this.

@vigith vigith requested a review from jbguerraz February 7, 2023 15:02
@jbguerraz
Copy link
Contributor

LGTM thank you a lot @bourbonkk :)

Copy link
Contributor

@jbguerraz jbguerraz left a comment

Choose a reason for hiding this comment

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

🎆

@jbguerraz jbguerraz merged commit 3dc969f into grafadruid:master Feb 7, 2023
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.

4 participants