Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake autoincrement: autoincrement raises RuntimeError #1619

Closed
myschkyna opened this issue Oct 13, 2021 · 3 comments · Fixed by #1620
Closed

Snowflake autoincrement: autoincrement raises RuntimeError #1619

myschkyna opened this issue Oct 13, 2021 · 3 comments · Fixed by #1620
Labels
bug Something isn't working

Comments

@myschkyna
Copy link
Contributor

Expected Behaviour

I expected using auto increments to work without generating errors.

Observed Behaviour

A RuntimeError is raised using autoincrement columns, see code report / stacktrace below:

Traceback (most recent call last):
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/linter/runner.py", line 97, in run
    yield partial()
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/linter/linter.py", line 521, in lint_rendered
    parsed = cls.parse_rendered(rendered)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/linter/linter.py", line 311, in parse_rendered
    parsed, pvs = cls._parse_tokens(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/linter/linter.py", line 188, in _parse_tokens
    parsed: Optional[BaseSegment] = parser.parse(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/parser.py", line 32, in parse
    parsed = root_segment.parse(parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 870, in parse
    self.segments = self.expand(self.segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 276, in expand
    res = stmt.parse(parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 811, in parse
    m = parse_grammar.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 198, in match
    match = self._match_once(unmatched_segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 142, in _match_once
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 854, in match
    resp = elem.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 466, in match
    m = cls.match_grammar.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 331, in match
    content_match = super().match(content_segs, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/delimited.py", line 135, in match
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 198, in match
    match = self._match_once(unmatched_segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 142, in _match_once
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 854, in match
    resp = elem.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 466, in match
    m = cls.match_grammar.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 198, in match
    match = self._match_once(unmatched_segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 142, in _match_once
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 854, in match
    resp = elem.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/base.py", line 466, in match
    m = cls.match_grammar.match(segments=segments, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 198, in match
    match = self._match_once(unmatched_segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 142, in _match_once
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 198, in match
    match = self._match_once(unmatched_segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/anyof.py", line 142, in _match_once
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 331, in match
    content_match = super().match(content_segs, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/sequence.py", line 130, in match
    elem_match = elem.match(mid_seg, parse_context=ctx)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/delimited.py", line 135, in match
    match, _ = self._longest_trimmed_match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 217, in _longest_trimmed_match
    res_match: MatchResult = matcher.match(
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/match_wrapper.py", line 49, in wrapped_match_method
    m = func(self_cls, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/segments/ephemeral.py", line 90, in wrapped_match_method
    return func(self, segments, parse_context=parse_context)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 826, in match
    elem = self._get_elem(dialect=parse_context.dialect)
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/parser/grammar/base.py", line 805, in _get_elem
    return dialect.ref(self._get_ref())
  File "/Users/meesstrooker/sqlfluff/src/sqlfluff/core/dialects/base.py", line 232, in ref
    raise RuntimeError(
RuntimeError: Grammar refers to 'NumericLiteralValue' which was not found in the snowflake dialect

Steps to Reproduce

  1. Install the SQLFluff package version 0.7.0a4
  2. Create a file with content below
  3. Run sqlfluff lint --dialect snowflake

Content of SQL file generating the issue:

CREATE
OR REPLACE TABLE test_schema.test_table (test_column NUMBER autoincrement (0, 1));

Dialect

Snowflake

Version

sqlfluff, version 0.7.0a4

Configuration

[sqlfluff]
dialect = snowflake
exclude_rules = L009,L011,L029,L031,L034

[sqlfluff:rules]
tab_space_size = 2

[sqlfluff:rules:L010]  # Keywords
capitalisation_policy = upper

[sqlfluff:rules:L014]  # Tables, columns, views
extended_capitalisation_policy = lower

[sqlfluff:rules:L030]  # Function names
capitalisation_policy = upper

[sqlfluff:rules:L040]  # Null & Boolean Literals
capitalisation_policy = upper

[sqlfluff:rules:L016] # Max line length
max_line_length = 120
@myschkyna myschkyna added the bug Something isn't working label Oct 13, 2021
@myschkyna
Copy link
Contributor Author

@tunetheweb is it possible to create a new pre-release containing the latest fixes? If not no problem, I'll keep an eye on the release notes :)

@tunetheweb
Copy link
Member

We did better than that and created a full release. 0.7.0 is out!!

@myschkyna
Copy link
Contributor Author

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants