Created
November 22, 2019 01:14
-
-
Save roaramburu/c622c699d963462b568b91785f8cb8b4 to your computer and use it in GitHub Desktop.
This file contains 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", | |
"metadata": {}, | |
"source": [ | |
"## BlazingSQL\n", | |
"\n", | |
"Basic demonstration of querying an Apache Parquet file on a data lake (in this case Google Cloud Storage)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"lo\n", | |
"BlazingContext ready\n", | |
"29129\n" | |
] | |
}, | |
{ | |
"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>n_nationkey</th>\n", | |
" <th>n_name</th>\n", | |
" <th>n_regionkey</th>\n", | |
" <th>n_comment</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>0</td>\n", | |
" <td>ALGERIA</td>\n", | |
" <td>0</td>\n", | |
" <td>haggle. carefully final deposits detect slyly...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>1</td>\n", | |
" <td>ARGENTINA</td>\n", | |
" <td>1</td>\n", | |
" <td>al foxes promise slyly according to the regula...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>2</td>\n", | |
" <td>BRAZIL</td>\n", | |
" <td>1</td>\n", | |
" <td>y alongside of the pending deposits. carefully...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>3</td>\n", | |
" <td>CANADA</td>\n", | |
" <td>1</td>\n", | |
" <td>eas hang ironic, silent packages. slyly regula...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>4</td>\n", | |
" <td>EGYPT</td>\n", | |
" <td>4</td>\n", | |
" <td>y above the carefully unusual theodolites. fin...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>5</td>\n", | |
" <td>ETHIOPIA</td>\n", | |
" <td>0</td>\n", | |
" <td>ven packages wake quickly. regu</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>6</td>\n", | |
" <td>FRANCE</td>\n", | |
" <td>3</td>\n", | |
" <td>refully final requests. regular, ironi</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>7</td>\n", | |
" <td>GERMANY</td>\n", | |
" <td>3</td>\n", | |
" <td>l platelets. regular accounts x-ray: unusual, ...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>8</td>\n", | |
" <td>INDIA</td>\n", | |
" <td>2</td>\n", | |
" <td>ss excuses cajole slyly across the packages. d...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>9</td>\n", | |
" <td>INDONESIA</td>\n", | |
" <td>2</td>\n", | |
" <td>slyly express asymptotes. regular deposits ha...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>10</td>\n", | |
" <td>IRAN</td>\n", | |
" <td>4</td>\n", | |
" <td>efully alongside of the slyly final dependenci...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>11</td>\n", | |
" <td>IRAQ</td>\n", | |
" <td>4</td>\n", | |
" <td>nic deposits boost atop the quickly final requ...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>12</td>\n", | |
" <td>JAPAN</td>\n", | |
" <td>2</td>\n", | |
" <td>ously. final, express gifts cajole a</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>13</td>\n", | |
" <td>JORDAN</td>\n", | |
" <td>4</td>\n", | |
" <td>ic deposits are blithely about the carefully r...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>14</td>\n", | |
" <td>KENYA</td>\n", | |
" <td>0</td>\n", | |
" <td>pending excuses haggle furiously deposits. pe...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>15</td>\n", | |
" <td>MOROCCO</td>\n", | |
" <td>0</td>\n", | |
" <td>rns. blithely bold courts among the closely re...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>16</td>\n", | |
" <td>MOZAMBIQUE</td>\n", | |
" <td>0</td>\n", | |
" <td>s. ironic, unusual asymptotes wake blithely r</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>17</th>\n", | |
" <td>17</td>\n", | |
" <td>PERU</td>\n", | |
" <td>1</td>\n", | |
" <td>platelets. blithely pending dependencies use f...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>18</th>\n", | |
" <td>18</td>\n", | |
" <td>CHINA</td>\n", | |
" <td>2</td>\n", | |
" <td>c dependencies. furiously express notornis sle...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>19</th>\n", | |
" <td>19</td>\n", | |
" <td>ROMANIA</td>\n", | |
" <td>3</td>\n", | |
" <td>ular asymptotes are about the furious multipli...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>20</th>\n", | |
" <td>20</td>\n", | |
" <td>SAUDI ARABIA</td>\n", | |
" <td>4</td>\n", | |
" <td>ts. silent requests haggle. closely express pa...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>21</th>\n", | |
" <td>21</td>\n", | |
" <td>VIETNAM</td>\n", | |
" <td>2</td>\n", | |
" <td>hely enticingly express accounts. even, final</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>22</th>\n", | |
" <td>22</td>\n", | |
" <td>RUSSIA</td>\n", | |
" <td>3</td>\n", | |
" <td>requests against the platelets use never acco...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>23</th>\n", | |
" <td>23</td>\n", | |
" <td>UNITED KINGDOM</td>\n", | |
" <td>3</td>\n", | |
" <td>eans boost carefully special requests. account...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>24</th>\n", | |
" <td>24</td>\n", | |
" <td>UNITED STATES</td>\n", | |
" <td>1</td>\n", | |
" <td>y final packages. slow foxes cajole quickly. q...</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" n_nationkey n_name n_regionkey \\\n", | |
"0 0 ALGERIA 0 \n", | |
"1 1 ARGENTINA 1 \n", | |
"2 2 BRAZIL 1 \n", | |
"3 3 CANADA 1 \n", | |
"4 4 EGYPT 4 \n", | |
"5 5 ETHIOPIA 0 \n", | |
"6 6 FRANCE 3 \n", | |
"7 7 GERMANY 3 \n", | |
"8 8 INDIA 2 \n", | |
"9 9 INDONESIA 2 \n", | |
"10 10 IRAN 4 \n", | |
"11 11 IRAQ 4 \n", | |
"12 12 JAPAN 2 \n", | |
"13 13 JORDAN 4 \n", | |
"14 14 KENYA 0 \n", | |
"15 15 MOROCCO 0 \n", | |
"16 16 MOZAMBIQUE 0 \n", | |
"17 17 PERU 1 \n", | |
"18 18 CHINA 2 \n", | |
"19 19 ROMANIA 3 \n", | |
"20 20 SAUDI ARABIA 4 \n", | |
"21 21 VIETNAM 2 \n", | |
"22 22 RUSSIA 3 \n", | |
"23 23 UNITED KINGDOM 3 \n", | |
"24 24 UNITED STATES 1 \n", | |
"\n", | |
" n_comment \n", | |
"0 haggle. carefully final deposits detect slyly... \n", | |
"1 al foxes promise slyly according to the regula... \n", | |
"2 y alongside of the pending deposits. carefully... \n", | |
"3 eas hang ironic, silent packages. slyly regula... \n", | |
"4 y above the carefully unusual theodolites. fin... \n", | |
"5 ven packages wake quickly. regu \n", | |
"6 refully final requests. regular, ironi \n", | |
"7 l platelets. regular accounts x-ray: unusual, ... \n", | |
"8 ss excuses cajole slyly across the packages. d... \n", | |
"9 slyly express asymptotes. regular deposits ha... \n", | |
"10 efully alongside of the slyly final dependenci... \n", | |
"11 nic deposits boost atop the quickly final requ... \n", | |
"12 ously. final, express gifts cajole a \n", | |
"13 ic deposits are blithely about the carefully r... \n", | |
"14 pending excuses haggle furiously deposits. pe... \n", | |
"15 rns. blithely bold courts among the closely re... \n", | |
"16 s. ironic, unusual asymptotes wake blithely r \n", | |
"17 platelets. blithely pending dependencies use f... \n", | |
"18 c dependencies. furiously express notornis sle... \n", | |
"19 ular asymptotes are about the furious multipli... \n", | |
"20 ts. silent requests haggle. closely express pa... \n", | |
"21 hely enticingly express accounts. even, final \n", | |
"22 requests against the platelets use never acco... \n", | |
"23 eans boost carefully special requests. account... \n", | |
"24 y final packages. slow foxes cajole quickly. q... " | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from blazingsql import BlazingContext\n", | |
"\n", | |
"bc = BlazingContext()\n", | |
"bc.gs(\"bsql\", project_id='blazingsql-enduser', bucket_name='bsql', use_default_adc_json_file=True, adc_json_file='')\n", | |
"\n", | |
"bc.create_table('nation','gcs://bsql/tpch_sf1/nation/0_0_0.parquet')\n", | |
"gdf = bc.sql('select * from nation')\n", | |
"\n", | |
"gdf" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment