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

[CT-3017] [Feature] Support show of python model #8467

Open
3 tasks done
ChenyuLInx opened this issue Aug 22, 2023 · 2 comments
Open
3 tasks done

[CT-3017] [Feature] Support show of python model #8467

ChenyuLInx opened this issue Aug 22, 2023 · 2 comments
Labels
enhancement New feature or request Refinement Maintainer input needed stale Issues that have gone stale

Comments

@ChenyuLInx
Copy link
Contributor

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

dbt-core added show command to help user developing models, however, this command only works for SQL models, when trying to run show selecting a python model, we will get the following error:

03:41:19  Encountered an error:
Runtime Error
  Database Error in model test (models/test.py)
    001003 (42000): SQL compilation error:
    syntax error line 1 at position 0 unexpected 'def'.

This is because dbt-core still tries to run the python model as a SQL.

In order to support this, we likely will have to actually materialize the python model to a temp table, get some results back, and remove the temp table. I am not sure whether the use case here is large enough for dbt-core to support such functionality that is fairly involved.

Describe alternatives you've considered

Not supporting it as python models as sql models works pretty different.

Or we can raise a more clear error saying that show do not support python model

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response

@ChenyuLInx ChenyuLInx added enhancement New feature or request triage labels Aug 22, 2023
@github-actions github-actions bot changed the title [Feature] Support show of python model [CT-3017] [Feature] Support show of python model Aug 22, 2023
@jtcohen6
Copy link
Contributor

Thanks @ChenyuLInx!

First thought: I think this would be easier to support for Snowpark, where we can (in theory) run the Python model as a stored procedure that actually returns rows. I believe that's how it works inside the Snowsight UI. But this doesn't work in the more-general case, whereby Python models are submitted as jobs that produce an object in the DWH.

Second thought: We just need to build the model first — either:

  • behind-the-scenes into a temp table (tricky)
  • by keeping track of logical state (complex), and rebuilding only when it's changed
  • by just exposing this limitation to the user explicitly, and asking them to build the model first after making changes

In any case, this would require that we add a parameter to show to the effect of: "I've already built this model, so please just show me X records from the object that already exists in the DWH"

That could be relevant for SQL models, too. It becomes a question of UX and state management: "You haven't changed this model since the last time you built it, so we're going to show you a preview from the existing DWH object rather than re-running the query." Or: "You've edited this Python model since the last you built it, so you need to run it first before previewing."

@jtcohen6 jtcohen6 added Refinement Maintainer input needed and removed triage labels Aug 22, 2023
Copy link
Contributor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Refinement Maintainer input needed stale Issues that have gone stale
Projects
None yet
Development

No branches or pull requests

2 participants