Created
June 13, 2022 02:38
-
-
Save ajfriend/1b334e4bbf1bd3d13a1d6a103f33f074 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "01236593-e138-4e48-be59-04b9f53516fa", | |
"metadata": {}, | |
"source": [ | |
"# DuckDB confusion around ordering of `where` and `using sample`\n", | |
"\n", | |
"Here's some code demonstrating an issue that confused me recently.\n", | |
"\n", | |
"Going in, my expectation was that the `using sample 5` filtering would happen **after** the `where` clause filtering. So I was confused by the second example, where I got a random number of rows back.\n", | |
"\n", | |
"After playing around with it for a bit, I'm guessing that the `using sample 5` filtering actually happens **before** the `where` clause filtering.\n", | |
"\n", | |
"Perhaps this is explained well somewhere in the documentation, but as a Python user who isn't used to the syntax diagrams like in https://duckdb.org/docs/sql/samples, this wasn't obvious to me.\n", | |
"\n", | |
"Maybe pointing out the clause ordering more aggressively in the docs would help other folks in the future that might run into this issue? (Or maybe I just missed that part of the docs?)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "f0cb4c6e-cd8b-4e7a-828f-4860bfe73e62", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import uuid\n", | |
"\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"\n", | |
"import duckdb\n", | |
"\n", | |
"def dquery(\n", | |
" query_string,\n", | |
" **dfs_for_query,\n", | |
"):\n", | |
" \"\"\"\n", | |
" Helper function controls the scope of which dataframes\n", | |
" are considered.\n", | |
" \"\"\"\n", | |
" con = duckdb.connect(database=':memory:')\n", | |
" \n", | |
" for tbl_name, df in dfs_for_query.items():\n", | |
" con.register(tbl_name, df)\n", | |
" \n", | |
" out = con.execute(query_string).df()\n", | |
" \n", | |
" return out" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "bc42f26e-2dea-4a13-a21b-7f9465c8bcc6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>9cfa0d63-b990-475a-8c38-4bc0904f809b</td>\n", | |
" <td>9.252029</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>4918839f-388c-4c70-b062-8c56e3182ea7</td>\n", | |
" <td>8.193557</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>2fbdec89-12a3-4ece-b935-7ecfae331544</td>\n", | |
" <td>7.811328</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>9ca9d6d7-f272-4d32-a61c-f3786ed70f0d</td>\n", | |
" <td>2.700175</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>82fd67ca-1005-49a1-b4d4-65251b074649</td>\n", | |
" <td>2.608047</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>995</th>\n", | |
" <td>4d1ddeed-00a9-466f-ad73-af76ddc9b515</td>\n", | |
" <td>0.479595</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>996</th>\n", | |
" <td>2e847c92-5f50-458a-af76-b682fe8ba189</td>\n", | |
" <td>1.087416</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>997</th>\n", | |
" <td>bc248b1c-e035-4159-bbd8-4515e596576c</td>\n", | |
" <td>0.032724</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>998</th>\n", | |
" <td>05ba1d7c-54df-4714-b95f-923b45c26c3b</td>\n", | |
" <td>3.469124</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>999</th>\n", | |
" <td>df474459-8241-43be-989b-d979519bac51</td>\n", | |
" <td>2.133793</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>1000 rows × 2 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 9cfa0d63-b990-475a-8c38-4bc0904f809b 9.252029\n", | |
"1 4918839f-388c-4c70-b062-8c56e3182ea7 8.193557\n", | |
"2 2fbdec89-12a3-4ece-b935-7ecfae331544 7.811328\n", | |
"3 9ca9d6d7-f272-4d32-a61c-f3786ed70f0d 2.700175\n", | |
"4 82fd67ca-1005-49a1-b4d4-65251b074649 2.608047\n", | |
".. ... ...\n", | |
"995 4d1ddeed-00a9-466f-ad73-af76ddc9b515 0.479595\n", | |
"996 2e847c92-5f50-458a-af76-b682fe8ba189 1.087416\n", | |
"997 bc248b1c-e035-4159-bbd8-4515e596576c 0.032724\n", | |
"998 05ba1d7c-54df-4714-b95f-923b45c26c3b 3.469124\n", | |
"999 df474459-8241-43be-989b-d979519bac51 2.133793\n", | |
"\n", | |
"[1000 rows x 2 columns]" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"N = 1000\n", | |
"\n", | |
"d = {\n", | |
" 'uuid':\n", | |
" [str(uuid.uuid4()) for _ in range(N)],\n", | |
" 'solve_seconds':\n", | |
" [np.random.rand()*10 for _ in range(N)],\n", | |
"}\n", | |
"\n", | |
"df = pd.DataFrame(d)\n", | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "120341e6-4d09-45ff-b106-97e4e1758601", | |
"metadata": {}, | |
"source": [ | |
"# Consistent number of rows" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "e1b528ae-2ecb-4b6b-85b1-30d571b89b58", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"s = \"\"\"\n", | |
"with _ as (select 0)\n", | |
"\n", | |
", tbl2 as\n", | |
"(\n", | |
"select\n", | |
" *\n", | |
"from\n", | |
" tbl\n", | |
"where\n", | |
" solve_seconds >= 5\n", | |
")\n", | |
"\n", | |
"select\n", | |
" *\n", | |
"from\n", | |
" tbl2\n", | |
"using\n", | |
" sample 5\n", | |
"\"\"\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "cfcc00fe-4f7c-4436-9c9c-f834e3f5f03c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>920d74a0-7059-4268-971e-f5e9e4fa85c2</td>\n", | |
" <td>8.837215</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>ca5bfdb8-ba51-428b-afee-e241fddb8463</td>\n", | |
" <td>5.186592</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>36b46144-d94c-4684-84ab-31f5491209f9</td>\n", | |
" <td>6.847117</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>c7a635fb-5fb0-45c7-9afa-a14f78732fd6</td>\n", | |
" <td>9.991330</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>280de764-f078-41ae-a710-7f94346b1fa7</td>\n", | |
" <td>7.085486</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 920d74a0-7059-4268-971e-f5e9e4fa85c2 8.837215\n", | |
"1 ca5bfdb8-ba51-428b-afee-e241fddb8463 5.186592\n", | |
"2 36b46144-d94c-4684-84ab-31f5491209f9 6.847117\n", | |
"3 c7a635fb-5fb0-45c7-9afa-a14f78732fd6 9.991330\n", | |
"4 280de764-f078-41ae-a710-7f94346b1fa7 7.085486" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "1a20f791-3411-48f8-9c35-d279d2575fd0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>54f3a42e-abf8-4b6f-9e2f-bddc55f2f8f0</td>\n", | |
" <td>8.118792</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>d9438133-708a-44f9-bec3-da4feba485cc</td>\n", | |
" <td>6.679834</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>a6990494-6683-417a-b8bd-71708254594f</td>\n", | |
" <td>9.939963</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>3b39ee7b-a8c8-45b4-a832-bbfb834336f4</td>\n", | |
" <td>9.691375</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>89bdb822-ca33-412f-9a09-cdb1a305ccba</td>\n", | |
" <td>8.981711</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 54f3a42e-abf8-4b6f-9e2f-bddc55f2f8f0 8.118792\n", | |
"1 d9438133-708a-44f9-bec3-da4feba485cc 6.679834\n", | |
"2 a6990494-6683-417a-b8bd-71708254594f 9.939963\n", | |
"3 3b39ee7b-a8c8-45b4-a832-bbfb834336f4 9.691375\n", | |
"4 89bdb822-ca33-412f-9a09-cdb1a305ccba 8.981711" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "58aa6a32-776e-485a-b899-f528b7180096", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>1705fcb2-ece6-41ba-88d6-2aa7c44b7b12</td>\n", | |
" <td>6.545223</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5122df2b-10ab-4b0c-b8b8-dfe0b8e4b2c3</td>\n", | |
" <td>7.121213</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>525be9e1-bcf4-49c2-b6f2-41d73f657495</td>\n", | |
" <td>9.450045</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>600d35ad-fcb8-4032-9965-9d414776bf30</td>\n", | |
" <td>7.534916</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>fdd792e0-3d9f-4742-bd8f-5ff0ad26a0b9</td>\n", | |
" <td>5.950555</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 1705fcb2-ece6-41ba-88d6-2aa7c44b7b12 6.545223\n", | |
"1 5122df2b-10ab-4b0c-b8b8-dfe0b8e4b2c3 7.121213\n", | |
"2 525be9e1-bcf4-49c2-b6f2-41d73f657495 9.450045\n", | |
"3 600d35ad-fcb8-4032-9965-9d414776bf30 7.534916\n", | |
"4 fdd792e0-3d9f-4742-bd8f-5ff0ad26a0b9 5.950555" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "5e98035b-d70d-4295-92f5-0d3c4f031c49", | |
"metadata": {}, | |
"source": [ | |
"# Random number of rows?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "0da3ac55-376f-4227-8ff4-1195ae11f54c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"s = \"\"\"\n", | |
"with _ as (select 0)\n", | |
"\n", | |
", tbl2 as\n", | |
"(\n", | |
"select\n", | |
" *\n", | |
"from\n", | |
" tbl\n", | |
"where\n", | |
" solve_seconds >= 5\n", | |
"using\n", | |
" sample 5\n", | |
")\n", | |
"\n", | |
"select\n", | |
" *\n", | |
"from\n", | |
" tbl2\n", | |
"\"\"\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "6bbf5af8-d1fd-4fb1-a7f8-0287db269f9c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>aeb203bc-d183-4cf2-a56f-d8ed78bf795a</td>\n", | |
" <td>7.052027</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 aeb203bc-d183-4cf2-a56f-d8ed78bf795a 7.052027" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "945caa4e-2030-4932-8430-90b2f174d254", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>8a0b4c99-2cfa-4f5d-8e36-22b43d12719a</td>\n", | |
" <td>5.746398</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>efcaa71f-a87b-4981-a9fc-db89750da27f</td>\n", | |
" <td>7.170344</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 8a0b4c99-2cfa-4f5d-8e36-22b43d12719a 5.746398\n", | |
"1 efcaa71f-a87b-4981-a9fc-db89750da27f 7.170344" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "e5d03cde-4432-4cbd-b8c9-d5c6b8175176", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>d2b9d89e-044f-42e1-a528-6e16ffeaf87b</td>\n", | |
" <td>7.565799</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>19dc9646-4be9-4a8a-b75c-47c79b6b0c47</td>\n", | |
" <td>5.367203</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 d2b9d89e-044f-42e1-a528-6e16ffeaf87b 7.565799\n", | |
"1 19dc9646-4be9-4a8a-b75c-47c79b6b0c47 5.367203" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "b846db1e-7f93-420b-a9b8-72ef7be6098b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>7fb23086-e56d-4e1b-b218-a0bde0624082</td>\n", | |
" <td>6.640648</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>65553d20-5485-41a4-9542-d1b4c0087623</td>\n", | |
" <td>5.090412</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>f5de2331-6d35-4c3c-9407-5d77edf9680a</td>\n", | |
" <td>8.789038</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>b0394f52-7281-4e4e-a8fe-dbb12f1dbcd0</td>\n", | |
" <td>8.184858</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 7fb23086-e56d-4e1b-b218-a0bde0624082 6.640648\n", | |
"1 65553d20-5485-41a4-9542-d1b4c0087623 5.090412\n", | |
"2 f5de2331-6d35-4c3c-9407-5d77edf9680a 8.789038\n", | |
"3 b0394f52-7281-4e4e-a8fe-dbb12f1dbcd0 8.184858" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "a1bc12a4-2a75-47a0-bb0f-42f526b93042", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>uuid</th>\n", | |
" <th>solve_seconds</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>99faa1a2-fe5e-4a6d-8840-10185dc02eb0</td>\n", | |
" <td>9.054793</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" uuid solve_seconds\n", | |
"0 99faa1a2-fe5e-4a6d-8840-10185dc02eb0 9.054793" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dquery(s, tbl=df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "aeb7efd3-105f-438a-b9c9-3d7518ce0142", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created for: duckdb/duckdb#3834