allthingssecurity opened a new pull request, #27343:
URL: https://github.com/apache/camel/pull/27343

   # Description
   
   [CAMEL-25302](https://issues.apache.org/jira/browse/CAMEL-25302)
   
   `google-sheets:application-x-struct` (used by the google-sheets Kamelets) 
maps the columns of a range to JSON property names; the custom `columnNames` 
"map to cell coordinates based on their position". 
`CellCoordinate.getColumnName(columnIndex, columnStartIndex, names)` used 
`columnIndex % columnStartIndex` as the position, which is right only for 
ranges starting at column A:
   
   - range `B2:D3` with `name,age,city`: every column is named `name`, so a 
read row is `{"name":"Oslo"}` and a written row 
`{"name":"Ann","age":31,"city":"Oslo"}` becomes `[Ann, Ann, Ann]`;
   - range `C1:E1` with `name,age`: `name, age, name` instead of `name, age, E`.
   
   Also the A1 column letters were wrong from three letters on: `AAA` was read 
as 52 instead of 702, and `getColumnName(702)` threw 
`ArrayIndexOutOfBoundsException`.
   
   This change uses `columnIndex - columnStartIndex` as the position and 
computes column letters in bijective base 26 in both directions. Ranges 
starting at column A, and columns up to `ZZ`, give the same names as before.
   
   The output changes only where it repeated a name inside the range (for a 
range starting at column `s > 0` the old and new names can differ only from 
column `2s` on, and there the old code gave columns `s` and `2s` the same 
name), so no upgrade note. With the default `columnNames` (`A`, set by the 
Kamelets) the first column of the range is still named `A`, as before (a single 
column range `B:B` keeps working unchanged); the other columns now keep their 
A1 name instead of all being named `A`.
   
   Tests:
   - `GoogleSheetsJsonStructDataTypeTransformerTest`: three new tests (read of 
`B2:D3`, split read of `C1:E1`, write of `B1:D1`).
   - new `CellCoordinateTest`: names by position for ranges starting at A, B 
and C (and the default names `A` for a range starting at B); three-letter 
columns; name/index round trip for all columns up to `ZZZ`; a control for one 
and two letters.
   - Without the change 6 of the new tests fail (2 runs), the control passes; 
with it the module passes (33 tests).
   
   Found with a Lean 4 model of the name lookup and the column arithmetic: "the 
k-th column gets the k-th name" fails for every row of a range starting at B 
(all columns get the first name) and is proved for the fix for every start 
column; "column index and name are inverse" fails for every three-letter column 
and is proved for the fix for every column.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the affected module, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to