Skip to content

Commit

Permalink
feat: add SHOW commands
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-Q committed Nov 15, 2024
1 parent f833028 commit 5fdc027
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = grammar({
keyword_update: _ => make_keyword("update"),
keyword_truncate: _ => make_keyword("truncate"),
keyword_merge: _ => make_keyword("merge"),
keyword_show: _ => make_keyword("show"),
keyword_into: _ => make_keyword("into"),
keyword_overwrite: _ => make_keyword("overwrite"),
keyword_values: _ => make_keyword("values"),
Expand Down Expand Up @@ -740,10 +741,42 @@ module.exports = grammar({
choice(
$._select_statement,
$.set_operation,
$._show_statement,
),
),
),

_show_statement: $ => seq(
$.keyword_show,
choice(
$._show_create,
$.keyword_all, // Postgres
$._show_tables // trino/presto
),
),

_show_tables: $ => seq(
$.keyword_tables,
optional(seq($.keyword_from, $.identifier)),
optional(seq($.keyword_like, $._single_quote_string))
),

_show_create: $ => seq(
$.keyword_create,
choice(
// Trino/Presto/MySQL
$.keyword_schema,
$.keyword_table,
seq(optional($.keyword_materialized), $.keyword_view),
// MySQL
$.keyword_user,
$.keyword_trigger,
$.keyword_procedure,
$.keyword_function
),
$.object_reference
),

cte: $ => seq(
$.identifier,
optional(paren_list(field("argument", $.identifier))),
Expand Down

0 comments on commit 5fdc027

Please sign in to comment.