bigquery-derive: reject ambiguous and duplicate #[bigquery(...)] attributes at compile time
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- backend-api-design
Línea de trabajo
Start with src/bigquery-derive/src/lib.rs, especially get_field_name, derive_from_row_impl, and derive_from_sql_impl, then read the proc-macro guidance in doc/contributor/howto-guide-handwritten-client-api.md. Add unit tests there for duplicate resolved names, duplicate rename options across and within attributes, and unsupported container attributes; done when each case produces a spanned compile-time error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
google-cloud-bigquery-derive (#[derive(FromRow)] and #[derive(FromSql)]) silently accepts ambiguous and invalid #[bigquery(...)] attribute configurations instead of rejecting them with compile-time errors.
Because rejecting input that previously compiled is a breaking change to accepted macro input under the proc-macro compatibility policy (src/bigquery-derive/src/lib.rs), fixing these validation gaps before google-cloud-bigquery 1.0.0 is released (#7424) avoids requiring a major bump of google-cloud-bigquery later.
Problem Details
Per doc/contributor/howto-guide-handwritten-client-api.md:
Ambiguous input (for example, two fields mapping to the same property name after flattening) is an error, never resolved silently.
Currently in src/bigquery-derive/src/lib.rs:
- Duplicate target column /
STRUCTfield names compile silently and exhibit transport-dependent runtime behavior:derive_from_row_implandderive_from_sql_implresolve each named field's column/field name independently without checking for duplicates across the struct.- For example:
(or two fields both marked#[derive(FromRow)] struct AmbiguousRow { col: Option<String>, #[bigquery(rename = "col")] other: Option<String>, }#[bigquery(rename = "same")], orr#typecolliding with#[bigquery(rename = "type")]). - At runtime,
FromRowemits tworow.take("col")?calls:- On JSON-backed rows (
RowInner::Jsoninsrc/bigquery/src/query/row.rs), the firsttakereplaces cell"col"withSqlValueInner::Null, soothersilently receivesNone(or fails withConvertError::NotNullfor non-optional types). - On Arrow-backed rows (
RowInner::Arrowinsrc/bigquery/src/query/row.rs),takereads from theRecordBatchwithout mutating it, so bothcolandotherreceive"col"'s value.
- On JSON-backed rows (
FromSql(SqlValue::take) has the same discrepancy betweenSqlValueInner::Struct(replaces slot withNull) andSqlValueInner::Arrow(reads without mutating).
- Multiple
#[bigquery(...)]attributes on the same field short-circuit after the firstrename:- In
get_field_name(src/bigquery-derive/src/lib.rs),if let Some(name) = renamed { return Ok(name); }returns inside thefor attr in &field.attrsloop. - A second
#[bigquery(rename = "...")]on the same field is silently ignored instead of reporting a duplicaterenameerror, and a subsequent invalid attribute (e.g.,#[bigquery(rename = "a")] #[bigquery(typo = "b")]) is never parsed at all.
- In
- Duplicate
renameoptions inside a single attribute overwrite silently:#[bigquery(rename = "a", rename = "b")]overwritesrenamed = Some(lit.value())without checking ifrenamewas already specified, silently using"b".
- Container-level
#[bigquery(...)]attributes on structs are silently ignored:- Neither
derive_from_row_implnorderive_from_sql_implinspectsinput.attrs, so unsupported container attributes such as#[bigquery(rename_all = "camelCase")]on a struct compile without error and have no effect.
- Neither
Expected Behavior
- Reject structs where two or more fields resolve to the same BigQuery column /
STRUCTfield name with a spannedsyn::Error. - Inspect all
#[bigquery(...)]attributes on every field and reject duplicaterenameoptions (whether in one#[bigquery(rename = "a", rename = "b")]list or across multiple#[bigquery(...)]attributes on the same field). - Reject
#[bigquery(...)]attributes placed on the container (struct/enum/union) itself until/unless container options are explicitly supported. - Add unit tests in
src/bigquery-derive/src/lib.rscovering each error case, and take a breaking version bump ongoogle-cloud-bigquery-deriveif needed per the compatibility policy.
- Lenguaje dominante
- Rust
- Estrellas
- 972
- Forks
- 163
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 176
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de googleapis/google-cloud-rust
-
Upgrade MSRV to 1.92.0Abiertotype: process
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
googleapis/google-cloud-rust#7466 ·
Los mantenedores suelen responder en 1 día
-
Upgrade Rust toolchain to 1.100Abiertotype: process
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
googleapis/google-cloud-rust#7465 ·
Los mantenedores suelen responder en 1 día
-
api: storage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
googleapis/google-cloud-rust#7344 ·
Los mantenedores suelen responder en 1 día
-
BytesValue in Any rejects unpadded and URL-safe base64Posiblemente ocupada @akasakariko la tomó hace 19 días. Abiertopriority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
googleapis/google-cloud-rust#6714 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
type: bug
Dificultad 2/5 Medio día Aptitud para principiantes 75/100
googleapis/google-cloud-rust#6710 ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/google-cloud-rust
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
obi1kenobi/cargo-semver-checks#1814 ·
Los mantenedores suelen responder en 1 día
-
community differential help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
hffgzktbcc-blip/ounce-core#489 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add support for TODO for AIAbiertoneeds triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pbakaus/impeccable#1560 ·
Los mantenedores suelen responder en 1 día
-
Links broken in documentationAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
pact-foundation/pact-plugins#125 ·