Skip to content

Commit f3c1a93

Browse files
author
Matthew Corley
committed
feat: add Dremio dialect
1 parent 480fd87 commit f3c1a93

4 files changed

Lines changed: 32 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A CodeMirror extension for SQL linting and visual gutter indicators. Built by an
99
- 💡 **Hover tooltips** - Schema info, keywords, and column details on hover
1010
- 🔮 **CTE autocomplete** - Auto-complete support for CTEs
1111
- 🎯 **Query-aware resolution** - Context-sensitive schema and column suggestions
12-
- 🔍 **Additional dialects** - DuckDB, BigQuery
12+
- 🔍 **Additional dialects** - DuckDB, BigQuery, Dremio
1313
- 🛠️ **Custom renderers** - Customizable tooltip rendering for tables, columns, and keywords
1414

1515
## Installation
@@ -75,6 +75,7 @@ This extension adds support for additional dialects:
7575

7676
- **DuckDB**
7777
- **BigQuery**
78+
- **Dremio**
7879

7980
## Keyword Completion
8081

src/__tests__/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,16 @@ describe("dialects.ts exports", () => {
4242
expect(sortedExports).toMatchInlineSnapshot(`
4343
[
4444
"BigQueryDialect",
45+
"DremioDialect",
4546
"DuckDBDialect",
4647
]
4748
`);
4849
});
50+
51+
it("should expose a Dremio dialect with Dremio SQL keywords", () => {
52+
expect(dialects.DremioDialect.spec.identifierQuotes).toBe('"');
53+
expect(dialects.DremioDialect.spec.keywords?.split(" ")).toContain("reflection");
54+
expect(dialects.DremioDialect.spec.keywords?.split(" ")).toContain("qualify");
55+
expect(dialects.DremioDialect.spec.types?.split(" ")).toContain("struct");
56+
});
4957
});

src/dialects/dremio.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { SQLDialect, type SQLDialectSpec } from "@codemirror/lang-sql";
2+
3+
// Source: https://docs.dremio.com/current/reference/sql/reserved-keywords/
4+
const dremioKeywords =
5+
"abs access acos aes_decrypt aggregate all allocate allow alter analyze and any approx_count_distinct approx_percentile are array array_avg array_cat array_compact array_contains array_generate_range array_max array_max_cardinality array_min array_position array_remove array_remove_at array_size array_sum array_to_string arrow as ascii asensitive asin assign asymmetric at atan atan2 atomic authorization auto avg avoid base64 batch begin begin_frame begin_partition between bigint bin bin_pack binary binary_string bit bit_and bit_length bit_or bitwise_and bitwise_not bitwise_or bitwise_xor blob bool_and bool_or boolean both branch bround btrim by cache call called cardinality cascaded case cast catalog cbrt ceil ceiling change char char_length character character_length check chr classifier clob close cloud coalesce col_like collate collect column columns commit commits_older_than compute concat concat_ws condition connect constraint contains convert convert_from convert_replaceutf8 convert_timezone convert_to copy corr corresponding cos cosh cot count covar_pop covar_samp crc32 create cross cube cume_dist current current_catalog current_date current_date_utc current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cycle data databases datasets date date_add date_diff date_format date_part date_sub date_trunc datediff datetype day dayofmonth dayofweek dayofyear deallocate dec decimal declare dedupe_lookback_period default define degrees delete dense_rank deref describe deterministic dimensions disallow disconnect display distinct double drop dynamic e each element else empty empty_as_null encode end end-exec end_frame end_partition ends_with engine equals escape escape_char every except exec execute exists exp expire explain extend external extract factorial false fetch field field_delimiter file_format files filter first_value flatten float floor folder for foreign frame_row free from from_hex full function fusion geo_beyond geo_distance geo_nearby get global grant grants greatest group grouping groups hash hash64 having hex history hold hour identity if ilike imindir import in include indicator initcap initial inner inout insensitive insert instr int integer intersect intersection interval into is is_bigint is_int is_member is_substr is_utf8 is_varchar isdate isnumeric job join json_array json_arrayagg json_exists json_object json_objectagg json_query json_value lag language large last_day last_query_id last_value lateral lazy lcase lead leading least left length levenshtein like like_regex limit listagg ln local localsort localtime localtimestamp locate log log10 logs lower lpad lshift ltrim manifests map_keys map_values mask mask_first_n mask_hash mask_last_n mask_show_first_n mask_show_last_n masking match match_number match_recognize matches max max_file_size_mb maxdir md5 measures median member merge metadata method min min_file_size_mb min_input_files mindir minus minute missing mod modifies module monitor month months_between more multiset national natural nchar nclob ndv new next next_day no none normalize normalize_string not notification_provider notification_queue_reference now nth_value ntile null null_if nullif numeric nvl occurrences_regex octet_length of offset old older_than omit on one only open operate optimize or order orphan out outer over overlaps overlay ownership parameter parse_url partition partitions pattern per percent percent_rank percentile_cont percentile_disc period permute pi pivot pmod policy portion position position_regex pow power precedes precision prepare prev primary procedure project promotion qualify quarter query query_user quote quote_char radians random range rank raw reads real record_delimiter recursive ref reference references referencing reflection reflections refresh regex regexp_col_like regexp_extract regexp_like regexp_matches regexp_replace regexp_split regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxy regr_syy release remove rename repeat repeatstr replace reset result retain_last retain_last_commits retain_last_snapshots return returns reverse revoke rewrite right role rollback rollup round route row row_number rows rpad rshift rtrim running savepoint schemas scope scroll search second seek select sensitive session_user set sha sha1 sha256 sha512 show sign similar similar_to sin sinh size skip smallint snapshot snapshots snapshots_older_than some soundex specific specifictype split_part sql sqlexception sqlstate sqlwarning sqrt st_fromgeohash st_geohash start starts_with static statistics stddev stddev_pop stddev_samp stream string_binary strpos submultiset subset substr substring substring_index substring_regex succeeds sum symmetric system system_time system_user table tables tablesample tag tan tanh target_file_size_mb tblproperties then time time_format timestamp timestamp_format timestampadd timestampdiff timestamptype timezone_hour timezone_minute tinyint to to_char to_date to_hex to_number to_time to_timestamp toascii trailing transaction_timestamp translate translate_regex translation treat trigger trim trim_array trim_space true truncate typeof ucase uescape unbase64 unhex union unique unix_timestamp unknown unnest unpivot unset update upper upsert usage use user using vacuum value value_of values var_pop var_samp varbinary varchar varying versioning view views week weekofyear when whenever where width_bucket window with within without write xor year";
6+
7+
// Source: https://docs.dremio.com/dremio-cloud/sql/data-types/
8+
const dremioTypes =
9+
"bigint binary bit blob boolean char character clob date dec decimal double float int integer interval list map nchar nclob numeric real smallint struct time timestamp tinyint varbinary varchar varying";
10+
11+
const DremioDialectSpec: SQLDialectSpec = {
12+
doubleQuotedStrings: false,
13+
hashComments: false,
14+
spaceAfterDashes: false,
15+
identifierQuotes: '"',
16+
caseInsensitiveIdentifiers: true,
17+
keywords: dremioKeywords,
18+
types: dremioTypes,
19+
};
20+
21+
export const DremioDialect = SQLDialect.define(DremioDialectSpec);

src/dialects/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { BigQueryDialect } from "./bigquery.js";
2+
export { DremioDialect } from "./dremio.js";
23
export { DuckDBDialect } from "./duckdb/duckdb.js";

0 commit comments

Comments
 (0)