Subject: bug#32724: 26.1; sql.el: support presto client

From: Carlos Pita <[email-masked]>
Date: Wed, 12 Sep 2018 14:08:35 -0300

Here is a tentative partial implementation:

(defun sql-presto (&optional buffer)
  (interactive "P")
  (sql-product-interactive 'presto buffer))

(defun sql-comint-presto (product options &optional buf-name)
  (let* ((catalog-schema (split-string sql-database ":"))
         (params (append options
                         (list "--user" sql-user
                               "--server" sql-server
                               "--catalog" (car catalog-schema)
                               "--schema" (cadr catalog-schema)))))
    (sql-comint product params buf-name)))

(defvar sql-presto-login-params '(user server database))

(setf (alist-get 'presto sql-product-alist)
      '(:name "Presto"
        :font-lock sql-mode-ansi-font-lock-keywords
        :sqli-program "bash"
        :sqli-options ("-c" "PRESTO_PAGER= TERM=vt100 presto $@" "--")
        :sqli-login sql-presto-login-params
        :sqli-comint-func sql-comint-presto
        :list-all "SHOW TABLES;"
        :list-table "SHOW COLUMNS FROM %s;"
        :prompt-regexp "^[[:alnum:]]+:[[:alnum:]]+> "
        :prompt-cont-regexp "^[[:blank:]]+-> "
        :terminator ";"))