Skip to content
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

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

rudolfix
Copy link
Collaborator

@rudolfix rudolfix commented Feb 6, 2024

Description

  1. adds dlt.mark.with_hints which allow to create/update resource hints from within decorated function. allows lazy creation of table schema during extract process
  2. allows several current functions: to get source instance and resource name from within decorated function

Copy link

netlify bot commented Feb 6, 2024

Deploy Preview for dlt-hub-docs ready!

Name Link
🔨 Latest commit dd1af51
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/65c36c20b64bf900088e5960
😎 Deploy Preview https://deploy-preview-938--dlt-hub-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

validator: ValidateItem
original_columns: TTableHintTemplate[TAnySchemaColumns]


class HintsMeta:
__slots__ = "hints"
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

@@ -176,7 +232,12 @@ def apply_hints(
# normalize columns
columns = ensure_table_schema_columns(columns)
# this updates all columns with defaults
print("PREV")
Copy link
Collaborator

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:
Copy link
Collaborator

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)

Copy link
Collaborator Author

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

Copy link
Collaborator

@sh-rp sh-rp left a 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?

@rudolfix rudolfix merged commit f04032d into devel Feb 7, 2024
57 of 59 checks passed
@rudolfix rudolfix deleted the rfix/mark_hints branch February 7, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants