Skip to content

Commit

Permalink
add snowflake_connector.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhseh committed Mar 7, 2024
1 parent e9da466 commit 805b6a2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/connector/src/sink/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub mod pulsar;
pub mod redis;
pub mod remote;
pub mod snowflake;
pub mod snowflake_connector;
pub mod starrocks;
pub mod test_sink;
pub mod trivial;
Expand Down
51 changes: 51 additions & 0 deletions src/connector/src/sink/snowflake_connector.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use http::request::Builder;
use hyper::body::{Body, Sender};
use hyper::client::HttpConnector;
use hyper::{body, Client, Request, StatusCode};
use hyper_tls::HttpsConnector;

use std::collections::HashMap;

use super::{Result, SinkError};

const SNOWFLAKE_HOST_ADDR: &str = "snowflakecomputing.com";
const SNOWFLAKE_REQUEST_ID: &str = "RW_SNOWFLAKE_SINK";

#[derive(Debug)]
pub struct SnowflakeInserterBuilder {
url: String,
header: HashMap<String, String>,
}

impl SnowflakeInserterBuilder {
pub fn new(account: String, db: String, schema: String, pipe: String, header: HashMap<String, String>) -> Self {
// TODO: ensure if we need user to *explicitly* provide the request id
let url = format!("https://{}.{}/v1/data/pipes/{}.{}.{}/insertFiles?request_id={}",
account,
SNOWFLAKE_HOST_ADDR,
db,
schema.
pipe,
SNOWFLAKE_REQUEST_ID);

Self {
url,
header,
}
}

fn build_request_and_client() -> (Builder, Client<HttpsConnector<HttpConnector>>) {

}

pub async fn build(&self) -> Result<SnowflakeInserter> {

}
}

#[derive(Debug)]
pub struct SnowflakeInserter {
sender: Option<Sender>,
join_handle: Option<JoinHandle<Result<Vec<u8>>,
buffer: BytesMut,
}

0 comments on commit 805b6a2

Please sign in to comment.