(tree *pg_query.ParseResult, result *Result)
| 90 | } |
| 91 | |
| 92 | func (t *TypeMappingTransform) Transform(tree *pg_query.ParseResult, result *Result) (bool, error) { |
| 93 | changed := false |
| 94 | |
| 95 | WalkFunc(tree, func(node *pg_query.Node) bool { |
| 96 | switch n := node.Node.(type) { |
| 97 | case *pg_query.Node_TypeCast: |
| 98 | if n.TypeCast != nil && n.TypeCast.TypeName != nil { |
| 99 | if t.transformTypeName(n.TypeCast.TypeName) { |
| 100 | changed = true |
| 101 | } |
| 102 | } |
| 103 | case *pg_query.Node_ColumnDef: |
| 104 | if n.ColumnDef != nil && n.ColumnDef.TypeName != nil { |
| 105 | if t.transformTypeName(n.ColumnDef.TypeName) { |
| 106 | changed = true |
| 107 | } |
| 108 | } |
| 109 | case *pg_query.Node_FuncCall: |
| 110 | // CAST function calls have type as second argument |
| 111 | // but are handled differently in the AST (via TypeCast nodes) |
| 112 | // so no action needed here |
| 113 | } |
| 114 | return true |
| 115 | }) |
| 116 | |
| 117 | return changed, nil |
| 118 | } |
| 119 | |
| 120 | // transformTypeName converts PostgreSQL type names to DuckDB equivalents |
| 121 | func (t *TypeMappingTransform) transformTypeName(typeName *pg_query.TypeName) bool { |
nothing calls this directly
no test coverage detected