Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(connector): add comment for BigQuery field type mapping #17820

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/connector/src/sink/big_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ impl BigQuerySink {
Ok(())
}

// Used to check whether the BigQuery table field is equal to RisingWave.
jetjinser marked this conversation as resolved.
Show resolved Hide resolved
fn get_string_and_check_support_from_datatype(rw_data_type: &DataType) -> Result<String> {
match rw_data_type {
DataType::Boolean => Ok("BOOL".to_owned()),
Expand All @@ -241,6 +242,9 @@ impl BigQuerySink {
DataType::Time => Ok("TIME".to_owned()),
DataType::Timestamp => Ok("DATETIME".to_owned()),
DataType::Timestamptz => Ok("TIMESTAMP".to_owned()),
// Even if Interval is an Pre-GA type,
// if the BigQuery table column is indeed of this type,
// we have no reason to reject it.
DataType::Interval => Ok("INTERVAL".to_owned()),
DataType::Struct(structs) => {
let mut elements_vec = vec![];
Expand All @@ -264,6 +268,8 @@ impl BigQuerySink {
}
}

// Mapping from RisingWave field `DataType`s to BigQuery `TableFieldSchema` types.
// For creating BigQuery table from RisingWave table.
jetjinser marked this conversation as resolved.
Show resolved Hide resolved
fn map_field(rw_field: &Field) -> Result<TableFieldSchema> {
let tfs = match &rw_field.data_type {
DataType::Boolean => TableFieldSchema::bool(&rw_field.name),
Expand All @@ -282,6 +288,8 @@ impl BigQuerySink {
DataType::Time => TableFieldSchema::time(&rw_field.name),
DataType::Timestamp => TableFieldSchema::date_time(&rw_field.name),
DataType::Timestamptz => TableFieldSchema::timestamp(&rw_field.name),
// The Interval type is Pre-GA, so we refuse to map it.
// see: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#interval_type
DataType::Interval => {
return Err(SinkError::BigQuery(anyhow::anyhow!(
"Bigquery cannot support Interval"
Expand Down
Loading