Skip to content

Commit

Permalink
Fully remove exasol_fs dialect and bump version (#1573)
Browse files Browse the repository at this point in the history
* Fully remove exasol dialect and bump version

* Update tests and docs

* add legacy dialect test

* Remove Exasol FS fixtures
  • Loading branch information
alanmcruickshank committed Oct 9, 2021
1 parent eb44ebd commit 2eaab2b
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 1,198 deletions.
3 changes: 1 addition & 2 deletions docs/source/dialects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ The dialect for `Google BigQuery`_.
Exasol
------

The dialect for `Exasol`_. Note that currently Exasol script and functions
create statements are currently defined in a separate ``exasol_fs`` dialect.
The dialect for `Exasol`_.

.. _`Exasol`: https://www.exasol.com/

Expand Down
15 changes: 14 additions & 1 deletion src/sqlfluff/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
FluffConfig,
SQLLintError,
SQLTemplaterError,
SQLFluffUserError,
dialect_selector,
dialect_readout,
TimingSummary,
Expand Down Expand Up @@ -208,8 +209,20 @@ def get_config(**kwargs) -> FluffConfig:
try:
# We're just making sure it exists at this stage - it will be fetched properly in the linter
dialect_selector(kwargs["dialect"])
except SQLFluffUserError as err:
click.echo(
colorize(
f"Error loading dialect '{kwargs['dialect']}': {str(err)}",
color=Color.red,
)
)
sys.exit(66)
except KeyError:
click.echo(f"Error: Unknown dialect '{kwargs['dialect']}'")
click.echo(
colorize(
f"Error: Unknown dialect '{kwargs['dialect']}'", color=Color.red
)
)
sys.exit(66)
# Instantiate a config object (filtering out the nulls)
overrides = {k: kwargs[k] for k in kwargs if kwargs[k] is not None}
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfluff/config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Config file for SQLFluff, mostly for version info for now
[sqlfluff]
version=0.6.9
version=0.7.0a1
stable_version=0.6.9
1 change: 1 addition & 0 deletions src/sqlfluff/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
SQLLexError,
SQLParseError,
SQLLintError,
SQLFluffUserError,
)

# Timing objects
Expand Down
12 changes: 11 additions & 1 deletion src/sqlfluff/core/dialects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Eventually it would be a good to dynamically discover dialects
# from any module beginning with "dialect_" within this folder.
from sqlfluff.core.dialects.base import Dialect
from sqlfluff.core.errors import SQLFluffUserError

_dialect_lookup = {
"ansi": ("dialect_ansi", "ansi_dialect"),
Expand All @@ -27,15 +28,24 @@
"postgres": ("dialect_postgres", "postgres_dialect"),
"snowflake": ("dialect_snowflake", "snowflake_dialect"),
"exasol": ("dialect_exasol", "exasol_dialect"),
"exasol_fs": ("dialect_exasol_fs", "exasol_fs_dialect"),
"tsql": ("dialect_tsql", "tsql_dialect"),
"hive": ("dialect_hive", "hive_dialect"),
"sqlite": ("dialect_sqlite", "sqlite_dialect"),
}

_legacy_dialects = {
"exasol_fs": (
"As of 0.7.0 the 'exasol_fs' dialect has been combined with "
"the 'exasol' dialect, and is no longer a standalone dialect. "
"Please use the 'exasol' dialect instead."
)
}


def load_raw_dialect(label: str, base_module: str = "sqlfluff.dialects") -> Any:
"""Dynamically load a dialect."""
if label in _legacy_dialects:
raise SQLFluffUserError(_legacy_dialects[label])
module, name = _dialect_lookup[label]
return getattr(import_module(f"{base_module}.{module}"), name)

Expand Down
4 changes: 4 additions & 0 deletions src/sqlfluff/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ def __repr__(self):
len(self.fixes),
self.description,
)


class SQLFluffUserError(ValueError):
"""An error which should be fed back to the user."""
76 changes: 0 additions & 76 deletions src/sqlfluff/dialects/dialect_exasol_fs.py

This file was deleted.

17 changes: 17 additions & 0 deletions test/cli/commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ def test__cli__command_dialect():
)


def test__cli__command_dialect_legacy():
"""Check the script raises the right exception on a legacy dialect."""
result = invoke_assert_code(
ret_code=66,
args=[
lint,
[
"-n",
"--dialect",
"exasol_fs",
"test/fixtures/linter/indentation_error_simple.sql",
],
],
)
assert "Please use the 'exasol' dialect instead." in result.stdout


@pytest.mark.parametrize(
"command",
[
Expand Down
19 changes: 0 additions & 19 deletions test/dialects/exasol_fs_test.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/dialects/exasol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
def test_dialect_exasol_specific_segment_parses(
segmentref, raw, caplog, dialect_specific_segment_parses
):
"""Test exasol_fs specific segments."""
"""Test exasol specific segments."""
dialect_specific_segment_parses(TEST_DIALECT, segmentref, raw, caplog)

This file was deleted.

23 changes: 0 additions & 23 deletions test/fixtures/parser/exasol_fs/CreateAdapterScriptStatement.yml

This file was deleted.

90 changes: 0 additions & 90 deletions test/fixtures/parser/exasol_fs/CreateFunctionStatement.sql

This file was deleted.

0 comments on commit 2eaab2b

Please sign in to comment.