-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat(MLOP-1985): optional params #347
Changes from 3 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 |
---|---|---|
|
@@ -49,13 +49,22 @@ class Source(HookableComponent): | |
temporary views regarding each reader and, after, will run the | ||
desired query and return a dataframe. | ||
|
||
The `eager_evaluation` param forces Spark to apply the currently | ||
mapped changes to the DataFrame. When this parameter is set to | ||
False, Spark follows its standard behaviour of lazy evaluation. | ||
Lazy evaluation can improve Spark's performance as it allows | ||
Spark to build the best version of the execution plan. | ||
|
||
""" | ||
|
||
def __init__(self, readers: List[Reader], query: str) -> None: | ||
def __init__( | ||
self, readers: List[Reader], query: str = "", eager_evaluation: bool = True, | ||
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. By the docs, we have: "Lazy evaluation can improve Spark's performance as it allows Spark to build the best version of the execution plan.". Looks like that 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. Or is it 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. You're right, it's defaulted |
||
) -> None: | ||
super().__init__() | ||
self.enable_pre_hooks = False | ||
self.readers = readers | ||
self.query = query | ||
self.eager_evaluation = eager_evaluation | ||
|
||
def construct( | ||
self, client: SparkClient, start_date: str = None, end_date: str = None | ||
|
@@ -87,7 +96,7 @@ def construct( | |
|
||
dataframe = client.sql(self.query) | ||
|
||
if not dataframe.isStreaming: | ||
if not dataframe.isStreaming and self.eager_evaluation: | ||
dataframe.cache().count() | ||
|
||
post_hook_df = self.run_post_hooks(dataframe) | ||
|
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.
why did you add this empty string as default value?
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.
👀
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.
Fixed