Skip to content

Commit

Permalink
[SNOW-1669514] Honor the Valuer/Stringer methods to resolve #1209 (#1211
Browse files Browse the repository at this point in the history
)

Co-authored-by: Piotr Fus <piotr.fus@snowflake.com>
  • Loading branch information
ChronosMasterOfAllTime and sfc-gh-pfus authored Dec 10, 2024
1 parent 56beb83 commit d91e009
Show file tree
Hide file tree
Showing 16 changed files with 484 additions and 126 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Build and Test

on:
push:
braches:
- master
tags:
- v*
pull_request:
branches:
- master
- SNOW-*
schedule:
- cron: '7 3 * * *'
workflow_dispatch:
inputs:
goTestParams:
default:
description: "Parameters passed to go test"
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
- SNOW-*
schedule:
- cron: '7 3 * * *'
workflow_dispatch:
inputs:
goTestParams:
default:
description: 'Parameters passed to go test'

concurrency:
# older builds for the same pull request numer or branch should be cancelled
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: './go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.vscode/
parameters*.json
parameters*.bat
*.p8
Expand All @@ -11,6 +12,8 @@ wss-golang-agent.config
wss-unified-agent.jar
whitesource/
*.swp
cp.out
__debug_bin*

# exclude vendor
vendor
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ This driver currently does not support GCP regional endpoints. Please ensure tha
Snowflake provides a set of sample programs to test with. Set the environment variable ``$GOPATH`` to the top directory of your workspace, e.g., ``~/go`` and make certain to
include ``$GOPATH/bin`` in the environment variable ``$PATH``. Run the ``make`` command to build all sample programs.

```
```sh
make install
```

In the following example, the program ``select1.go`` is built and installed in ``$GOPATH/bin`` and can be run from the command line:

```
```sh
SNOWFLAKE_TEST_ACCOUNT=<your_account> \
SNOWFLAKE_TEST_USER=<your_user> \
SNOWFLAKE_TEST_PASSWORD=<your_password> \
Expand All @@ -79,7 +79,7 @@ The developer notes are hosted with the source code on [GitHub](https://github.c

Set the Snowflake connection info in ``parameters.json``:

```
```json
{
"testconnection": {
"SNOWFLAKE_TEST_USER": "<your_user>",
Expand All @@ -88,21 +88,25 @@ Set the Snowflake connection info in ``parameters.json``:
"SNOWFLAKE_TEST_WAREHOUSE": "<your_warehouse>",
"SNOWFLAKE_TEST_DATABASE": "<your_database>",
"SNOWFLAKE_TEST_SCHEMA": "<your_schema>",
"SNOWFLAKE_TEST_ROLE": "<your_role>"
"SNOWFLAKE_TEST_ROLE": "<your_role>",
"SNOWFLAKE_TEST_DEBUG": "false"
}
}
```

Install [jq](https://stedolan.github.io/jq) so that the parameters can get parsed correctly, and run ``make test`` in your Go development environment:

```
```sh
make test
```

### Setting debug mode during tests
This is for debugging Large SQL statements (greater than 300 characters). If you want to enable debug mode, set `SNOWFLAKE_TEST_DEBUG` to `true` in `parameters.json`, or export it in your shell instance.

## customizing Logging Tags

If you would like to ensure that certain tags are always present in the logs, `RegisterClientLogContextHook` can be used in your init function. See example below.
```
```go
import "github.com/snowflakedb/gosnowflake"

func init() {
Expand All @@ -116,7 +120,7 @@ func init() {

## Setting Log Level
If you want to change the log level, `SetLogLevel` can be used in your init function like this:
```
```go
import "github.com/snowflakedb/gosnowflake"

func init() {
Expand All @@ -138,15 +142,15 @@ The following is a list of options you can pass in to set the level from least t

Configure your testing environment as described above and run ``make cov``. The coverage percentage will be printed on the console when the testing completes.

```
```sh
make cov
```

For more detailed analysis, results are printed to ``coverage.txt`` in the project directory.

To read the coverage report, run:

```
```sh
go tool cover -html=coverage.txt
```

Expand Down
2 changes: 1 addition & 1 deletion bind_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (bu *bindUploader) createStageIfNeeded() error {
return (&SnowflakeError{
Number: code,
SQLState: data.Data.SQLState,
Message: err.Error(),
Message: data.Message,
QueryID: data.Data.QueryID,
}).exceptionTelemetry(bu.sc)
}
Expand Down
Loading

0 comments on commit d91e009

Please sign in to comment.