-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add override_columns to openapi transformer #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| from typing import Dict, List | ||||||
| from typing import Dict, List, Optional | ||||||
| import pyarrow as pa | ||||||
| from cloudquery.sdk.types import JSONType | ||||||
| from cloudquery.sdk.schema import Column | ||||||
|
|
@@ -24,11 +24,24 @@ def oapi_type_to_arrow_type(field) -> pa.DataType: | |||||
| return pa.string() | ||||||
|
|
||||||
|
|
||||||
| def oapi_definition_to_columns(definition: Dict) -> List[Column]: | ||||||
| def get_column_by_name(columns: List[Column], name: str) -> Optional[Column]: | ||||||
| for column in columns: | ||||||
| if column.name == name: | ||||||
| return column | ||||||
| return None | ||||||
|
|
||||||
|
|
||||||
| def oapi_definition_to_columns(definition: Dict, override_columns=[]) -> List[Column]: | ||||||
| columns = [] | ||||||
| for key, value in definition["properties"].items(): | ||||||
| column_type = oapi_type_to_arrow_type(value) | ||||||
| columns.append( | ||||||
| Column(name=key, type=column_type, description=value.get("description")) | ||||||
| column = Column( | ||||||
| name=key, type=column_type, description=value.get("description") | ||||||
| ) | ||||||
| override_column = get_column_by_name(override_columns, key) | ||||||
| if override_column is not None: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think better
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. false would be falsy, also it's either a |
||||||
| column.type = override_column.type | ||||||
| column.primary_key = override_column.primary_key | ||||||
| column.unique = override_column.unique | ||||||
| columns.append(column) | ||||||
| return columns | ||||||
Uh oh!
There was an error while loading. Please reload this page.