joellubi commented on code in PR #1456:
URL: https://github.com/apache/arrow-adbc/pull/1456#discussion_r1460711862


##########
go/adbc/driver/snowflake/bulk_ingestion.go:
##########
@@ -0,0 +1,546 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package snowflake
+
+import (
+       "bytes"
+       "compress/flate"
+       "context"
+       "database/sql"
+       "database/sql/driver"
+       "errors"
+       "fmt"
+       "io"
+       "runtime"
+       "strings"
+       "sync"
+
+       "github.com/apache/arrow-adbc/go/adbc"
+       "github.com/apache/arrow/go/v14/arrow"
+       "github.com/apache/arrow/go/v14/arrow/array"
+       "github.com/apache/arrow/go/v14/arrow/memory"
+       "github.com/apache/arrow/go/v14/parquet"
+       "github.com/apache/arrow/go/v14/parquet/compress"
+       "github.com/apache/arrow/go/v14/parquet/pqarrow"
+       "github.com/snowflakedb/gosnowflake"
+       "golang.org/x/sync/errgroup"
+)
+
+const (
+       bindStageName            = "ADBC$BIND"
+       createTemporaryStageStmt = "CREATE OR REPLACE TEMPORARY STAGE " + 
bindStageName + " FILE_FORMAT = (TYPE = PARQUET USE_LOGICAL_TYPE = TRUE 
BINARY_AS_TEXT = FALSE)"
+       putQueryTmpl             = "PUT 'file:///tmp/placeholder/%s' @" + 
bindStageName + " OVERWRITE = TRUE"
+       copyQuery                = "COPY INTO IDENTIFIER(?) FROM @" + 
bindStageName + " MATCH_BY_COLUMN_NAME = CASE_INSENSITIVE"
+       countQuery               = "SELECT COUNT(*) FROM IDENTIFIER(?)"
+       megabyte                 = 1024 * 1024
+)
+
+var (
+       defaultTargetFileSize    = 10 * megabyte
+       defaultWriterConcurrency = runtime.NumCPU()
+       defaultUploadConcurrency = 8
+       defaultCopyConcurrency   = 4
+       defaultCompressionCodec  = compress.Codecs.Snappy
+       defaultCompressionLevel  = flate.DefaultCompression
+)
+
+// Options for configuring bulk ingestion.
+//
+// Values should be updated with appropriate calls to stmt.SetOption().
+type ingestOptions struct {
+       // Approximate size of Parquet files written during ingestion.
+       //
+       // Actual size will be slightly larger, depending on size of 
footer/metadata.
+       // Default is 10 MB. Must be an integer > 0.
+       targetFileSize int
+       // Number of Parquet files to write in parallel.
+       //
+       // Default attempts to maximize workers based on logical cores 
detected, but
+       // may need to be adjusted if running in a constrained environment. 
Must be an integer > 0.
+       writerConcurrency int
+       // Number of Parquet files to upload in parallel.
+       //
+       // Greater concurrency can smooth out TCP congestion and help make use 
of
+       // available network bandwith, but will increase memory utilization.
+       // Default is 8. Must be an integer > 0.

Review Comment:
   Updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to