Skip to content

Conversation

knassre-bodo
Copy link
Contributor

Resolves #421.

@knassre-bodo knassre-bodo requested review from a team, hadia206, john-sanchez31 and juankx-bodo and removed request for a team September 15, 2025 17:45
@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)
Copy link
Contributor Author

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

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,
Copy link
Contributor

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?

Copy link
Contributor

@john-sanchez31 john-sanchez31 left a 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
Copy link
Contributor

@john-sanchez31 john-sanchez31 Sep 17, 2025

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`).
Copy link
Contributor

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.

Suggested change
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`).

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.

Allow a session to be passed in as a keyword argument to to_sql and to_df
3 participants