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

missing example on using multiple --with #1007

Closed
edublancas opened this issue Mar 29, 2024 · 1 comment
Closed

missing example on using multiple --with #1007

edublancas opened this issue Mar 29, 2024 · 1 comment

Comments

@edublancas
Copy link

this came from a slack question. asking how to pass --with multiple times (the question asked if it was --with a --with b, --with a b or another format)

AFAIK, --with is optional and we should be able to parse the dependencies automatically, I tested this and it works, passing --with a --with b also works, we should add this to our docs:

In [7]: %%sql --save female
   ...: select * from penguins.csv where sex = 'FEMALE'
   ...:
   ...:
Running query in 'duckdb://'
Out[7]:
+---------+-----------+----------------+---------------+-------------------+-------------+--------+
| species |   island  | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g |  sex   |
+---------+-----------+----------------+---------------+-------------------+-------------+--------+
|  Adelie | Torgersen |      39.5      |      17.4     |        186        |     3800    | FEMALE |
|  Adelie | Torgersen |      40.3      |      18.0     |        195        |     3250    | FEMALE |
|  Adelie | Torgersen |      36.7      |      19.3     |        193        |     3450    | FEMALE |
|  Adelie | Torgersen |      38.9      |      17.8     |        181        |     3625    | FEMALE |
|  Adelie | Torgersen |      41.1      |      17.6     |        182        |     3200    | FEMALE |
|  Adelie | Torgersen |      36.6      |      17.8     |        185        |     3700    | FEMALE |
|  Adelie | Torgersen |      38.7      |      19.0     |        195        |     3450    | FEMALE |
|  Adelie | Torgersen |      34.4      |      18.4     |        184        |     3325    | FEMALE |
|  Adelie |   Biscoe  |      37.8      |      18.3     |        174        |     3400    | FEMALE |
|  Adelie |   Biscoe  |      35.9      |      19.2     |        189        |     3800    | FEMALE |
+---------+-----------+----------------+---------------+-------------------+-------------+--------+
Truncated to displaylimit of 10.

In [8]: %%sql --save male
   ...: select * from penguins.csv where sex = 'MALE'
   ...:
   ...:
Running query in 'duckdb://'
Out[8]:
+---------+-----------+----------------+---------------+-------------------+-------------+------+
| species |   island  | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex  |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
|  Adelie | Torgersen |      39.1      |      18.7     |        181        |     3750    | MALE |
|  Adelie | Torgersen |      39.3      |      20.6     |        190        |     3650    | MALE |
|  Adelie | Torgersen |      39.2      |      19.6     |        195        |     4675    | MALE |
|  Adelie | Torgersen |      38.6      |      21.2     |        191        |     3800    | MALE |
|  Adelie | Torgersen |      34.6      |      21.1     |        198        |     4400    | MALE |
|  Adelie | Torgersen |      42.5      |      20.7     |        197        |     4500    | MALE |
|  Adelie | Torgersen |      46.0      |      21.5     |        194        |     4200    | MALE |
|  Adelie |   Biscoe  |      37.7      |      18.7     |        180        |     3600    | MALE |
|  Adelie |   Biscoe  |      38.2      |      18.1     |        185        |     3950    | MALE |
|  Adelie |   Biscoe  |      38.8      |      17.2     |        180        |     3800    | MALE |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
Truncated to displaylimit of 10.

In [9]: %%sql
   ...: select * from male
   ...: union all
   ...: select * from female
   ...:
   ...:
Generating CTE with stored snippets: 'female', and 'male'
Running query in 'duckdb://'
Out[9]:
+---------+-----------+----------------+---------------+-------------------+-------------+------+
| species |   island  | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex  |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
|  Adelie | Torgersen |      39.1      |      18.7     |        181        |     3750    | MALE |
|  Adelie | Torgersen |      39.3      |      20.6     |        190        |     3650    | MALE |
|  Adelie | Torgersen |      39.2      |      19.6     |        195        |     4675    | MALE |
|  Adelie | Torgersen |      38.6      |      21.2     |        191        |     3800    | MALE |
|  Adelie | Torgersen |      34.6      |      21.1     |        198        |     4400    | MALE |
|  Adelie | Torgersen |      42.5      |      20.7     |        197        |     4500    | MALE |
|  Adelie | Torgersen |      46.0      |      21.5     |        194        |     4200    | MALE |
|  Adelie |   Biscoe  |      37.7      |      18.7     |        180        |     3600    | MALE |
|  Adelie |   Biscoe  |      38.2      |      18.1     |        185        |     3950    | MALE |
|  Adelie |   Biscoe  |      38.8      |      17.2     |        180        |     3800    | MALE |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
Truncated to displaylimit of 10.

In [10]: %%sql --with male --with female
    ...: select * from male
    ...: union all
    ...: select * from female
    ...:
    ...:
Running query in 'duckdb://'
Out[10]:
+---------+-----------+----------------+---------------+-------------------+-------------+------+
| species |   island  | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex  |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
|  Adelie | Torgersen |      39.1      |      18.7     |        181        |     3750    | MALE |
|  Adelie | Torgersen |      39.3      |      20.6     |        190        |     3650    | MALE |
|  Adelie | Torgersen |      39.2      |      19.6     |        195        |     4675    | MALE |
|  Adelie | Torgersen |      38.6      |      21.2     |        191        |     3800    | MALE |
|  Adelie | Torgersen |      34.6      |      21.1     |        198        |     4400    | MALE |
|  Adelie | Torgersen |      42.5      |      20.7     |        197        |     4500    | MALE |
|  Adelie | Torgersen |      46.0      |      21.5     |        194        |     4200    | MALE |
|  Adelie |   Biscoe  |      37.7      |      18.7     |        180        |     3600    | MALE |
|  Adelie |   Biscoe  |      38.2      |      18.1     |        185        |     3950    | MALE |
|  Adelie |   Biscoe  |      38.8      |      17.2     |        180        |     3800    | MALE |
+---------+-----------+----------------+---------------+-------------------+-------------+------+
Truncated to displaylimit of 10.
@edublancas
Copy link
Author

closing since the person who asked this on slack didn't follow up

@edublancas edublancas closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
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

No branches or pull requests

1 participant