-
Notifications
You must be signed in to change notification settings - Fork 193
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
add mark function to emit resource hints from decorated function #938
Conversation
✅ Deploy Preview for dlt-hub-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
validator: ValidateItem | ||
original_columns: TTableHintTemplate[TAnySchemaColumns] | ||
|
||
|
||
class HintsMeta: | ||
__slots__ = "hints" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i never heard of this before, this is purely here for performance reasons, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is performance. instead of creating and maintaining dict, class have slots (and its fields are frozen). almost as good as tuple
dlt/extract/hints.py
Outdated
@@ -176,7 +232,12 @@ def apply_hints( | |||
# normalize columns | |||
columns = ensure_table_schema_columns(columns) | |||
# this updates all columns with defaults | |||
print("PREV") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev code
@@ -202,8 +263,13 @@ def apply_hints( | |||
) | |||
if schema_contract is not None: | |||
t["schema_contract"] = schema_contract | |||
if table_format is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kind of unrelated, but what about a utility function that does all of the table_format updating (and all other props that behave the same way) in one line? this makes it all more readable and you can also use it in make_hints (although the popping part is not needed there really)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean code refactor? yeah maybe there's time to do that. I'll merge this as it is though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a small note in the docs somewhere?
Description
dlt.mark.with_hints
which allow to create/update resource hints from within decorated function. allows lazy creation of table schema during extract process