Skip to content

Commit

Permalink
Merge branch 'master' into SNOW-692968-async-queries-support
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-nl committed Dec 19, 2024
2 parents 97531c8 + 65ef675 commit f32ada0
Show file tree
Hide file tree
Showing 28 changed files with 234 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jira_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
summary: '${{ github.event.issue.title }}'
description: |
${{ github.event.issue.body }} \\ \\ _Created from GitHub Action_ for ${{ github.event.issue.html_url }}
fields: '{ "customfield_11401": {"id": "14723"}, "assignee": {"id": "712020:3c0352b5-63f7-4e26-9afe-38f6f9f0f4c5"}, "components":[{"id":"19292"}] }'
fields: '{ "customfield_11401": {"id": "14723"}, "assignee": {"id": "712020:e1f41916-da57-4fe8-b317-116d5229aa51"}, "components":[{"id":"19292"}], "labels": ["oss"], "priority": {"id": "10001"} }'

- name: Update GitHub Issue
uses: ./jira/gajira-issue-update
Expand Down
52 changes: 42 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,61 @@ Snowflake Connector for C/C++
:target: http://www.apache.org/licenses/LICENSE-2.0.txt


Prerequisites
================================================================================

Operating system
For a list of the operating systems supported by Snowflake clients, see `Operating system support <https://docs.snowflake.com/en/release-notes/requirements#label-client-operating-system-support>`_.

To build libsnowflakeclient, the following software must be installed:

- On Windows: Visual Studio 2015, 2017, 2019 or 2022
- On Linux:

- gcc/g++ 8.3 or higher. **Note**: on certain OS (e.g. Centos 7) the preinstalled gcc/libstdc++ version is below the required minimum. For Centos 7, this is 4.8.5, which is below the requirement. Building libsnowflakeclient might be unsuccessful on such OS's until the prerequisite is fulfilled, i.e. libraries upgraded to at least the minimum version.
- cmake 3.17 or higher

- On macOS:

- clang
- cmake 3.17 or higher

To run test cases, the following software must be installed:

- jq: https://jqlang.github.io/jq/download/
- python 3.7 or higher

Build and Tests
======================================================================

Build
----------------------------------------------------------------------

Ensure you have cmake 3.17 or later version.

Linux and OSX
^^^^^^^^^^^^^

.. code-block:: bash
./scripts/build_dependencies.sh
./scripts/build_libsnowflakeclient.sh
Windows
^^^^^^^^^^

Set environment variables: PLATFORM: [x64, x86], BUILD_TYPE: [Debug, Release], VS_VERSION: [VS14, VS15, VS16, VS17] and run the script.

.. code-block:: bash
set platform=x64
set build_type=Debug
set vs_version=VS14
ci\build.bat
set build_type=Release
set vs_version=VS17
.\scripts\build_dependencies.bat
.\scripts\build_libsnowflakeclient.bat
Prepare for Test
----------------------------------------------------------------------

Set the Snowflake connection info in ``parameters.json`` and place it in $HOME:
Set the Snowflake connection info in ``parameters.json`` and place it in the root path of libsnowflakeclient repository:

.. code-block:: json
Expand All @@ -55,9 +79,16 @@ Set the Snowflake connection info in ``parameters.json`` and place it in $HOME:
"SNOWFLAKE_TEST_DATABASE": "<your_database>",
"SNOWFLAKE_TEST_SCHEMA": "<your_schema>",
"SNOWFLAKE_TEST_ROLE": "<your_role>"
"SNOWFLAKE_TEST_HOST": "<your_snowflake_url>"
"CLOUD_PROVIDER": "<your_cloud_provider>"
}
}
where:

- :code:`<your_snowflake_url>` is optional. Set it when your Snowflake URL is not in the format of :code:`account.snowflakecomputing.com`.
- :code:`<CLOUD_PROVIDER>` is the cloud platform of your Snowflake account. (:code:`AWS`, :code:`AZURE` or :code:`GCP`).

Proxy
^^^^^^^^^^

Expand Down Expand Up @@ -96,9 +127,10 @@ Set environment variables: PLATFORM: [x64, x86], BUILD_TYPE: [Debug, Release], V
.. code-block:: bash
set platform=x64
set build_type=Debug
set vs_version=VS14
ci\test.bat
set build_type=Release
set vs_version=VS17
.\scripts\run_tests.bat
Code Coverage (Linux)
Expand Down
14 changes: 7 additions & 7 deletions cpp/FileTransferAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void Snowflake::Client::FileTransferAgent::upload(string *command)
}
else if( outcome == RemoteStorageRequestOutcome::FAILED)
{
m_failedTransfers.append(m_largeFilesMeta[i].srcFileName) + ", ";
m_failedTransfers += m_largeFilesMeta[i].srcFileName + ", ";
//Fast fail, return when the first file fails to upload.
if (isPutFastFailEnabled())
{
Expand Down Expand Up @@ -351,7 +351,7 @@ void Snowflake::Client::FileTransferAgent::uploadFilesInParallel(std::string *co
{
if (outcome == RemoteStorageRequestOutcome::FAILED) {
CXX_LOG_DEBUG("Sequential upload %s FAILED.", metadata->srcFileName.c_str());
m_failedTransfers.append(metadata->srcFileName) + ", ";
m_failedTransfers += metadata->srcFileName + ", ";
//Fast fail, return when the first file fails to upload.
if(isPutFastFailEnabled())
{
Expand Down Expand Up @@ -405,7 +405,7 @@ void Snowflake::Client::FileTransferAgent::uploadFilesInParallel(std::string *co
//Cannot throw and catch error from a thread.
CXX_LOG_DEBUG("Parallel upload %s FAILED", metadata->srcFileName.c_str());
_mutex_lock(&m_parallelFailedMsgMutex);
m_failedTransfers.append(metadata->srcFileName) + ", ";
m_failedTransfers += metadata->srcFileName + ", ";
_mutex_unlock(&m_parallelFailedMsgMutex);
}
else if (outcome == RemoteStorageRequestOutcome::SUCCESS)
Expand Down Expand Up @@ -682,7 +682,7 @@ void Snowflake::Client::FileTransferAgent::download(string *command)
{
CXX_LOG_DEBUG("Putget serial large file download, %s file download FAILED.",
m_largeFilesMeta[i].srcFileName.c_str());
m_failedTransfers.append(m_largeFilesMeta[i].srcFileName) + ", ";
m_failedTransfers += m_largeFilesMeta[i].srcFileName + ", ";
//Fast fail, return when the first file fails to download.
if (isGetFastFailEnabled())
{
Expand Down Expand Up @@ -748,7 +748,7 @@ void Snowflake::Client::FileTransferAgent::downloadFilesInParallel(std::string *
else if (outcome == RemoteStorageRequestOutcome::FAILED)
{
CXX_LOG_DEBUG("Sequential download %s FAILED.", metadata->srcFileName.c_str());
m_failedTransfers.append(metadata->srcFileName) + ", ";
m_failedTransfers += metadata->srcFileName + ", ";
//Fast fail, return when the first file fails to download.
if (isGetFastFailEnabled())
{
Expand Down Expand Up @@ -796,7 +796,7 @@ void Snowflake::Client::FileTransferAgent::downloadFilesInParallel(std::string *
{
CXX_LOG_DEBUG("Parallel download %s FAILED.", metadata->srcFileName.c_str());
_mutex_lock(&m_parallelFailedMsgMutex);
m_failedTransfers.append(metadata->srcFileName) + ", ";
m_failedTransfers += metadata->srcFileName + ", ";
_mutex_unlock(&m_parallelFailedMsgMutex);
}
else if (outcome == RemoteStorageRequestOutcome::SUCCESS)
Expand All @@ -810,7 +810,7 @@ void Snowflake::Client::FileTransferAgent::downloadFilesInParallel(std::string *
RemoteStorageRequestOutcome::FAILED, resultIndex);
CXX_LOG_DEBUG("Parallel download %s FAILED.", metadata->srcFileName.c_str());
_mutex_lock(&m_parallelFailedMsgMutex);
m_failedTransfers.append(metadata->srcFileName) + ", ";
m_failedTransfers += metadata->srcFileName + ", ";
_mutex_unlock(&m_parallelFailedMsgMutex);
}

Expand Down
12 changes: 6 additions & 6 deletions deps/curl/lib/vtls/sf_ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ SF_CERT_STATUS checkResponse(OCSP_RESPONSE *resp,
long validity = (pday*24*60*60 + psec)/100;
skewInSec = validity > skewInSec ? validity : skewInSec;
infof(data, "Diff between thisupd and nextupd "
"day: %d, sec: %d, Tolerant skew: %d", pday, psec,
"day: %d, sec: %d, Tolerant skew: %ld", pday, psec,
skewInSec);
}
else
Expand Down Expand Up @@ -779,7 +779,7 @@ static OCSP_RESPONSE * queryResponderUsingCurl(char *url, OCSP_CERTID *certid, c
}
else
{
snprintf(urlbuf, sizeof(urlbuf),
snprintf(urlbuf, sizeof(urlbuf), "%s",
ocsp_cache_server_retry_url_pattern);
}
}
Expand Down Expand Up @@ -882,7 +882,7 @@ static OCSP_RESPONSE * queryResponderUsingCurl(char *url, OCSP_CERTID *certid, c
}
else if (response_code < 200 || response_code >= 300)
{
failf(data, "OCSP request failed with non-200 level code: %d",
failf(data, "OCSP request failed with non-200 level code: %ld",
response_code);

if (ocsp_retry_cnt == max_retry-1)
Expand Down Expand Up @@ -1247,7 +1247,7 @@ static SF_OCSP_STATUS checkResponseTimeValidity(OCSP_RESPONSE *resp, struct Curl
long validity = (pday*24*60*60 + psec)/100;
skewInSec = validity > skewInSec ? validity : skewInSec;
infof(data, "Diff between thisupd and nextupd "
"day: %d, sec: %d, Tolerant skew: %d", pday, psec,
"day: %d, sec: %d, Tolerant skew: %ld", pday, psec,
skewInSec);
}
else
Expand Down Expand Up @@ -1550,7 +1550,7 @@ void downloadOCSPCache(struct Curl_easy *data, SF_OTD *ocsp_log_data, char *last
}
else if (response_code < 200 || response_code >= 300 )
{
failf(data, "OCSP cache download request failed with non-200 level code: %d, OCSP Cache Could not be downloaded",
failf(data, "OCSP cache download request failed with non-200 level code: %ld, OCSP Cache Could not be downloaded",
response_code);
sf_otd_set_event_sub_type(OCSP_RESPONSE_CACHE_DOWNLOAD_FAILED, ocsp_log_data);
goto end;
Expand Down Expand Up @@ -2450,7 +2450,7 @@ SF_PUBLIC(CURLcode) checkCertOCSP(struct connectdata *conn,

sf_otd_set_insecure_mode(0, &ocsp_log_data);

infof(data, "Cert Data Store: %s, Certifcate Chain: %s", st, ch);
infof(data, "Cert Data Store: %s, Certifcate Chain: %s", (char*)st, (char*)ch);
initOCSPCacheServer(data);

infof(data, "Start SF OCSP Validation...");
Expand Down
1 change: 1 addition & 0 deletions include/snowflake/QueryContextCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <map>
#include <set>
#include <vector>
#include <string>
#include "snowflake/client.h"

namespace Snowflake
Expand Down
2 changes: 1 addition & 1 deletion include/snowflake/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#ifndef SNOWFLAKE_CLIENT_VERSION_H
#define SNOWFLAKE_CLIENT_VERSION_H

#define SF_API_VERSION "1.1.1"
#define SF_API_VERSION "1.1.2"

#endif /* SNOWFLAKE_CLIENT_VERSION_H */
10 changes: 6 additions & 4 deletions lib/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3510,15 +3510,17 @@ SF_STATUS STDCALL snowflake_timestamp_get_epoch_seconds(SF_TIMESTAMP *ts,
return SF_STATUS_ERROR_NULL_POINTER;
}

time_t epoch_time_local;
time_t epoch_time;

ts->tm_obj.tm_isdst = -1;
epoch_time_local = (time_t) mktime(&ts->tm_obj);
// mktime takes into account tm_gmtoff which is a Linux and OS X ONLY field
#if defined(__linux__) || defined(__APPLE__)
epoch_time_local += ts->tm_obj.tm_gmtoff;
epoch_time = (time_t)mktime(&ts->tm_obj);
epoch_time += ts->tm_obj.tm_gmtoff;
#else
epoch_time = _mkgmtime64(&ts->tm_obj);
#endif
*epoch_time_ptr = epoch_time_local - (ts->tzoffset * 60);
*epoch_time_ptr = epoch_time - (ts->tzoffset * 60);

return SF_STATUS_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/results.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ char *value_to_string(void *value, size_t len, SF_C_TYPE c_type) {
return ret;
case SF_C_TYPE_BOOLEAN:
ret = (char*) SF_CALLOC(1, size + 1);
sf_strncpy(ret, size + 1, *(sf_bool*)value != (sf_bool)0 ? SF_BOOLEAN_INTERNAL_TRUE_STR : SF_BOOLEAN_INTERNAL_FALSE_STR, size + 1);
sf_strcpy(ret, size + 1, *(sf_bool*)value != (sf_bool)0 ? SF_BOOLEAN_INTERNAL_TRUE_STR : SF_BOOLEAN_INTERNAL_FALSE_STR);
return ret;
case SF_C_TYPE_BINARY:
size = (size_t)len * 2 + 1;
Expand Down
43 changes: 23 additions & 20 deletions scripts/_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Initialize varizbles

set -o pipefail

export PATH=/usr/local/bin:$PATH
export TERM=vt100

Expand Down Expand Up @@ -35,64 +34,67 @@ if [[ -z "$GCC" || -z "$GXX" ]]; then
elif (test -f "/usr/lib64/ccache/gcc52") && (test -f "/usr/lib64/ccache/g++52"); then
GCC="/usr/lib64/ccache/gcc52"
GXX="/usr/lib64/ccache/g++52"
elif which gcc-5 >& /dev/null; then
elif which g++-5 >& /dev/null; then
GCC="$(which gcc-5)"
GXX="$(which g++-5)"
elif which gcc5 >& /dev/null; then
elif which g++5 >& /dev/null; then
GCC="$(which gcc5)"
GXX="$(which g++5)"
elif which gcc-62 >& /dev/null; then
elif which g++-62 >& /dev/null; then
GCC="$(which gcc-62)"
GXX="$(which g++-62)"
elif which gcc62 >& /dev/null; then
elif which g++62 >& /dev/null; then
GCC="$(which gcc62)"
GXX="$(which g++62)"
elif which gcc-6 >& /dev/null; then
elif which g++-6 >& /dev/null; then
GCC="$(which gcc-6)"
GXX="$(which g++-6)"
elif which gcc6 >& /dev/null; then
elif which g++6 >& /dev/null; then
GCC="$(which gcc6)"
GXX="$(which g++6)"
elif which gcc-72 >& /dev/null; then
elif which g++-72 >& /dev/null; then
GCC="$(which gcc-72)"
GXX="$(which g++-72)"
elif which gcc72 >& /dev/null; then
elif which g++72 >& /dev/null; then
GCC="$(which gcc72)"
GXX="$(which g++72)"
elif which gcc-7 >& /dev/null; then
elif which g++-7 >& /dev/null; then
GCC="$(which gcc-7)"
GXX="$(which g++-7)"
elif which gcc7 >& /dev/null; then
elif which g++7 >& /dev/null; then
GCC="$(which gcc7)"
GXX="$(which g++7)"
elif which gcc-82 >& /dev/null; then
elif which g++-82 >& /dev/null; then
GCC="$(which gcc-82)"
GXX="$(which g++-82)"
elif which gcc82 >& /dev/null; then
elif which g++82 >& /dev/null; then
GCC="$(which gcc82)"
GXX="$(which g++82)"
elif which gcc-8 >& /dev/null; then
elif which g++-8 >& /dev/null; then
GCC="$(which gcc-8)"
GXX="$(which g++-8)"
elif which gcc8 >& /dev/null; then
elif which g++8 >& /dev/null; then
GCC="$(which gcc8)"
GXX="$(which g++8)"
elif which gcc-92 >& /dev/null; then
elif which g++-92 >& /dev/null; then
GCC="$(which gcc-92)"
GXX="$(which g++-92)"
elif which gcc92 >& /dev/null; then
elif which g++92 >& /dev/null; then
GCC="$(which gcc92)"
GXX="$(which g++92)"
elif which gcc-9 >& /dev/null; then
elif which g++-9 >& /dev/null; then
GCC="$(which gcc-9)"
GXX="$(which g++-9)"
elif which gcc9 >& /dev/null; then
elif which g++9 >& /dev/null; then
GCC="$(which gcc9)"
GXX="$(which g++9)"
else
elif which g++ >& /dev/null; then
# Default to system
GCC="$(which gcc)"
GXX="$(which g++)"
else
echo "Error: gcc/g++ not found. Please install gcc/g++."
exit 1
fi
fi

Expand Down Expand Up @@ -164,3 +166,4 @@ fi

export DEPENDENCY_DIR=$DIR/../deps-build/$PLATFORM/$target
mkdir -p $DEPENDENCY_DIR

Loading

0 comments on commit f32ada0

Please sign in to comment.