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

Sf rebase#1 #159

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
df7fe6e
[Maintenance] Create Fork
Jun 1, 2022
7527d70
[Fix] arrowToValue handling of timestamp_ltz at non-nanosecond scales…
sigmacomputingluke Jul 29, 2021
15d99cc
[Fix] SIG-18794: Fix handling of results response for canceled querie…
mtoader Mar 16, 2022
04fb391
[Feature] Add fetchers for result, monitoring, query-graph.
Yifeng-Sigma Feb 17, 2022
c31e061
[Feature] allow clients to set QUERY_TAG parameter via context
jsjqian Apr 30, 2021
087fb36
[Fix] SIG-17456: Trap chunk-downloader errors with Sentry at Multiple…
agam Jan 27, 2022
cd0e9da
[Feature] Allow clients to specify any/null DataType explicitly
GregOwen Feb 15, 2022
aff5962
[Feature] add a cache to the FetchResult codepath to avoid API calls …
mhseiden Jan 26, 2022
4f7758e
[Fix] SIG-18794: Fix getAsync() to not panic on context exceeded + te…
mtoader Mar 11, 2022
c770d0e
[Fix] shutdown race over access of the connection's "restful" structure.
Nov 4, 2021
69eedd2
[Feature] Improvements to Async handling
mtoader Mar 16, 2022
40aa397
[Maintenance] Rebase: 6/6/22
Jun 6, 2022
d772f33
[Feature] Enable fetching raw Arrow records directly
fengqingthu Jul 19, 2022
3e52244
[Feature][SIG-24903] Prototype for Snowflake SubmitSync (#81)
aldld Sep 15, 2022
5a6b5c1
[Feature] Snowflake driver to support `WaitForQueryCompletion()`; wai…
madisonchamberlain Sep 13, 2022
9e7c815
[Feature] Enable extracting tokens from snowflake conn and constructi…
aldld Sep 19, 2022
eac001e
[Maintenance] Rebase with upstream 2022-09-19
aldld Sep 19, 2022
9c53955
If FuncGet() returns no code dont convert to str (#89)
madisonchamberlain Oct 11, 2022
17e6f8c
test with context deadline (#92)
madisonchamberlain Oct 21, 2022
2b29acb
Don't cache non success responses (#109)
mtoader Dec 29, 2022
e2bfc88
Fix atoi error. (#110)
mtoader Dec 29, 2022
d0dd743
Revert "Don't cache non success responses" (#111)
mtoader Dec 29, 2022
aca7395
fix incorrect error sending (#114)
mansapabbaraju Dec 30, 2022
18fef1f
fix res.Success in async.go (#115)
Yifeng-Sigma Dec 30, 2022
4c1f5cb
Add StateDuration to QueryMonitoringData struct (#116)
ayman-sigma Jan 9, 2023
daaa1d3
add logging for sf cache bug (#117)
mansapabbaraju Jan 20, 2023
e439cf7
Protect against nil and raise error instead (#118)
mtoader Jan 25, 2023
ea347b0
[Feature] Add support for client log context hooks (#119)
aldld Feb 8, 2023
cab33e5
save changes
madisonchamberlain Feb 8, 2023
d30328e
fix up
madisonchamberlain Feb 8, 2023
f180de6
bump down go
madisonchamberlain Feb 9, 2023
946470a
put back build test to what it was
madisonchamberlain Feb 10, 2023
48d6511
just test on linux like we used to
madisonchamberlain Feb 10, 2023
5d2deba
fix status
madisonchamberlain Feb 10, 2023
bd4b7d1
update test back to what it was
madisonchamberlain Feb 10, 2023
0943196
Add a nil check for snowflakeRows.Close (#123)
aldld Feb 21, 2023
e2f5313
Only cache successful API responses (#124)
aldld Mar 10, 2023
8a68661
[Maint] squash 8 commits from my last rebase (#125)
madisonchamberlain Apr 27, 2023
243eb12
fmt
madisonchamberlain May 2, 2023
c2cb1f1
use unsupported type
madisonchamberlain May 3, 2023
63c6110
use TimestampNtz as default when the client does not specify data typ…
GregOwen May 5, 2023
beef694
[SIG-35025] Add a nil check in snowflake driver heartbeat function (#…
rajsigma May 19, 2023
f64bd26
[SIG-36502]add more visibility into chunk downloader (#132)
Yifeng-Sigma May 19, 2023
86b6fa7
Add status on snowflakes status result so we know if the query is que…
madisonchamberlain May 25, 2023
b29ba2a
Don't require username & password if using token accessor (#144)
madisonchamberlain Jul 7, 2023
d94a4c8
Adding Changes of sf_stable_master to master branch (#147)
sureshmula2 Jul 18, 2023
75a0379
remove dependency on arrow v0 (#148)
Yifeng-Sigma Jul 19, 2023
669606c
[SIG-40301] fix integer value not in range error (#149)
Yifeng-Sigma Aug 3, 2023
c0a8dfb
use bigFloat when convert int64 to float (#150)
Yifeng-Sigma Aug 3, 2023
dcd8a27
[SIG-40455] fix arrow batch int64 to ntz/ltz (#151)
Yifeng-Sigma Aug 5, 2023
44425e5
add arrowToRecord tz tests (#152)
Yifeng-Sigma Aug 8, 2023
5465ac7
[SIG-40738] convert binary array to string array (#153)
Yifeng-Sigma Aug 10, 2023
bc8b7b2
[SIG-40820]don't panic if type mismatch is decode arrow (#154)
Yifeng-Sigma Aug 11, 2023
8a3ffd3
Revert "[SIG-40738] convert binary array to string array" (#155)
Yifeng-Sigma Aug 15, 2023
3432b92
[SIG-41137] remove decode fixed types from arrowToRecord (#156)
Yifeng-Sigma Aug 16, 2023
af51126
fix recordToSchema and not do conversion for fixedType (#157)
Yifeng-Sigma Aug 16, 2023
ed1cf70
[Security] Remove logging sql text from the snowflake driver (part 2 …
rajsigma Aug 16, 2023
37cad60
[Maintenance] Create Fork
Jun 1, 2022
f32d2a4
[Fix] arrowToValue handling of timestamp_ltz at non-nanosecond scales…
sigmacomputingluke Jul 29, 2021
40a433a
[Fix] SIG-18794: Fix handling of results response for canceled querie…
mtoader Mar 16, 2022
8c59b7c
[Feature] Add fetchers for result, monitoring, query-graph.
Yifeng-Sigma Feb 17, 2022
0881df5
[Feature] allow clients to set QUERY_TAG parameter via context
jsjqian Apr 30, 2021
b9f9e88
[Fix] SIG-17456: Trap chunk-downloader errors with Sentry at Multiple…
agam Jan 27, 2022
7b85b99
[Feature] Allow clients to specify any/null DataType explicitly
GregOwen Feb 15, 2022
81346f8
[Feature] add a cache to the FetchResult codepath to avoid API calls …
mhseiden Jan 26, 2022
3f10a57
[Fix] SIG-18794: Fix getAsync() to not panic on context exceeded + te…
mtoader Mar 11, 2022
3ffd773
[Fix] shutdown race over access of the connection's "restful" structure.
Nov 4, 2021
abbfcbc
[Feature] Improvements to Async handling
mtoader Mar 16, 2022
370433c
[Maintenance] Rebase: 6/6/22
Jun 6, 2022
dce4f98
[Feature] Enable fetching raw Arrow records directly
fengqingthu Jul 19, 2022
5203959
[Feature][SIG-24903] Prototype for Snowflake SubmitSync (#81)
aldld Sep 15, 2022
0c90328
[Feature] Snowflake driver to support `WaitForQueryCompletion()`; wai…
madisonchamberlain Sep 13, 2022
ad2208d
[Feature] Enable extracting tokens from snowflake conn and constructi…
aldld Sep 19, 2022
2a76d4e
[Maintenance] Rebase with upstream 2022-09-19
aldld Sep 19, 2022
dae502a
If FuncGet() returns no code dont convert to str (#89)
madisonchamberlain Oct 11, 2022
8fc71b7
test with context deadline (#92)
madisonchamberlain Oct 21, 2022
d07ab61
Don't cache non success responses (#109)
mtoader Dec 29, 2022
b4df9f8
Fix atoi error. (#110)
mtoader Dec 29, 2022
4619ddd
Revert "Don't cache non success responses" (#111)
mtoader Dec 29, 2022
cec8eca
fix incorrect error sending (#114)
mansapabbaraju Dec 30, 2022
7f631c0
fix res.Success in async.go (#115)
Yifeng-Sigma Dec 30, 2022
78cc6a7
Add StateDuration to QueryMonitoringData struct (#116)
ayman-sigma Jan 9, 2023
b76d3c7
add logging for sf cache bug (#117)
mansapabbaraju Jan 20, 2023
2b4107f
Protect against nil and raise error instead (#118)
mtoader Jan 25, 2023
d7de588
[Feature] Add support for client log context hooks (#119)
aldld Feb 8, 2023
859292a
save changes
madisonchamberlain Feb 8, 2023
6f280fa
fix up
madisonchamberlain Feb 8, 2023
406fdc6
bump down go
madisonchamberlain Feb 9, 2023
0db5c99
put back build test to what it was
madisonchamberlain Feb 10, 2023
17007f8
fix status
madisonchamberlain Feb 10, 2023
9f59ac8
update test back to what it was
madisonchamberlain Feb 10, 2023
780055a
Add a nil check for snowflakeRows.Close (#123)
aldld Feb 21, 2023
dfaa69c
Only cache successful API responses (#124)
aldld Mar 10, 2023
98bf060
[Maint] squash 8 commits from my last rebase (#125)
madisonchamberlain Apr 27, 2023
1144395
fmt
madisonchamberlain May 2, 2023
9a0c258
use unsupported type
madisonchamberlain May 3, 2023
7651e9a
[SIG-35025] Add a nil check in snowflake driver heartbeat function (#…
rajsigma May 19, 2023
7250507
[SIG-36502]add more visibility into chunk downloader (#132)
Yifeng-Sigma May 19, 2023
64f3664
Add status on snowflakes status result so we know if the query is que…
madisonchamberlain May 25, 2023
74702e3
Don't require username & password if using token accessor (#144)
madisonchamberlain Jul 7, 2023
2f53948
Adding Changes of sf_stable_master to master branch (#147)
sureshmula2 Jul 18, 2023
067ccf1
remove dependency on arrow v0 (#148)
Yifeng-Sigma Jul 19, 2023
effbcd9
[SIG-40301] fix integer value not in range error (#149)
Yifeng-Sigma Aug 3, 2023
4016c8c
use bigFloat when convert int64 to float (#150)
Yifeng-Sigma Aug 3, 2023
88c81d7
[SIG-40455] fix arrow batch int64 to ntz/ltz (#151)
Yifeng-Sigma Aug 5, 2023
32db357
add arrowToRecord tz tests (#152)
Yifeng-Sigma Aug 8, 2023
5222859
[SIG-40738] convert binary array to string array (#153)
Yifeng-Sigma Aug 10, 2023
f9c1d6a
[SIG-40820]don't panic if type mismatch is decode arrow (#154)
Yifeng-Sigma Aug 11, 2023
14691a1
Revert "[SIG-40738] convert binary array to string array" (#155)
Yifeng-Sigma Aug 15, 2023
d93cc7a
[SIG-41137] remove decode fixed types from arrowToRecord (#156)
Yifeng-Sigma Aug 16, 2023
fdba2bf
fix recordToSchema and not do conversion for fixedType (#157)
Yifeng-Sigma Aug 16, 2023
0393e93
[Security] Remove logging sql text from the snowflake driver (part 2 …
rajsigma Aug 16, 2023
106da3c
Merge branch 'master' into sf_rebase#1
rajsigma Aug 29, 2023
974a1d6
Reconcile with gosnowflake db master
rajsigma Aug 30, 2023
eab058b
Update async_test.go
rajsigma Aug 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 42 additions & 109 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,113 +1,46 @@
name: Build and Test

on:
push:
braches:
- master
tags:
- v*
pull_request:
branches:
- master
schedule:
- cron: '7 3 * * *'
workflow_dispatch:
inputs:
logLevel:
default: warning
description: "Log level"
required: true
tags:
description: "Test scenario tags"

concurrency:
# older builds for the same pull request numer or branch should be cancelled
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

push:
braches:
- master
tags:
- v*
pull_request:
branches:
- master
schedule:
- cron: "7 3 * * *"
workflow_dispatch:
inputs:
logLevel:
default: warning
description: "Log level"
required: true
tags:
description: "Test scenario tags"
jobs:
build-test-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cloud: [ 'AWS', 'AZURE', 'GCP' ]
go: [ '1.20', '1.19' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Ubuntu
steps:
- uses: actions/checkout@v1
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Format, Lint
shell: bash
run: ./ci/build.sh
- name: Test
shell: bash
env:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: ./ci/test.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
build-test-mac:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
cloud: [ 'AWS', 'AZURE', 'GCP' ]
go: [ '1.20', '1.19' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Mac
steps:
- uses: actions/checkout@v1
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Format, Lint
shell: bash
run: ./ci/build.sh
- name: Test
shell: bash
env:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: ./ci/test.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
build-test-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
cloud: [ 'AWS', 'AZURE', 'GCP' ]
go: [ '1.20', '1.19' ]
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Windows
steps:
- uses: actions/checkout@v1
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Format, Lint
shell: cmd
run: ci\\build.bat
- uses: actions/setup-python@v1
with:
python-version: '3.x'
architecture: 'x64'
- name: Test
shell: cmd
env:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: ci\\test.bat
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
build-test-linux:
environment: gosnowflake-ci-env
runs-on: ubuntu-latest
strategy:
matrix:
# TODO(SIG-12289): re-enable tests on cloud providers other than AWS, and for v1.18
cloud: ["AWS"]
go: ['1.19']
name: ${{ matrix.cloud }} Go ${{ matrix.go }} on Ubuntu
steps:
- uses: actions/checkout@v1
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Format, Lint
shell: bash
run: ./ci/build.sh
- name: Test
shell: bash
env:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: ./ci/test.sh
Binary file modified .github/workflows/parameters_aws_golang.json.gpg
Binary file not shown.
Binary file modified .github/workflows/rsa-2048-private-key.p8.gpg
Binary file not shown.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Set the Snowflake connection info in ``parameters.json``:
"SNOWFLAKE_TEST_ROLE": "<your_role>"
}
}

You can find the complete file in the [Sigma 1Password](https://my.1password.com/vaults/likk64vc3hl7iaozanwj3dn7vu/allitems/72eslwc2yrglsfadkepljc45ai)

```

Install [jq](https://stedolan.github.io/jq) so that the parameters can get parsed correctly, and run ``make test`` in your Go development environment:
Expand Down Expand Up @@ -110,3 +113,33 @@ You may use your preferred editor to edit the driver code. Make certain to run `
For official support, contact Snowflake support at:
[https://support.snowflake.net/](https://support.snowflake.net/).

## Setting up the CI credentials

You shouldn't need to do this, but in case we need to rotate the CI credentials, here are the steps I followed to create them:

1. Install ``gpg`` if you don't already have it:

```
brew install gpg
```

2. Get the `gpg passphrase <https://my.1password.com/vaults/likk64vc3hl7iaozanwj3dn7vu/allitems/esdnmyqh5c3cze3k67tqrkd5s4>`_ and the raw `parameters.json file <https://my.1password.com/vaults/likk64vc3hl7iaozanwj3dn7vu/allitems/72eslwc2yrglsfadkepljc45ai>`_ from the Sigma 1Password.

3. Use ``gpg``'s symmetric encryption mode to encrypt the ``parameters.json`` file. You'll be prompted twice to enter the passphrase:

```
gpg --symmetric --cipher-algo AES256 --output .github/workflows/parameters_aws_golang.json.gpg parameters.json
```

4. Get the `TEST_USER private key <https://sigmacomputing.1password.com/vaults/likk64vc3hl7iaozanwj3dn7vu/allitems/7g4gv6wjbbh6bgt7t6v6dlbhke>`_ from the Sigma 1Password. The TEST_USER keypair secret includes a public key, an encrypted private key, and the passphrase used to encrypt the private key; copy only the encrypted private key into ``rsa-2048-private-key-enc.p8``)

5. Remove the passphrase from the private key (you'll be prompted for the private key passphrase), then use ``gpg``'s symmetric encryption mode to encrypt the resulting unencrypted private key (we only need one layer of encryption and it's easier to standardize on ``gpg``). As with the ``parameters.json`` file, you'll be prompted twice to enter the gpg passphrase:

```
openssl pkcs8 -in rsa-2048-private-key-enc.p8 -out rsa-2048-private-key.p8
gpg --symmetric --cipher-algo AES256 --output .github/workflows/rsa-2048-private-key.p8.gpg rsa-2048-private-key.p8
```

6. Ensure that the gpg passphrase is configured properly in the `GitHub Environment <https://docs.github.com/en/actions/reference/environments>`_


59 changes: 59 additions & 0 deletions arrow_chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ package gosnowflake
import (
"bytes"
"encoding/base64"
"io"
"strconv"
"strings"
"time"

"github.com/apache/arrow/go/v12/arrow"
Expand Down Expand Up @@ -67,6 +70,62 @@ func (arc *arrowResultChunk) decodeArrowBatch(scd *snowflakeChunkDownloader) (*[
return &records, arc.reader.Err()
}

// Note(Qing): Previously, the gosnowflake driver decodes the raw arrow chunks fetched from snowflake by
// calling the decodeArrowBatch() function above. Instead of decoding here, we directly pass the raw records
// to evaluator, along with neccesary metadata needed.
func (arc *arrowResultChunk) passRawArrowBatch(scd *snowflakeChunkDownloader) (*[]arrow.Record, error) {
var records []arrow.Record

for {
rawRecord, err := arc.reader.Read()
if err == io.EOF {
break
} else if err != nil {
return nil, err
}
// Here we check all metadata from snowflake are preserved, so evaluator can decode accordingly
for idx, field := range rawRecord.Schema().Fields() {
// NOTE(Qing): Sometimes we see the rowtype metadata specify nullable as false but then still
// reveive nullable arrow records. Given that, we do not check the nullability here. Also, no
// need to compare names.
if !checkMetadata(field.Metadata, scd.RowSet.RowType[idx]) {
logger.Error("Lack or mismatch of necessary metadata to decode fetched raw arrow records")
return nil, &SnowflakeError{
Message: "Lack or mismatch of necessary metadata to decode fetched raw arrow records",
}
}
}
rawRecord.Retain()
records = append(records, rawRecord)
}
return &records, nil
}

func checkMetadata(actual arrow.Metadata, expected execResponseRowType) bool {
// LogicalType seems to be the only REALLY necessary metadata.
var hasLogicalType bool

for idx, key := range actual.Keys() {
switch strings.ToUpper(key) {
case "LOGICALTYPE":
hasLogicalType = true
if !strings.EqualFold(actual.Values()[idx], expected.Type) {
return false
}
case "SCALE":
switch strings.ToUpper(expected.Type) {
case "FIXED", "TIME", "TIMESTAMP_LTZ", "TIMESTAMP_NTZ":
if i64, err := strconv.ParseInt(actual.Values()[idx], 10, 64); err != nil || i64 != expected.Scale {
return false
}
default:
}
default:
}
}
return hasLogicalType
}

// Build arrow chunk based on RowSet of base64
func buildFirstArrowChunk(rowsetBase64 string, loc *time.Location, alloc memory.Allocator) arrowResultChunk {
rowSetBytes, err := base64.StdEncoding.DecodeString(rowsetBase64)
Expand Down
Loading
Loading