+++ /dev/null
-# -*- mode: snippet -*-
-# name: check_rle_overridden
-# key: rle_check_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-select
- qe.user_name,
- count(*)
-from
- v_monitor.query_events qe
- join v_monitor.query_requests qr
- on qr.transaction_id = qe.transaction_id
- and qr.statement_id = qe.statement_id
-where
- qr.request_type = 'QUERY'
- and qe.event_type = 'RLE_OVERRIDDEN'
- and to_char(event_timestamp, 'YYYY-MM-DD') = '${1:`(format-time-string "%Y-%m-%d")`}'
-group by
- 1
-;
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: current_epoch
-# key: epo_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT current_epoch, ahm_epoch, last_good_epoch FROM v_monitor.system;
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: errors
-# key: errors_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT DISTINCT error_level, message FROM error_messages $0WHERE message ILIKE 'Vertica suggests%';
+++ /dev/null
-# -*- mode: snippet -*-
-# name: get-partitions
-# key: get-part
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM v_monitor.partitions WHERE table_schema = '$1' AND projection_name LIKE '%$2%';$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: get-projections
-# key: get-proj
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT GET_PROJECTIONS('$1');$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: grants
-# key: grants_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT grantee, object_name, privileges_description FROM v_catalog.grants WHERE object_type = '${1:$$(yas-choose-value '("RESOURCEPOOL" "ROLE" "SCHEMA" "TABLE" "VIEW" "STORAGELOCATION"))}' ORDER BY grantee $0LIMIT 50;
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: show nodes
-# key: nodes_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM nodes;
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: query-times
-# key: qt_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT DISTINCT theday,
- user_name,
- (min_dat / 1000) AS min_sec,
- (max_dat / 1000) AS max_sec,
- (avg_dat / 1000) AS avg_sec,
- (median_dat / 1000) AS median_sec,
- query_cnt
-FROM
- (SELECT date(end_timestamp::TIMESTAMP) AS theday,
- user_name,
- min(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) min_dat,
- max(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) max_dat,
- avg(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) avg_dat,
- median(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) median_dat,
- count(*) over(partition BY date(end_timestamp::TIMESTAMP), user_name) AS query_cnt
- FROM query_requests
- WHERE is_executing IS FALSE
- AND request ILIKE '%table%'
- AND NOT (request LIKE 'SELECT * FROM columns%'
- OR request LIKE '%query_requests%') ) my_alias
-ORDER BY 1, 2 DESC;
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: rebalance_status
-# key: rebalance_status_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT rebalance_method rebalance_method,
- status,
- count(*) AS COUNT
-FROM
- (SELECT rebalance_method,
- CASE
- WHEN (separated_percent = 100
- AND transferred_percent = 100) THEN 'Completed'
- WHEN (separated_percent <> 0
- AND separated_percent <> 100)
- OR (transferred_percent <> 0
- AND transferred_percent <> 100) THEN 'In Progress'
- ELSE 'Queued'
- END AS status
- FROM rebalance_projection_status
- WHERE is_latest) AS tab
-GROUP BY 1,
- 2
-ORDER BY 1,
- 2;$0
+++ /dev/null
-# -*- mode: snippet -*-
-# name: resource-pool-move
-# key: rpmv
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM resource_pool_move ORDER BY move_timestamp DESC LIMIT 40;$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: resources
-# key: res_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM ${1:$$(yas-choose-value '("resource_pool_status" "resource_pool_move" "resource_rejections" "resource_rejection_details ORDER BY 1"))};$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: sessions
-# key: sess_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM sessions;$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: storage-containers
-# key: storage-containers
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT s.node_name,
- p.table_schema,
- s.projection_name,
- count(DISTINCT s.storage_oid) storage_container_count,
- count(DISTINCT partition_key) partition_count,
- count(r.rosid) ros_file_count
-FROM storage_containers s
-LEFT OUTER JOIN partitions p ON s.storage_oid = p.ros_id
-JOIN vs_ros r ON r.delid = s.storage_oid
-GROUP BY 1,
- 2,
- 3
-ORDER BY 4 DESC LIMIT 50;$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: storage-locations
-# key: storage-locations
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT * FROM v_catalog.grants gra, storage_locations loc WHERE gra.object_id = loc.location_id;$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: user_sessions
-# key: ussess_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT session_id, transaction_start FROM sessions WHERE user_name = '$1' ORDER BY 2 desc;$0
\ No newline at end of file
+++ /dev/null
-# -*- mode: snippet -*-
-# name: vertica_users
-# key: vertu_
-# group: vertica
-# condition: (if (string-equal sql-product 'vertica)t)
-# --
-SELECT user_name,resource_pool,default_roles FROM v_catalog.users ORDER BY 1;
\ No newline at end of file
+++ /dev/null
-sql-interactive-mode
+++ /dev/null
-;;; vertica-snippets-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
-\f
-;;;### (autoloads nil "vertica-snippets" "vertica-snippets.el" (23163
-;;;;;; 2511 68580 344000))
-;;; Generated autoloads from vertica-snippets.el
-
-(autoload 'vertica-snippets-initialize "vertica-snippets" "\
-Add snippet dir to yas-snippet-dirs and load it.
-
-\(fn)" nil nil)
-
-(eval-after-load 'yasnippet '(vertica-snippets-initialize))
-
-;;;***
-\f
-;;;### (autoloads nil nil ("vertica-snippets-pkg.el") (23163 2511
-;;;;;; 67083 188000))
-
-;;;***
-\f
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; End:
-;;; vertica-snippets-autoloads.el ends here
+++ /dev/null
-(define-package "vertica-snippets" "20180207.453" "Yasnippets for Vertica"
- '((yasnippet "0.6.1"))
- :url "https://github.com/baron42bba/vertica-snippets" :keywords
- '("convenience" "snippets"))
-;; Local Variables:
-;; no-byte-compile: t
-;; End:
+++ /dev/null
-;;; vertica-snippets.el --- Yasnippets for Vertica
-
-;; Copyright (C) 2018 Andreas Gerler
-;; keywords: convenience,snippets
-;; Version: 0.1.0
-;; Package-Requires: ((yasnippet "0.6.1"))
-
-;; Author: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
-;; Maintainer: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
-
-;; URL: https://github.com/baron42bba/vertica-snippets
-
-;; Permission is hereby granted, free of charge, to any person obtaining
-;; a copy of this software and associated documentation files (the
-;; "Software"), to deal in the Software without restriction, including
-;; without limitation the rights to use, copy, modify, merge, publish,
-;; distribute, sublicense, and/or sell copies of the Software, and to
-;; permit persons to whom the Software is furnished to do so, subject to
-;; the following conditions:
-
-;; The above copyright notice and this permission notice shall be
-;; included in all copies or substantial portions of the Software.
-
-;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-;;; Commentary:
-
-;; A collection of yasnippet snippets to be used with the Vertica Analytics Platform
-
-;;; Code:
-
-(require 'yasnippet)
-
-(defvar vertica-snippets-dir (file-name-directory (or (buffer-file-name)
- load-file-name)))
-
-;;;###autoload
-(defun vertica-snippets-initialize ()
- "Add snippet dir to yas-snippet-dirs and load it."
- (let ((snip-dir (expand-file-name "snippets" vertica-snippets-dir)))
- (add-to-list 'yas-snippet-dirs snip-dir t)
- (yas-load-directory snip-dir)))
-
-;;;###autoload
-(eval-after-load 'yasnippet
- '(vertica-snippets-initialize))
-
-(provide 'vertica-snippets)
-;;; vertica-snippets.el ends here
--- /dev/null
+# -*- mode: snippet -*-
+# name: check_rle_overridden
+# key: rle_check_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+select
+ qe.user_name,
+ count(*)
+from
+ v_monitor.query_events qe
+ join v_monitor.query_requests qr
+ on qr.transaction_id = qe.transaction_id
+ and qr.statement_id = qe.statement_id
+where
+ qr.request_type = 'QUERY'
+ and qe.event_type = 'RLE_OVERRIDDEN'
+ and to_char(event_timestamp, 'YYYY-MM-DD') = '${1:`(format-time-string "%Y-%m-%d")`}'
+group by
+ 1
+;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: current_epoch
+# key: epo_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT current_epoch, ahm_epoch, last_good_epoch FROM v_monitor.system;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: errors
+# key: errors_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT DISTINCT error_level, message FROM error_messages $0WHERE message ILIKE 'Vertica suggests%';
--- /dev/null
+# -*- mode: snippet -*-
+# name: get-partitions
+# key: get-part
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM v_monitor.partitions WHERE table_schema = '$1' AND projection_name LIKE '%$2%';$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: get-projections
+# key: get-proj
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT GET_PROJECTIONS('$1');$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: grants
+# key: grants_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT grantee, object_name, privileges_description FROM v_catalog.grants WHERE object_type = '${1:$$(yas-choose-value '("RESOURCEPOOL" "ROLE" "SCHEMA" "TABLE" "VIEW" "STORAGELOCATION"))}' ORDER BY grantee $0LIMIT 50;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: last-statement-timing
+# key: lst_
+# group: vertica
+# --
+SELECT last_statement,
+ last_statement_duration_us / 1000000.0 last_statement_duration_seconds
+FROM current_session;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: list-tables-row-count-size
+# key: ls-tables
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT tbl.table_schema AS "Schema Name",
+ tbl.table_name AS "Table Name",
+ to_char(sum(prs.ros_row_count)/count(DISTINCT prs.projection_name), '999G999G999G999') AS "No Of Rows",
+ to_char(sum(prs.ros_used_bytes)/count(DISTINCT prs.projection_name), '999G999G999G999G999') AS "Size In Bytes"
+FROM TABLES tbl
+JOIN projections prj ON tbl.table_id = prj.anchor_table_id
+JOIN projection_storage prs ON prj.projection_name = prs.projection_name
+GROUP BY 1, 2
+ORDER BY 1, 2;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: show nodes
+# key: nodes_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM nodes;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: query-times
+# key: qt_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT DISTINCT theday,
+ user_name,
+ (min_dat / 1000) AS min_sec,
+ (max_dat / 1000) AS max_sec,
+ (avg_dat / 1000) AS avg_sec,
+ (median_dat / 1000) AS median_sec,
+ query_cnt
+FROM
+ (SELECT date(end_timestamp::TIMESTAMP) AS theday,
+ user_name,
+ min(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) min_dat,
+ max(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) max_dat,
+ avg(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) avg_dat,
+ median(request_duration_ms) over(partition BY date(end_timestamp::TIMESTAMP), user_name) median_dat,
+ count(*) over(partition BY date(end_timestamp::TIMESTAMP), user_name) AS query_cnt
+ FROM query_requests
+ WHERE is_executing IS FALSE
+ AND request ILIKE '%table%'
+ AND NOT (request LIKE 'SELECT * FROM columns%'
+ OR request LIKE '%query_requests%') ) my_alias
+ORDER BY 1, 2 DESC;
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: rebalance_status
+# key: rebalance_status_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT rebalance_method rebalance_method,
+ status,
+ count(*) AS COUNT
+FROM
+ (SELECT rebalance_method,
+ CASE
+ WHEN (separated_percent = 100
+ AND transferred_percent = 100) THEN 'Completed'
+ WHEN (separated_percent <> 0
+ AND separated_percent <> 100)
+ OR (transferred_percent <> 0
+ AND transferred_percent <> 100) THEN 'In Progress'
+ ELSE 'Queued'
+ END AS status
+ FROM rebalance_projection_status
+ WHERE is_latest) AS tab
+GROUP BY 1,
+ 2
+ORDER BY 1,
+ 2;$0
--- /dev/null
+# -*- mode: snippet -*-
+# name: resource-pool-move
+# key: rpmv
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM resource_pool_move ORDER BY move_timestamp DESC LIMIT 40;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: resources
+# key: res_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM ${1:$$(yas-choose-value '("resource_pool_status" "resource_pool_move" "resource_rejections" "resource_rejection_details ORDER BY 1"))};$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: sessions
+# key: sess_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM sessions;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: storage-containers
+# key: storage-containers
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT s.node_name,
+ p.table_schema,
+ s.projection_name,
+ count(DISTINCT s.storage_oid) storage_container_count,
+ count(DISTINCT partition_key) partition_count,
+ count(r.rosid) ros_file_count
+FROM storage_containers s
+LEFT OUTER JOIN partitions p ON s.storage_oid = p.ros_id
+JOIN vs_ros r ON r.delid = s.storage_oid
+GROUP BY 1,
+ 2,
+ 3
+ORDER BY 4 DESC LIMIT 50;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: storage-locations
+# key: storage-locations
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT * FROM v_catalog.grants gra, storage_locations loc WHERE gra.object_id = loc.location_id;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: user_sessions
+# key: ussess_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT session_id, transaction_start FROM sessions WHERE user_name = '$1' ORDER BY 2 desc;$0
\ No newline at end of file
--- /dev/null
+# -*- mode: snippet -*-
+# name: vertica_users
+# key: vertu_
+# group: vertica
+# condition: (if (string-equal sql-product 'vertica)t)
+# --
+SELECT user_name,resource_pool,default_roles FROM v_catalog.users ORDER BY 1;
\ No newline at end of file
--- /dev/null
+sql-interactive-mode
--- /dev/null
+;;; vertica-snippets-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+ (or (file-name-directory #$) (car load-path))))
+
+\f
+;;;### (autoloads nil "vertica-snippets" "vertica-snippets.el" (0
+;;;;;; 0 0 0))
+;;; Generated autoloads from vertica-snippets.el
+
+(autoload 'vertica-snippets-initialize "vertica-snippets" "\
+Add snippet dir to yas-snippet-dirs and load it.
+
+\(fn)" nil nil)
+
+(eval-after-load 'yasnippet '(vertica-snippets-initialize))
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "vertica-snippets" '("vertica-snippets-dir")))
+
+;;;***
+\f
+;;;### (autoloads nil nil ("vertica-snippets-pkg.el") (0 0 0 0))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; vertica-snippets-autoloads.el ends here
--- /dev/null
+(define-package "vertica-snippets" "20181016.748" "Yasnippets for Vertica"
+ '((yasnippet "0.6.1"))
+ :keywords
+ '("convenience" "snippets")
+ :authors
+ '(("Andreas Gerler" . "baron@bundesbrandschatzamt.de"))
+ :maintainer
+ '("Andreas Gerler" . "baronNOSPAMbundesbrandschatzamt.de")
+ :url "https://github.com/baron42bba/vertica-snippets")
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
--- /dev/null
+;;; vertica-snippets.el --- Yasnippets for Vertica
+
+;; Copyright (C) 2018 Andreas Gerler
+;; keywords: convenience,snippets
+;; Version: 0.1.0
+;; Package-Requires: ((yasnippet "0.6.1"))
+
+;; Author: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
+;; Maintainer: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
+
+;; URL: https://github.com/baron42bba/vertica-snippets
+
+;; Permission is hereby granted, free of charge, to any person obtaining
+;; a copy of this software and associated documentation files (the
+;; "Software"), to deal in the Software without restriction, including
+;; without limitation the rights to use, copy, modify, merge, publish,
+;; distribute, sublicense, and/or sell copies of the Software, and to
+;; permit persons to whom the Software is furnished to do so, subject to
+;; the following conditions:
+
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+;;; Commentary:
+
+;; A collection of yasnippet snippets to be used with the Vertica Analytics Platform
+
+;;; Code:
+
+(require 'yasnippet)
+
+(defvar vertica-snippets-dir (file-name-directory (or (buffer-file-name)
+ load-file-name)))
+
+;;;###autoload
+(defun vertica-snippets-initialize ()
+ "Add snippet dir to yas-snippet-dirs and load it."
+ (let ((snip-dir (expand-file-name "snippets" vertica-snippets-dir)))
+ (add-to-list 'yas-snippet-dirs snip-dir t)
+ (yas-load-directory snip-dir)))
+
+;;;###autoload
+(eval-after-load 'yasnippet
+ '(vertica-snippets-initialize))
+
+(provide 'vertica-snippets)
+;;; vertica-snippets.el ends here