-
Notifications
You must be signed in to change notification settings - Fork 3
Add a session
keyword argument to to_sql
and to_df
#427
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
base: main
Are you sure you want to change the base?
Conversation
… graph/config with the session in most places
@pytest.fixture(scope="module") | ||
def sqlglot_relational_visitor() -> SQLGlotRelationalVisitor: | ||
config: PyDoughConfigs = PyDoughConfigs() | ||
return SQLGlotRelationalVisitor(DatabaseDialect.SQLITE, config) | ||
@pytest.fixture | ||
def sqlglot_relational_visitor(empty_sqlite_tpch_session) -> SQLGlotRelationalVisitor: | ||
return SQLGlotRelationalVisitor(empty_sqlite_tpch_session) |
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.
Can no longer be module-level since we depend on empty_sqlite_tpch_session
raise PyDoughSessionException( | ||
f"Expected `session` to be a PyDoughSession, got {session.__class__.__name__}." | ||
) | ||
if session.metadata is 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.
We are only checking for metadata
. Should we check also for session.config
and session.database
?
Could we build new_session
from session
in kwargs
if it exists, then if metadata, config or database are provided we overwrite them in new_session
and finally if any of them is null in new_session
then we set that value with its value in active_session
.
@@ -1317,6 +1318,7 @@ def test_unqualified_node_exploration( | |||
], | |||
verbose: bool, | |||
get_sample_graph: graph_fetcher, |
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.
Should we provide the graph as part of the session?
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.
Good job! Just a couple of comments below
FROM main.customer AS customer | ||
JOIN _s1 AS _s1 | ||
ON _s1.o_custkey = customer.c_custkey | ||
ORDER BY | ||
total DESC | ||
3 DESC |
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 these queries change?
@@ -1022,7 +1006,8 @@ The `explain` API is limited in that it can only be called on complete PyDough c | |||
|
|||
To handle cases where you need to learn about a term within a collection, you can use the `explain_term` API. The first argument to `explain_term` is PyDough code for a collection, which can have `explain` called on it, and the second is PyDough code for a term that can be evaluated within the context of that collection (e.g. a scalar term of the collection, or one of its sub-collections). | |||
|
|||
The `explain_term` API also has a `verbose` keyword argument (default False) to specify whether to include a more detailed explanation, as opposed to a more compact summary. | |||
The `explain_term` API also has a `verbose` keyword argument (default False) to specify whether to include a more detailed explanation, as opposed to a more compact summary. The `explain_term` API also has an optional `verbose` argument (default=False) that enables displaying additional information. It also has an optional `session` argument to specify what configs etc. to use when explaining certain terms (if not provided, uses `pydough.active_session`). |
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.
Lets rephrase this so we don't use also has an optional argument
twice.
The `explain_term` API also has a `verbose` keyword argument (default False) to specify whether to include a more detailed explanation, as opposed to a more compact summary. The `explain_term` API also has an optional `verbose` argument (default=False) that enables displaying additional information. It also has an optional `session` argument to specify what configs etc. to use when explaining certain terms (if not provided, uses `pydough.active_session`). | |
The `explain_term` API also has a `verbose` keyword argument (default False) to specify whether to include a more detailed explanation, as opposed to a more compact summary. The `explain_term` API also has some optional arguments. The `verbose` argument (default=False) that enables displaying additional information and the `session` argument to specify what configs etc. to use when explaining certain terms (if not provided, uses `pydough.active_session`). |
Resolves #421.