Code Monkey home page Code Monkey logo

Comments (2)

Guojcc avatar Guojcc commented on August 17, 2024 1

I hava already submitted a bug to sqlfluff,
Please help to supplement other content

[#5601]

from sqllineage.

reata avatar reata commented on August 17, 2024

This is a parser issue with sqlfluff that we can verify with:

sqlfluff parse test.sql --dialect=tsql

There's only one statement parsed when GROUP BY clause is added:

select id from foo group by id 
select * from bar
[L:  1, P:  1]      |file:
[L:  1, P:  1]      |    batch:
[L:  1, P:  1]      |        statement:
[L:  1, P:  1]      |            select_statement:
[L:  1, P:  1]      |                select_clause:
[L:  1, P:  1]      |                    keyword:                                  'select'
[L:  1, P:  7]      |                    [META] indent:
[L:  1, P:  7]      |                    whitespace:                               ' '
[L:  1, P:  8]      |                    select_clause_element:
[L:  1, P:  8]      |                        column_reference:
[L:  1, P:  8]      |                            naked_identifier:                 'id'
[L:  1, P: 10]      |                    [META] dedent:
[L:  1, P: 10]      |                whitespace:                                   ' '
[L:  1, P: 11]      |                from_clause:
[L:  1, P: 11]      |                    keyword:                                  'from'
[L:  1, P: 15]      |                    whitespace:                               ' '
[L:  1, P: 16]      |                    from_expression:
[L:  1, P: 16]      |                        [META] indent:
[L:  1, P: 16]      |                        from_expression_element:
[L:  1, P: 16]      |                            table_expression:
[L:  1, P: 16]      |                                table_reference:
[L:  1, P: 16]      |                                    naked_identifier:         'foo'
[L:  1, P: 19]      |                        [META] dedent:
[L:  1, P: 19]      |                whitespace:                                   ' '
[L:  1, P: 20]      |                groupby_clause:
[L:  1, P: 20]      |                    keyword:                                  'group'
[L:  1, P: 25]      |                    whitespace:                               ' '
[L:  1, P: 26]      |                    keyword:                                  'by'
[L:  1, P: 28]      |                    [META] indent:
[L:  1, P: 28]      |                    whitespace:                               ' '
[L:  1, P: 29]      |                    column_reference:
[L:  1, P: 29]      |                        naked_identifier:                     'id'
[L:  1, P: 31]      |                    whitespace:                               ' '
[L:  1, P: 32]      |                    newline:                                  '\n'
[L:  2, P:  1]      |                    expression:
[L:  2, P:  1]      |                        select_statement:
[L:  2, P:  1]      |                            select_clause:
[L:  2, P:  1]      |                                keyword:                      'select'
[L:  2, P:  7]      |                                [META] indent:
[L:  2, P:  7]      |                                whitespace:                   ' '
[L:  2, P:  8]      |                                select_clause_element:
[L:  2, P:  8]      |                                    wildcard_expression:
[L:  2, P:  8]      |                                        wildcard_identifier:
[L:  2, P:  8]      |                                            star:             '*'
[L:  2, P:  9]      |                                [META] dedent:
[L:  2, P:  9]      |                            whitespace:                       ' '
[L:  2, P: 10]      |                            from_clause:
[L:  2, P: 10]      |                                keyword:                      'from'
[L:  2, P: 14]      |                                whitespace:                   ' '
[L:  2, P: 15]      |                                from_expression:
[L:  2, P: 15]      |                                    [META] indent:
[L:  2, P: 15]      |                                    from_expression_element:
[L:  2, P: 15]      |                                        table_expression:
[L:  2, P: 15]      |                                            table_reference:
[L:  2, P: 15]      |                                                naked_identifier:  'bar'
[L:  2, P: 18]      |                                    [META] dedent:
[L:  2, P: 18]      |                    [META] dedent:
[L:  2, P: 18]      |    newline:                                                  '\n'
[L:  3, P:  1]      |    [META] end_of_file:

Whereas removing GROUP BY results in the correct AST with two statements:

select id from foo
select * from bar
[L:  1, P:  1]      |file:
[L:  1, P:  1]      |    batch:
[L:  1, P:  1]      |        statement:
[L:  1, P:  1]      |            select_statement:
[L:  1, P:  1]      |                select_clause:
[L:  1, P:  1]      |                    keyword:                                  'select'
[L:  1, P:  7]      |                    [META] indent:
[L:  1, P:  7]      |                    whitespace:                               ' '
[L:  1, P:  8]      |                    select_clause_element:
[L:  1, P:  8]      |                        column_reference:
[L:  1, P:  8]      |                            naked_identifier:                 'id'
[L:  1, P: 10]      |                    [META] dedent:
[L:  1, P: 10]      |                whitespace:                                   ' '
[L:  1, P: 11]      |                from_clause:
[L:  1, P: 11]      |                    keyword:                                  'from'
[L:  1, P: 15]      |                    whitespace:                               ' '
[L:  1, P: 16]      |                    from_expression:
[L:  1, P: 16]      |                        [META] indent:
[L:  1, P: 16]      |                        from_expression_element:
[L:  1, P: 16]      |                            table_expression:
[L:  1, P: 16]      |                                table_reference:
[L:  1, P: 16]      |                                    naked_identifier:         'foo'
[L:  1, P: 19]      |                        [META] dedent:
[L:  1, P: 19]      |        whitespace:                                           ' '
[L:  1, P: 20]      |        newline:                                              '\n'
[L:  2, P:  1]      |        statement:
[L:  2, P:  1]      |            select_statement:
[L:  2, P:  1]      |                select_clause:
[L:  2, P:  1]      |                    keyword:                                  'select'
[L:  2, P:  7]      |                    [META] indent:
[L:  2, P:  7]      |                    whitespace:                               ' '
[L:  2, P:  8]      |                    select_clause_element:
[L:  2, P:  8]      |                        wildcard_expression:
[L:  2, P:  8]      |                            wildcard_identifier:
[L:  2, P:  8]      |                                star:                         '*'
[L:  2, P:  9]      |                    [META] dedent:
[L:  2, P:  9]      |                whitespace:                                   ' '
[L:  2, P: 10]      |                from_clause:
[L:  2, P: 10]      |                    keyword:                                  'from'
[L:  2, P: 14]      |                    whitespace:                               ' '
[L:  2, P: 15]      |                    from_expression:
[L:  2, P: 15]      |                        [META] indent:
[L:  2, P: 15]      |                        from_expression_element:
[L:  2, P: 15]      |                            table_expression:
[L:  2, P: 15]      |                                table_reference:
[L:  2, P: 15]      |                                    naked_identifier:         'bar'
[L:  2, P: 18]      |                        [META] dedent:
[L:  2, P: 18]      |    newline:                                                  '\n'
[L:  3, P:  1]      |    [META] end_of_file:

We need to fix it on sqlfluff side.

from sqllineage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.