Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions prqlc/bindings/prqlc-python/python/prqlc/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ class CompileOptions:
self,
*,
format: bool = True,
target: str = "sql.any",
signature_comment: bool = True,
target: str = "sql.any",
color: bool = False,
display: str = "plain",
) -> None: ...

def compile(prql_query: str, options: Optional[CompileOptions] = None) -> str: ...
def prql_to_pl(prql_query: str) -> str: ...
def pl_to_rq(pl_json: str) -> str: ...
def pl_to_prql(pl_json: str) -> str: ...
def rq_to_sql(rq_json: str) -> str: ...
def rq_to_sql(rq_json: str, options: Optional[CompileOptions] = None) -> str: ...
def get_targets() -> List[str]: ...

__version__: str
22 changes: 22 additions & 0 deletions prqlc/bindings/prqlc-python/python/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ def test_compile_options() -> None:
)


def test_rq_to_sql_options() -> None:
"""
`rq_to_sql` accepts an optional `CompileOptions`, and `CompileOptions`
accepts `color` and `display`. These calls exercise the full public
signatures so the type stub stays in sync with the binding (checked by
`ty` in CI).
"""
rq = prqlc.pl_to_rq(prqlc.prql_to_pl("from employees | take 3"))

options = prqlc.CompileOptions(
format=False,
signature_comment=False,
target="sql.sqlite",
color=False,
display="plain",
)
assert prqlc.rq_to_sql(rq, options) == "SELECT * FROM employees LIMIT 3"

# `options` is optional and defaults to None.
assert prqlc.rq_to_sql(rq)


def test_debug_functions() -> None:
prql_query = "from invoices | select { id, customer_id }"

Expand Down
Loading