hansva opened a new issue, #9559:
URL: https://github.com/apache/hop/issues/9559

   ### Apache Hop version?
   
   2.20.0
   
   ### Java version?
   
   21
   
   ### Operating system
   
   Other
   
   ### What happened?
   
   `ValueMetaGraph` (the Neo4j plugin's *Graph* value type) doesn't override 
`convertData`. `ValueMetaBase.convertData` only knows Hop's built-in types, so 
converting any value into a Graph field throws:
   
       <field> Graph : can't be converted to type 309
   
   This also happens for the two conversions that should just work:
   
   - **Text holding a graph as JSON:** `ValueMetaGraph.getString` writes a 
graph as JSON, and `getGraphData` can already read that JSON back when the 
field's own type is String. But a conversion from a String field to a Graph 
field doesn't use it.
   - **Graph to Graph.**
   
   ### How to reproduce
   
   1. A pipeline with a String field holding a graph's JSON, for example the 
output of a Graph field written to text and read back, or a JSON column from a 
database.
   2. *Select values*, *Meta-data* tab: change the field's type to Graph.
   3. Run: the transform fails with the error above.
   
   Any engine or transform that hands Graph values over as text and converts 
them back runs into the same error. For example, Neo4j Load / Graph Output 
receive a String where they expect a graph.
   
   ### Expected
   
   - A String value holding a graph's JSON (as `getString` writes it) converts 
to that graph. Empty or null text converts to null.
   - A Graph value converts to a copy of itself.
   - Text that isn't valid graph JSON fails with an error that says so and 
shows the text.
   - Other types still fail with a clear "can't convert to a graph" error.
   
   ### Proposed fix
   
   Override `convertData(IValueMeta, Object)` in `ValueMetaGraph`:
   
   - null → null;
   - Graph → `new GraphData(GraphData)`;
   - String → `new GraphData(json)`, with empty text → null;
   - anything else → `HopValueException`.
   
   ### Tests
   
   `ValueMetaGraphTest`: a graph written with `getString` and converted back 
from a String field equals the original (nodes, relationships, properties). 
Graph → Graph gives an equal copy. Null and empty text give null. Invalid JSON 
and a non-string type throw a `HopValueException`.
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: API


-- 
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