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

fix(sink): fix starrocks sink array check #15471

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions integration_tests/starrocks-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Run the following queries to create database and table. You also use other starr
CREATE database demo;
use demo;

CREATE table demo_bhv_table(
CREATE table upsert_table(
user_id int,
target_id text,
event_timestamp_local datetime
Expand All @@ -46,5 +46,5 @@ We only support `upsert` with starrocks' `PRIMARY KEY`

Run the following query
```sql
select user_id, count(*) from demo.demo_bhv_table group by user_id;
select user_id, count(*) from demo.upsert_table group by user_id;
```
14 changes: 9 additions & 5 deletions src/connector/src/sink/starrocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl StarrocksSink {
i.name
))
})?;
if !Self::check_and_correct_column_type(&i.data_type, value.to_string())? {
if !Self::check_and_correct_column_type(&i.data_type, value)? {
return Err(SinkError::Starrocks(format!(
"Column type don't match, column name is {:?}. starrocks type is {:?} risingwave type is {:?} ",i.name,value,i.data_type
)));
Expand All @@ -150,7 +150,7 @@ impl StarrocksSink {

fn check_and_correct_column_type(
rw_data_type: &DataType,
starrocks_data_type: String,
starrocks_data_type: &String,
) -> Result<bool> {
match rw_data_type {
risingwave_common::types::DataType::Boolean => {
Expand Down Expand Up @@ -186,12 +186,16 @@ impl StarrocksSink {
risingwave_common::types::DataType::Interval => Err(SinkError::Starrocks(
"INTERVAL is not supported for Starrocks sink. Please convert to VARCHAR or other supported types.".to_string(),
)),
// todo! Validate the type struct and list
risingwave_common::types::DataType::Struct(_) => Err(SinkError::Starrocks(
"STRUCT is not supported for Starrocks sink.".to_string(),
)),
risingwave_common::types::DataType::List(_) => {
Ok(starrocks_data_type.contains("unknown"))
risingwave_common::types::DataType::List(list) => {
// For compatibility with older versions starrocks
if starrocks_data_type.contains("unknown") {
return Ok(true);
}
let check_result = Self::check_and_correct_column_type(list.as_ref(), starrocks_data_type)?;
Ok(check_result && starrocks_data_type.contains("array"))
}
risingwave_common::types::DataType::Bytea => Err(SinkError::Starrocks(
"BYTEA is not supported for Starrocks sink. Please convert to VARCHAR or other supported types.".to_string(),
Expand Down
Loading