-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a simple snowflake sink, enabling writing data into a snowflake database. Under the hood, it uses arrow-adbc's snowflake driver, which does bulk ingestion via file staging. Fixes tenzir/issues#2031
- Loading branch information
Showing
23 changed files
with
402 additions
and
10 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,2 @@ | ||
We have added a new `to_snowflake` sink operator, writing events into a | ||
[snowflake](https://www.snowflake.com/) table. |
Submodule tenzir-plugins
updated
from 3ce662 to 24902b
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 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchFromGitHub, | ||
cmake, | ||
arrow-adbc-go, | ||
testers, | ||
}: | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "arrow-adbc-cpp"; | ||
version = "1.3.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "apache"; | ||
repo = "arrow-adbc"; | ||
rev = "apache-arrow-adbc-15"; | ||
hash = "sha256-QRWVmUYNdMxQqe9dIBxcY8pY8aAbKIh3dhX3rzCGYI4="; | ||
}; | ||
|
||
patches = [ | ||
./use-prebuilt-go-lib.patch | ||
]; | ||
|
||
sourceRoot = "${finalAttrs.src.name}/c"; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
|
||
buildInputs = [ | ||
arrow-adbc-go | ||
]; | ||
|
||
cmakeFlags = [ | ||
(lib.cmakeBool "ADBC_BUILD_SHARED" (!stdenv.hostPlatform.isStatic)) | ||
(lib.cmakeBool "ADBC_BUILD_STATIC" stdenv.hostPlatform.isStatic) | ||
(lib.cmakeBool "ADBC_DRIVER_MANAGER" true) | ||
(lib.cmakeBool "ADBC_DRIVER_SNOWFLAKE" true) | ||
(lib.cmakeFeature "adbc_driver_snowflake_prebuilt" | ||
"${arrow-adbc-go}/lib/snowflake${stdenv.hostPlatform.extensions.library}") | ||
]; | ||
|
||
meta = with lib; { | ||
description = "Database connectivity API standard and libraries for Apache Arrow "; | ||
homepage = "https://arrow.apache.org/adbc/"; | ||
license = licenses.asl20; | ||
platforms = platforms.unix; | ||
maintainers = [ maintainers.tobim ]; | ||
pkgConfigModules = [ | ||
"arrow-adbc" | ||
]; | ||
}; | ||
|
||
passthru = { | ||
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; | ||
}; | ||
}) |
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,58 @@ | ||
diff --git a/cmake_modules/BuildUtils.cmake b/cmake_modules/BuildUtils.cmake | ||
index 88209ac5e..aefff1d5e 100644 | ||
--- a/cmake_modules/BuildUtils.cmake | ||
b/cmake_modules/BuildUtils.cmake | ||
@@ -310,7 310,7 @@ function(ADD_ARROW_LIB LIB_NAME) | ||
if(BUILD_STATIC) | ||
add_library(${LIB_NAME}_static STATIC ${LIB_DEPS}) | ||
target_compile_features(${LIB_NAME}_static PRIVATE cxx_std_11) | ||
- set_property(TARGET ${LIB_NAME}_shared PROPERTY CXX_STANDARD_REQUIRED ON) | ||
set_property(TARGET ${LIB_NAME}_static PROPERTY CXX_STANDARD_REQUIRED ON) | ||
adbc_configure_target(${LIB_NAME}_static) | ||
if(EXTRA_DEPS) | ||
add_dependencies(${LIB_NAME}_static ${EXTRA_DEPS}) | ||
diff --git a/cmake_modules/GoUtils.cmake b/cmake_modules/GoUtils.cmake | ||
index 085d46fef..5c0a043c5 100644 | ||
--- a/cmake_modules/GoUtils.cmake | ||
b/cmake_modules/GoUtils.cmake | ||
@@ -15,8 15,8 @@ | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
-find_program(GO_BIN "go" REQUIRED) | ||
-message(STATUS "Detecting Go executable: Found ${GO_BIN}") | ||
#find_program(GO_BIN "go" REQUIRED) | ||
#message(STATUS "Detecting Go executable: Found ${GO_BIN}") | ||
|
||
function(add_go_lib GO_MOD_DIR GO_LIBNAME) | ||
set(options) | ||
@@ -131,13 131,8 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME) | ||
add_custom_command(OUTPUT "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}" | ||
WORKING_DIRECTORY ${GO_MOD_DIR} | ||
DEPENDS ${ARG_SOURCES} | ||
- COMMAND ${CMAKE_COMMAND} -E env ${GO_ENV_VARS} ${GO_BIN} build | ||
- ${GO_BUILD_TAGS} "${GO_BUILD_FLAGS}" -o | ||
- ${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION} | ||
- -buildmode=c-shared ${GO_LDFLAGS} . | ||
- COMMAND ${CMAKE_COMMAND} -E remove -f | ||
- "${LIBOUT_SHARED}.${ADBC_SO_VERSION}.0.h" | ||
- COMMENT "Building Go Shared lib ${GO_LIBNAME}" | ||
COMMAND ${CMAKE_COMMAND} -E copy "${${GO_LIBNAME}_prebuilt}" "${LIBOUT_SHARED}.${ADBC_FULL_SO_VERSION}" | ||
COMMENT "Copying Go Shared lib ${GO_LIBNAME}" | ||
COMMAND_EXPAND_LISTS) | ||
|
||
add_custom_command(OUTPUT "${LIBOUT_SHARED}.${ADBC_SO_VERSION}" "${LIBOUT_SHARED}" | ||
@@ -226,11 221,8 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME) | ||
add_custom_command(OUTPUT "${LIBOUT_STATIC}" | ||
WORKING_DIRECTORY ${GO_MOD_DIR} | ||
DEPENDS ${ARG_SOURCES} | ||
- COMMAND ${CMAKE_COMMAND} -E env "${GO_ENV_VARS}" ${GO_BIN} build | ||
- "${GO_BUILD_TAGS}" -o "${LIBOUT_STATIC}" | ||
- -buildmode=c-archive "${GO_BUILD_FLAGS}" . | ||
- COMMAND ${CMAKE_COMMAND} -E remove -f "${LIBOUT_HEADER}" | ||
- COMMENT "Building Go Static lib ${GO_LIBNAME}" | ||
COMMAND ${CMAKE_COMMAND} -E copy "${${GO_LIBNAME}_prebuilt}" "${LIBOUT_STATIC}" | ||
COMMENT "Copying Go Static lib ${GO_LIBNAME}" | ||
COMMAND_EXPAND_LISTS) | ||
|
||
add_custom_target(${GO_LIBNAME}_static_target ALL DEPENDS "${LIBOUT_STATIC}") |
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,103 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
}: | ||
buildGoModule ({ | ||
pname = "arrow-adbc-go"; | ||
version = "1.3.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "apache"; | ||
repo = "arrow-adbc"; | ||
rev = "apache-arrow-adbc-15"; | ||
hash = "sha256-QRWVmUYNdMxQqe9dIBxcY8pY8aAbKIh3dhX3rzCGYI4="; | ||
}; | ||
|
||
sourceRoot = "source/go/adbc"; | ||
|
||
proxyVendor = true; | ||
|
||
vendorHash = "sha256- hUYaFvmySnz2rzDszejcwzoVoCe1lAoj8qNwfMEfp4="; | ||
|
||
postUnpack = '' | ||
rm -rf source/go/adbc/driver/flightsql/cmd | ||
rm -rf source/go/adbc/driver/bigquery | ||
rm -rf source/go/adbc/pkg/bigquery | ||
''; | ||
|
||
#subPackages = [ | ||
# "driver/snowflake/..." | ||
#]; | ||
|
||
tags = [ | ||
"driverlib" | ||
]; | ||
|
||
env = { | ||
GOBIN = "${placeholder "out"}/lib"; | ||
NIX_DEBUG = 3; | ||
}; | ||
|
||
#GOFLAGS = [ | ||
# "-shared" | ||
#]; | ||
|
||
ldflags = | ||
[ | ||
"-s" | ||
"-w" | ||
] | ||
(if stdenv.hostPlatform.isStatic then [ | ||
"-buildmode=c-archive" | ||
"-extar=${stdenv.cc.targetPrefix}ar" | ||
] else [ | ||
"-buildmode=c-shared" | ||
]); | ||
# [ "-buildmode=c-archive" ]; | ||
|
||
doCheck = false; | ||
|
||
postInstall = lib.optionalString stdenv.hostPlatform.isStatic '' | ||
for f in $out/lib/*; do | ||
mv $f $f.a | ||
chmod -x $f.a | ||
done | ||
''; | ||
|
||
meta = { | ||
description = "Database connectivity API standard and libraries for Apache Arrow"; | ||
homepage = "https://arrow.apache.org/adbc/"; | ||
license = lib.licenses.asl20; | ||
platforms = lib.platforms.unix; | ||
maintainers = [ lib.maintainers.tobim ]; | ||
}; | ||
} // lib.optionalAttrs (!stdenv.hostPlatform.isStatic) { | ||
buildPhase = '' | ||
runHook preBuild | ||
if [ -z "$enableParallelBuilding" ]; then | ||
export NIX_BUILD_CORES=1 | ||
fi | ||
cd pkg/snowflake | ||
go build -tags=driverlib -buildmode=c-shared -o snowflake.so -v -p $NIX_BUILD_CORES . | ||
runHook postBuild | ||
''; | ||
checkPhase = '' | ||
runHook preCheck | ||
go test -v -p $NIX_BUILD_CORES . | ||
runHook postCheck | ||
''; | ||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/lib | ||
cp snowflake.so $out/lib | ||
runHook postInstall | ||
''; | ||
}) |
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 |
---|---|---|
|
@@ -5,6 5,7 @@ | |
"packages" | ||
"pipeline-manager" | ||
"platform" | ||
"snowflake" | ||
"to_splunk" | ||
"vast" | ||
] |
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 |
---|---|---|
|
@@ -2,7 2,8 @@ | |
"name": "tenzir-plugins", | ||
"url": "[email protected]:tenzir/tenzir-plugins", | ||
"ref": "main", | ||
"rev": "3ce6627bebde90b702c724d9e2b1065522c983bb", | ||
"rev": "24902ba81e6d3635414e15c8caac0aa533aa39e3", | ||
"submodules": true, | ||
"shallow": true | ||
"shallow": true, | ||
"allRefs": true | ||
} |
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
Oops, something went wrong.