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

redshift dialect: SELECT TOP xx rows causing parsing error #3531

Closed
2 of 3 tasks
6e2f61 opened this issue Jul 1, 2022 · 0 comments · Fixed by #3582
Closed
2 of 3 tasks

redshift dialect: SELECT TOP xx rows causing parsing error #3531

6e2f61 opened this issue Jul 1, 2022 · 0 comments · Fixed by #3582
Labels
bug Something isn't working good first issue Good for newcomers redshift Issues relating to Amazon Redshift dialect

Comments

@6e2f61
Copy link

6e2f61 commented Jul 1, 2022

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Trying to select TOP X values from select throws parsing error.

Expected Behaviour

Add support for the view TOP keyword.

Observed Behaviour

Query not currently supported, results in parse errors:

== [app/top.sql] FAIL                                                                                                                               
L:   2 | P:   7 |  PRS | Line 2, Position 7: Found unparsable section: ' TOP 10\n example_value_col'
WARNING: Parsing errors found and dialect is set to 'redshift'. Have you configured your dialect correctly?
All Finished 📜 🎉!

How to reproduce

Create a test file containing as below and try to lint/parse with sqlfluff.

CREATE OR REPLACE VIEW example_schema.v_example AS
SELECT TOP 10
    example_value_col
FROM
    example_schema.some_table
ORDER BY
    example_value_col

Dialect

redshift

Version

sqlfluff, version 1.0.0
Python 3.8.10

Configuration

# https://docs.sqlfluff.com/en/stable/configuration.html#config

[sqlfluff]
dialect = redshift
templater = jinja
rules = all
exclude_rules = L034
# Controls SQLFluff output, see max_line_length for SQL output
output_line_length = 118
ignore_templated_areas = true
sql_file_exts = .sql,.sql.j2,.dml,.ddl

[sqlfluff:indentation]
indented_joins = false
indented_using_on = true
template_blocks_indent = true

[sqlfluff:rules]
tab_space_size = 4
max_line_length = 118
indent_unit = space
comma_style = trailing

# https://docs.sqlfluff.com/en/stable/rules.html#ruleref

[sqlfluff:rules:L003]
hanging_indents = true

[sqlfluff:rules:L007]
operator_new_lines = after

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

[sqlfluff:rules:L011]
# of tables
aliasing = explicit

[sqlfluff:rules:L012]
# of columns
aliasing = explicit

[sqlfluff:rules:L013]
allow_scalar = false

[sqlfluff:rules:L014]
# Unquoted identifiers
extended_capitalisation_policy = lower

[sqlfluff:rules:L016]
ignore_comment_clauses = true
ignore_comment_lines = true
indent_unit = space
max_line_length = 160
tab_space_size = 4

[sqlfluff:rules:L019]
comma_style = leading

[sqlfluff:rules:L022]
comma_style = leading

[sqlfluff:rules:L029]
unquoted_identifiers_policy = all
ignore_words = character_maximum_length, column_name, columns, constraint_name, constraint_schema, data_type, role, status, table_name, type

[sqlfluff:rules:L030]
extended_capitalisation_policy = upper

[sqlfluff:rules:L031]
# Avoid table aliases in from clauses and join conditions
force_enable = true

[sqlfluff:rules:L038]
select_clause_trailing_comma = forbid

[sqlfluff:rules:L040]
capitalisation_policy = upper

[sqlfluff:rules:L051]
fully_qualify_join_types = both

[sqlfluff:rules:L052]
multiline_newline = false
require_final_semicolon = false

[sqlfluff:rules:L054]
group_by_and_order_by_style = explicit

[sqlfluff:rules:L057]
additional_allowed_characters = "{}"
unquoted_identifiers_policy = all
quoted_identifiers_policy = all
allow_space_in_identifier = false

[sqlfluff:rules:L059]
prefer_quoted_identifiers = false

[sqlfluff:rules:L063]
extended_capitalisation_policy = upper

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@6e2f61 6e2f61 added the bug Something isn't working label Jul 1, 2022
@tunetheweb tunetheweb added good first issue Good for newcomers redshift Issues relating to Amazon Redshift dialect labels Jul 2, 2022
pdebelak added a commit to pdebelak/sqlfluff that referenced this issue Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers redshift Issues relating to Amazon Redshift dialect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants