Skip to content

feat(magic): support PRQL query in line magic#160

Merged
eitsupi merged 6 commits into
PRQL:mainfrom
eitsupi:support-line-magic
Mar 27, 2023
Merged

feat(magic): support PRQL query in line magic#160
eitsupi merged 6 commits into
PRQL:mainfrom
eitsupi:support-line-magic

Conversation

@eitsupi
Copy link
Copy Markdown
Member

@eitsupi eitsupi commented Mar 27, 2023

Supports execution of PRQL queries in line magic, like that.

results = %prql from p = `products.csv` | aggregate [min unitsInStock, max unitsInStock]

This PR also changes the function that performs argument parsing from sql.parse.magic_args to IPython.core.magic_arguments.parse_argstring.
In SQL we need to use sql.parse.magic_args because the comment character is -- in SQL. In PRQL, we do not need to consider --.
IPython.core.magic_arguments.parse_argstring is more strict and will raise an error for unsupported arguments such as --foo.

In [1]: %load_ext pyprql.magic

In [2]: %prql --foo from a
UsageError: unrecognized arguments: --foo

@eitsupi eitsupi changed the title feat: support PRQL query in line magic feat(magic): support PRQL query in line magic Mar 27, 2023
@eitsupi eitsupi marked this pull request as ready for review March 27, 2023 13:48
@eitsupi eitsupi marked this pull request as draft March 27, 2023 13:51
@eitsupi eitsupi marked this pull request as ready for review March 27, 2023 14:29
@eitsupi eitsupi requested a review from max-sixty March 27, 2023 14:29
Copy link
Copy Markdown
Member

@max-sixty max-sixty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good, thank you very much @eitsupi !

@eitsupi eitsupi merged commit 0b0f8d8 into PRQL:main Mar 27, 2023
@eitsupi eitsupi deleted the support-line-magic branch March 27, 2023 16:13
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.

2 participants