dbt-labs / dbt-rpc

A server that can compile and run queries in the context of a dbt project. Additionally, it provides methods that can be used to list and terminate running processes.
https://docs.getdbt.com/reference/commands/rpc
Apache License 2.0
19 stars 7 forks source link

[CT-1163] Add `language` to `RPCExecParameters` to support interactive compilation for dbt Python #93

Closed jtcohen6 closed 2 years ago

jtcohen6 commented 2 years ago

The compile_sql method should accept a language argument, with two valid options: ("sql", "python"). (We should do the same things for run_sql, for consistency.)

I think this would require a change to RPCExecParameters:

https://github.com/dbt-labs/dbt-rpc/blob/b45d09e487fedb1b12fd3214081e593d52332bb4/dbt_rpc/contracts/rpc.py#L50-L54

If the argument is provided, we should (somewhere) set the ModelLanguage attribute of the RPC node to be the language provided. That should be enough for it to be compiled properly here in dbt-core.

In order for this to not be a breaking change, when running with earlier versions of dbt-core (<1.3), we might need to check if the node hasattr for language already. If it does need to be a breaking change, we'll just bump dbt-rpc to minor version 0.2.0.

We shouldn't go through the trouble of renaming and aliasing these methods because dbt-rpc is soon to be deprecated.

ChenyuLInx commented 2 years ago

@jtcohen6 I added the new arg language, it is an optional one, so not a breaking change for anythin.

But we could also just let them use the existing one name without adding a new arg, I can make sure that name is passed to where we create a FileBlock, and as long as that name has the correct ending .py, the rest will work.

Either way works from my perspective, just want to see if you have any preference Gonna stay with the current approach after talking on slack