@@ -99,6 +99,8 @@ type UserConfig struct {
9999 RetryWaitMax time.Duration
100100 RetryMax int
101101 Transport http.RoundTripper
102+ UseLz4Compression bool
103+ CloudFetchConfig
102104}
103105
104106// DeepCopy returns a true deep copy of UserConfig
@@ -138,6 +140,8 @@ func (ucfg UserConfig) DeepCopy() UserConfig {
138140 RetryWaitMax : ucfg .RetryWaitMax ,
139141 RetryMax : ucfg .RetryMax ,
140142 Transport : ucfg .Transport ,
143+ UseLz4Compression : ucfg .UseLz4Compression ,
144+ CloudFetchConfig : ucfg .CloudFetchConfig ,
141145 }
142146}
143147
@@ -170,6 +174,8 @@ func (ucfg UserConfig) WithDefaults() UserConfig {
170174 if ucfg .RetryWaitMax == 0 {
171175 ucfg .RetryWaitMax = 30 * time .Second
172176 }
177+ ucfg .UseLz4Compression = false
178+ ucfg .CloudFetchConfig = CloudFetchConfig {}.WithDefaults ()
173179
174180 return ucfg
175181}
@@ -194,7 +200,7 @@ func WithDefaults() *Config {
194200
195201}
196202
197- // ParseDSN constructs UserConfig by parsing DSN string supplied to `sql.Open()`
203+ // ParseDSN constructs UserConfig and CloudFetchConfig by parsing DSN string supplied to `sql.Open()`
198204func ParseDSN (dsn string ) (UserConfig , error ) {
199205 fullDSN := dsn
200206 if ! strings .HasPrefix (dsn , "https://" ) && ! strings .HasPrefix (dsn , "http://" ) {
@@ -266,6 +272,25 @@ func ParseDSN(dsn string) (UserConfig, error) {
266272 ucfg .Schema = params .Get ("schema" )
267273 params .Del ("schema" )
268274 }
275+
276+ // Cloud Fetch parameters
277+ if params .Has ("useCloudFetch" ) {
278+ useCloudFetch , err := strconv .ParseBool (params .Get ("useCloudFetch" ))
279+ if err != nil {
280+ return UserConfig {}, dbsqlerrint .NewRequestError (context .TODO (), dbsqlerr .InvalidDSNFormat ("useCloudFetch" , params .Get ("useCloudFetch" ), "bool" ), err )
281+ }
282+ ucfg .UseCloudFetch = useCloudFetch
283+ }
284+ params .Del ("useCloudFetch" )
285+ if params .Has ("maxDownloadThreads" ) {
286+ numThreads , err := strconv .Atoi (params .Get ("maxDownloadThreads" ))
287+ if err != nil {
288+ return UserConfig {}, dbsqlerrint .NewRequestError (context .TODO (), dbsqlerr .InvalidDSNFormat ("maxDownloadThreads" , params .Get ("maxDownloadThreads" ), "int" ), err )
289+ }
290+ ucfg .MaxDownloadThreads = numThreads
291+ }
292+ params .Del ("maxDownloadThreads" )
293+
269294 for k := range params {
270295 if strings .ToLower (k ) == "timezone" {
271296 ucfg .Location , err = time .LoadLocation (params .Get ("timezone" ))
@@ -310,3 +335,37 @@ func (arrowConfig ArrowConfig) DeepCopy() ArrowConfig {
310335 UseArrowNativeIntervalTypes : arrowConfig .UseArrowNativeIntervalTypes ,
311336 }
312337}
338+
339+ type CloudFetchConfig struct {
340+ UseCloudFetch bool
341+ MaxDownloadThreads int
342+ MaxFilesInMemory int
343+ MinTimeToExpiry time.Duration
344+ }
345+
346+ func (cfg CloudFetchConfig ) WithDefaults () CloudFetchConfig {
347+ cfg .UseCloudFetch = false
348+
349+ if cfg .MaxDownloadThreads <= 0 {
350+ cfg .MaxDownloadThreads = 10
351+ }
352+
353+ if cfg .MaxFilesInMemory < 1 {
354+ cfg .MaxFilesInMemory = 10
355+ }
356+
357+ if cfg .MinTimeToExpiry < 0 {
358+ cfg .MinTimeToExpiry = 0 * time .Second
359+ }
360+
361+ return cfg
362+ }
363+
364+ func (cfg CloudFetchConfig ) DeepCopy () CloudFetchConfig {
365+ return CloudFetchConfig {
366+ UseCloudFetch : cfg .UseCloudFetch ,
367+ MaxDownloadThreads : cfg .MaxDownloadThreads ,
368+ MaxFilesInMemory : cfg .MaxFilesInMemory ,
369+ MinTimeToExpiry : cfg .MinTimeToExpiry ,
370+ }
371+ }
0 commit comments