File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
cloudquery/sdk/transformers Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 1- from typing import Dict , List
1+ from typing import Dict , List , Optional
22import pyarrow as pa
33from cloudquery .sdk .types import JSONType
44from cloudquery .sdk .schema import Column
@@ -24,11 +24,24 @@ def oapi_type_to_arrow_type(field) -> pa.DataType:
2424 return pa .string ()
2525
2626
27- def oapi_definition_to_columns (definition : Dict ) -> List [Column ]:
27+ def get_column_by_name (columns : List [Column ], name : str ) -> Optional [Column ]:
28+ for column in columns :
29+ if column .name == name :
30+ return column
31+ return None
32+
33+
34+ def oapi_definition_to_columns (definition : Dict , override_columns = []) -> List [Column ]:
2835 columns = []
2936 for key , value in definition ["properties" ].items ():
3037 column_type = oapi_type_to_arrow_type (value )
31- columns . append (
32- Column ( name = key , type = column_type , description = value .get ("description" ) )
38+ column = Column (
39+ name = key , type = column_type , description = value .get ("description" )
3340 )
41+ override_column = get_column_by_name (override_columns , key )
42+ if override_column is not None :
43+ column .type = override_column .type
44+ column .primary_key = override_column .primary_key
45+ column .unique = override_column .unique
46+ columns .append (column )
3447 return columns
You can’t perform that action at this time.
0 commit comments