all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#3887: [PATCH] Hive support for sql-mode
@ 2009-07-20 17:46 Ian Eure
  2012-04-12 17:30 ` Lars Magne Ingebrigtsen
  2016-02-29  3:40 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Eure @ 2009-07-20 17:46 UTC (permalink / raw)
  To: emacs-pretest-bug

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

I added basic support for Hive to sql-mode. Hive is a SQL-like  
interface for querying data stored in Hadoop, a distributed storage  
framework and map/reduce engine.

Patch against recent CVS HEAD.


[-- Attachment #2: sql-hive.patch --]
[-- Type: application/octet-stream, Size: 4460 bytes --]

diff --git a/sql.el b/sql.el
index da0794b..609eec6 100644
--- a/sql.el
+++ b/sql.el
@@ -283,6 +283,7 @@ highlighted properly when you open them."
 		 (const :tag "PostGres" postgres)
 		 (const :tag "Solid" solid)
 		 (const :tag "SQLite" sqlite)
+		 (const :tag "Hive" hive)
 		 (const :tag "Sybase" sybase))
   :group 'SQL)
 
@@ -360,6 +361,11 @@ highlighted properly when you open them."
      :sqli-connect sql-connect-sqlite
      :sqli-prompt-regexp "^sqlite> "
      :sqli-prompt-length 8)
+    (hive
+     :font-lock sql-mode-hive-font-lock-keywords
+     :sqli-connect sql-connect-hive
+     :sqli-prompt-range "^hive> "
+     :sqli-prompt-length 6)
     (sybase
      :font-lock sql-mode-sybase-font-lock-keywords
      :sqli-login (server user password database)
@@ -549,6 +555,21 @@ on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
   :version "20.8"
   :group 'SQL)
 
+;; Customization for Hive
+
+(defcustom sql-hive-program "hive"
+  "*Command to start hive.
+
+Starts `sql-interactive-mode' after doing some setup."
+  :type 'file
+  :group 'SQL)
+
+(defcustom sql-hive-options nil
+  "*List of additional options for `sql-hive-program'."
+  :type '(repeat string)
+  :version "20.8"
+  :group 'SQL)
+
 ;; Customization for MySql
 
 (defcustom sql-mysql-program "mysql"
@@ -840,6 +861,9 @@ Based on `comint-mode-map'.")
     ["SQLite" sql-highlight-sqlite-keywords
      :style radio
      :selected (eq sql-product 'sqlite)]
+    ["Hive" sql-highlight-hive-keywords
+     :style radio
+     :selected (eq sql-product 'hive)]
     ["Sybase" sql-highlight-sybase-keywords
      :style radio
      :selected (eq sql-product 'sybase)]
@@ -1637,6 +1661,14 @@ regular expressions are created during compilation by calling the
 function `regexp-opt'.  Therefore, take a look at the source before
 you define your own sql-mode-sqlite-font-lock-keywords.")
 
+(defvar sql-mode-hive-font-lock-keywords nil
+  "Hive SQL keywords used by font-lock.
+
+This variable is used by `sql-mode' and `sql-interactive-mode'.  The
+regular expressions are created during compilation by calling the
+function `regexp-opt'.  Therefore, take a look at the source before
+you define your own sql-mode-sqlite-font-lock-keywords.")
+
 (defvar sql-mode-db2-font-lock-keywords nil
   "DB2 SQL keywords used by font-lock.
 
@@ -1830,6 +1862,11 @@ highlighting."
   (interactive)
   (sql-set-product 'sqlite))
 
+(defun sql-highlight-hive-keywords ()
+  "Highlight Hive SQL keywords."
+  (interactive)
+  (sql-set-product 'hive))
+
 (defun sql-highlight-db2-keywords ()
   "Highlight DB2 SQL keywords."
   (interactive)
@@ -2614,7 +2651,48 @@ parameters and command options."
     (if (not (null sql-sqlite-options))
 	(setq params (append sql-sqlite-options params)))
     (set-buffer (apply 'make-comint "SQL" sql-sqlite-program
-		       nil params))))
+                       nil params))))
+
+\f
+
+;;;###autoload
+(defun sql-hive ()
+  "Run hive as an inferior process.
+
+Hive is free software.
+
+If buffer `*SQL*' exists but no process is running, make a new process.
+If buffer exists and a process is running, just switch to buffer
+`*SQL*'.
+
+Interpreter used comes from variable
+`sql-hive-program'. Additional command line parameters can be
+stored in the list `sql-hive-options'.
+
+The buffer is put in sql-interactive-mode, giving commands for sending
+input.  See `sql-interactive-mode'.
+
+To specify a coding system for converting non-ASCII characters
+in the input and output to the process, use \\[universal-coding-system-argument]
+before \\[sql-hive].  You can also specify this with \\[set-buffer-process-coding-system]
+in the SQL buffer, after you start the process.
+The default comes from `process-coding-system-alist' and
+`default-process-coding-system'.
+
+\(Type \\[describe-mode] in the SQL buffer for a list of commands.)"
+  (interactive)
+  (sql-product-interactive 'hive))
+
+(defun sql-connect-hive ()
+  "Create comint buffer and connect to Hive using the login
+parameters and command options."
+  ;; Put all parameters to the program (if defined) in a list and call
+  ;; make-comint.
+  (let ((params))
+    (if (not (null sql-hive-options))
+        (setq params (append sql-hive-options params)))
+    (set-buffer (apply 'make-comint "SQL" sql-hive-program
+                       nil params))))
 
 \f
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-27 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-20 17:46 bug#3887: [PATCH] Hive support for sql-mode Ian Eure
2012-04-12 17:30 ` Lars Magne Ingebrigtsen
2016-02-29  3:40 ` Lars Ingebrigtsen
2019-06-27 17:55   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.