Skip to content

Instantly share code, notes, and snippets.

@satybald
Last active May 28, 2018 18:54
Show Gist options
  • Select an option

  • Save satybald/ee97e1ab4c14f38312340ae70904b44c to your computer and use it in GitHub Desktop.

Select an option

Save satybald/ee97e1ab4c14f38312340ae70904b44c to your computer and use it in GitHub Desktop.

Revisions

  1. satybald renamed this gist May 28, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. satybald renamed this gist May 26, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. satybald revised this gist May 26, 2018. No changes.
  4. satybald created this gist May 26, 2018.
    118 changes: 118 additions & 0 deletions ipython
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,118 @@
    {
    "cells": [
    {
    "cell_type": "code",
    "execution_count": 1,
    "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>node_id</th>\n",
    " <th>query_id</th>\n",
    " <th>state</th>\n",
    " <th>user</th>\n",
    " <th>source</th>\n",
    " <th>query</th>\n",
    " <th>queued_time_ms</th>\n",
    " <th>analysis_time_ms</th>\n",
    " <th>distributed_planning_time_ms</th>\n",
    " <th>created</th>\n",
    " <th>started</th>\n",
    " <th>last_heartbeat</th>\n",
    " <th>end</th>\n",
    " </tr>\n",
    " </thead>\n",
    " <tbody>\n",
    " <tr>\n",
    " <th>0</th>\n",
    " <td>ffffffff-ffff-ffff-ffff-ffffffffffff</td>\n",
    " <td>20180526_115416_00010_nwiis</td>\n",
    " <td>RUNNING</td>\n",
    " <td>satybald</td>\n",
    " <td>pyhive</td>\n",
    " <td>select * from queries limit 1</td>\n",
    " <td>1</td>\n",
    " <td>17</td>\n",
    " <td>0</td>\n",
    " <td>2018-05-26 13:54:16.654</td>\n",
    " <td>2018-05-26 13:54:16.675</td>\n",
    " <td>2018-05-26 13:54:16.656</td>\n",
    " <td>None</td>\n",
    " </tr>\n",
    " </tbody>\n",
    "</table>\n",
    "</div>"
    ],
    "text/plain": [
    " node_id query_id state \\\n",
    "0 ffffffff-ffff-ffff-ffff-ffffffffffff 20180526_115416_00010_nwiis RUNNING \n",
    "\n",
    " user source query queued_time_ms \\\n",
    "0 satybald pyhive select * from queries limit 1 1 \n",
    "\n",
    " analysis_time_ms distributed_planning_time_ms created \\\n",
    "0 17 0 2018-05-26 13:54:16.654 \n",
    "\n",
    " started last_heartbeat end \n",
    "0 2018-05-26 13:54:16.675 2018-05-26 13:54:16.656 None "
    ]
    },
    "execution_count": 1,
    "metadata": {},
    "output_type": "execute_result"
    }
    ],
    "source": [
    "import pandas as pd\n",
    "from sqlalchemy.engine import create_engine\n",
    "\n",
    "# Presto\n",
    "engine = create_engine('presto://localhost:8080/system/runtime') \n",
    "\n",
    "#Read Presto Data query into a DataFrame\n",
    "df = pd.read_sql('select * from queries limit 1', engine)\n",
    "df.head()"
    ]
    }
    ],
    "metadata": {
    "kernelspec": {
    "display_name": "Python 2",
    "language": "python",
    "name": "python2"
    },
    "language_info": {
    "codemirror_mode": {
    "name": "ipython",
    "version": 2
    },
    "file_extension": ".py",
    "mimetype": "text/x-python",
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython2",
    "version": "2.7.12"
    }
    },
    "nbformat": 4,
    "nbformat_minor": 2
    }