Type a raw row-value token against its column into an owned [`Cell`]. The bare token `null` is SQL `NULL` (only in a nullable column); quote it (`"null"`) for the literal string. Numeric and boolean tokens go through [`mz_repr::strconv`] — the canonical PostgreSQL-compatible text parser the rest of the codebase uses — so the accepted syntax matches `mz_pgrepr`'s text decode. `string`/`bytes` colu
(token: &str, col: &SqlColumnType)
| 234 | /// `string`/`bytes` columns take the (unquoted) token verbatim; `bytes` is its |
| 235 | /// UTF-8 encoding. |
| 236 | fn cell_from_token(token: &str, col: &SqlColumnType) -> anyhow::Result<Cell> { |
| 237 | if token == "null" { |
| 238 | anyhow::ensure!(col.nullable, "null value in non-nullable column"); |
| 239 | return Ok(Cell::Null); |
| 240 | } |
| 241 | let parse = |
| 242 | |kind: &str, e: strconv::ParseError| anyhow::anyhow!("parsing {token:?} as {kind}: {e}"); |
| 243 | let cell = match col.scalar_type { |
| 244 | SqlScalarType::Int16 => { |
| 245 | Cell::Int16(strconv::parse_int16(token).map_err(|e| parse("int16", e))?) |
| 246 | } |
| 247 | SqlScalarType::Int32 => { |
| 248 | Cell::Int32(strconv::parse_int32(token).map_err(|e| parse("int32", e))?) |
| 249 | } |
| 250 | SqlScalarType::Int64 => { |
| 251 | Cell::Int64(strconv::parse_int64(token).map_err(|e| parse("int64", e))?) |
| 252 | } |
| 253 | SqlScalarType::Bool => { |
| 254 | Cell::Bool(strconv::parse_bool(token).map_err(|e| parse("bool", e))?) |
| 255 | } |
| 256 | SqlScalarType::String => Cell::Str(unquote(token).to_string()), |
| 257 | SqlScalarType::Bytes => Cell::Bytes(unquote(token).as_bytes().to_vec()), |
| 258 | ref other => anyhow::bail!("unsupported column type {other:?}"), |
| 259 | }; |
| 260 | Ok(cell) |
| 261 | } |
| 262 | |
| 263 | /// Pack explicit row tokens against `desc`, validating arity per row. |
| 264 | fn rows_from_tokens(desc: &RelationDesc, rows: &[Vec<String>]) -> anyhow::Result<Vec<Row>> { |
no test coverage detected