-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/snowflakedb/snowflake-con…
…nector-nodejs into SNOW-728803-request-id-sqlText
- Loading branch information
Showing
9 changed files
with
370 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash -e | ||
# | ||
# Test NodeJS for Ubuntu | ||
# | ||
|
||
echo "DOWNLOADED" | ||
echo $(ls /Users/runner/work/snowflake-connector-nodejs/snowflake-connector-nodejs/) | ||
set -o pipefail | ||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
source $THIS_DIR/_init.sh | ||
source $THIS_DIR/scripts/set_git_info.sh | ||
|
||
export WORKSPACE=$GITHUB_WORKSPACE | ||
export SOURCE_ROOT=$GITHUB_WORKSPACE | ||
export SHOULD_GENERATE_COVERAGE_REPORT=1 | ||
export SHOULD_SKIP_PROXY_TESTS=1 | ||
|
||
python3 --version | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
pip3 install -U pip | ||
pip3 install -U snowflake-connector-python | ||
$THIS_DIR/container/test_component.sh $SHOULD_GENERATE_COVERAGE_REPORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-console */ | ||
const snowflake = require('snowflake-sdk'); | ||
const { connectUsingEnv, destroyAsync } = require('./helpers'); | ||
|
||
const executeQuery = (connection, query, binds = undefined) => new Promise((resolve, reject) => { | ||
connection.execute({ | ||
sqlText: query, | ||
binds: binds, | ||
complete: function (err, stmt, rows) { | ||
if (!err) { | ||
resolve(rows); | ||
} else { | ||
reject(err); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
const executeQueryStreaming = (connection, query, binds = undefined) => new Promise((resolve, reject) => { | ||
const stmt = connection.execute({ | ||
sqlText: query, | ||
binds: binds, | ||
streamResult: true, | ||
}); | ||
stmt.streamRows() | ||
.on('error', err => reject(err)) | ||
.on('data', () => {}) | ||
.on('end', () => resolve()); | ||
}); | ||
|
||
async function runQueryReadingResultsFromRows(query){ | ||
const connection = await connectUsingEnv(); | ||
console.time('without streaming'); | ||
await executeQuery(connection, query); | ||
console.timeEnd('without streaming'); | ||
await destroyAsync(connection); | ||
} | ||
|
||
async function runQueryReadingResultsFromStream(query){ | ||
const connection = await connectUsingEnv(); | ||
console.time('with streaming'); | ||
await executeQueryStreaming(connection, query); | ||
console.timeEnd('with streaming'); | ||
await destroyAsync(connection); | ||
} | ||
|
||
async function main() { | ||
const query = 'Select 1'; // Set your query here | ||
snowflake.configure({ logLevel: 'ERROR' }); | ||
console.log(`Executing query: ${query}`); | ||
await runQueryReadingResultsFromRows(query); | ||
await runQueryReadingResultsFromStream(query); | ||
} | ||
|
||
main(); |
Oops, something went wrong.