Skip to content

Conversation

@mbrobbel
Copy link
Member

@mbrobbel mbrobbel commented Oct 1, 2024

This PR adds the adbc_snowflake crate to the Rust workspace. This crate provides a Snowflake ADBC driver for Rust by wrapping the Go driver, loaded by the Rust driver manager implementation. The build.rs script builds the Go driver and links it statically.

  • Add methods to the wrapper structs to handle Snowflake specific configurations
  • Add a feature to support loading the Go driver dynamically
  • Docs
  • Tests

Comment on lines +35 to +56
type Option = OptionConnection;

fn set_option(&mut self, key: Self::Option, value: OptionValue) -> Result<()> {
self.0.set_option(key, value)
}

fn get_option_string(&self, key: Self::Option) -> Result<String> {
self.0.get_option_string(key)
}

fn get_option_bytes(&self, key: Self::Option) -> Result<Vec<u8>> {
self.0.get_option_bytes(key)
}

fn get_option_int(&self, key: Self::Option) -> Result<i64> {
self.0.get_option_int(key)
}

fn get_option_double(&self, key: Self::Option) -> Result<f64> {
self.0.get_option_double(key)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar enough with Rust, but can't these just be inherited somehow from a base type instead of having to implement them here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should be using traits for this. Discussed before here: #1725 (comment).

I'll try to put up a PR to change these option structs to traits following the proposal in #1725 (comment).

@mbrobbel mbrobbel marked this pull request as ready for review November 21, 2024 10:09
@mbrobbel
Copy link
Member Author

Marking this ready for review. This already a big PR so maybe it's better to get some feedback now, and add more tests and docs in follow-up PRs.

@github-actions github-actions bot added this to the ADBC Libraries 16 milestone Nov 21, 2024
let _ = dotenvy::dotenv();

let use_high_precision = env::var(Self::USE_HIGH_PRECISION_ENV)
.ok()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it make more sense to report errors and return Result<Self>?

@lidavidm
Copy link
Member

I re-ran CI. I'll merge this for now. Thanks @mbrobbel!

@lidavidm lidavidm merged commit 8de65c8 into apache:main Nov 22, 2024
29 of 30 checks passed
@mbrobbel mbrobbel deleted the rust/snowflake branch November 22, 2024 15:12
lidavidm pushed a commit that referenced this pull request Nov 25, 2024
…nv` when parsing fails (#2334)

As suggested in
#2207 (comment)
the `Builder::from_env` methods should return a result when parsing
fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants