{"record":{"id":"d6bdc08fc6646f93","repo":"risingwavelabs/risingwave","slug":"unexpected-downstream-sql-server-type-sql-server","errorCode":null,"errorMessage":"unexpected downstream SQL Server type {sql_server_data_type} for Timestamptz","messagePattern":"unexpected downstream SQL Server type (.+?) for Timestamptz","errorType":"validation","errorClass":"SinkError::SqlServer","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/sqlserver.rs","lineNumber":910,"sourceCode":"                DataType::Variant => return Err(data_type_not_supported(\"Variant\")),\n                DataType::Serial => return Err(data_type_not_supported(\"Serial\")),\n                DataType::Int256 => return Err(data_type_not_supported(\"Int256\")),\n                DataType::Map(_) => return Err(data_type_not_supported(\"Map\")),\n                DataType::Vector(_) => return Err(data_type_not_supported(\"Vector\")),\n            },\n        };\n    }\n    Ok(())\n}\n\nfn data_type_not_supported(data_type_name: &str) -> SinkError {\n    SinkError::SqlServer(anyhow!(format!(\n        \"{data_type_name} is not supported in SQL Server\"\n    )))\n}\n\nfn unexpected_downstream_timestamptz_type(sql_server_data_type: &str) -> SinkError {\n    SinkError::SqlServer(anyhow!(format!(\n        \"unexpected downstream SQL Server type {sql_server_data_type} for Timestamptz\"\n    )))\n}\n\nfn check_data_type_compatibility(data_type: &DataType) -> Result<()> {\n    match data_type {\n        DataType::Boolean\n        | DataType::Int16\n        | DataType::Int32\n        | DataType::Int64\n        | DataType::Float32\n        | DataType::Float64\n        | DataType::Decimal\n        | DataType::Date\n        | DataType::Varchar\n        | DataType::Time\n        | DataType::Timestamp\n        | DataType::Timestamptz","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/sqlserver.rs#L892-L928","documentation":"When binding a Timestamptz parameter for the SQL Server sink, RisingWave inspects the downstream column's reported SQL Server type. If it is neither of the expected datetime types (datetimeoffset/datetime2 family), this error reports the actual downstream type string. It protects against silently writing timestamps with wrong precision or timezone semantics.","triggerScenarios":"`bind_params` on a Timestamptz column whose downstream SQL Server column type (from `query_sql_server_table_metadata`) is something unexpected — e.g. `datetime`, `smalldatetime`, `date`, or `varchar` — instead of the supported `datetimeoffset` type.","commonSituations":"Downstream table created manually with `DATETIME` (common legacy default); migrations downgraded a `DATETIMEOFFSET` column; sink pointed at an older schema created before the sink supported Timestamptz.","solutions":["Alter the downstream column to `DATETIMEOFFSET`: `ALTER TABLE <schema>.<table> ALTER COLUMN <col> DATETIMEOFFSET;`.","Recreate the target table with `DATETIMEOFFSET` for that column and restart the sink.","Alternatively change the RisingWave column's type to Timestamp (non-tz) if `DATETIME2` semantics are acceptable.","Check the reported type in the error message against the supported list in `bind_params` in src/connector/src/sink/sqlserver.rs."],"exampleFix":"-- before\nCREATE TABLE dbo.orders (created_at DATETIME);\n-- after\nALTER TABLE dbo.orders ALTER COLUMN created_at DATETIMEOFFSET;","handlingStrategy":"validation","validationCode":"-- ensure timestamp columns use DATETIMEOFFSET downstream\nSELECT c.name, ty.name AS type_name\nFROM sys.columns c\nJOIN sys.types ty ON ty.user_type_id = c.user_type_id\nWHERE ty.name NOT IN ('datetimeoffset') AND c.name LIKE '%time%';","typeGuard":null,"tryCatchPattern":"if let Err(e) = sink.validate().await {\n    if e.to_string().contains(\"for Timestamptz\") {\n        alter_downstream_to_datetimeoffset();\n    } else { return Err(e); }\n}","preventionTips":["Always use DATETIMEOFFSET for tz-aware columns in downstream DDL","Avoid legacy DATETIME defaults for new tables","Re-validate sinks after downstream type migrations"],"tags":["sqlserver","sink","timestamptz","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}