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

Reposition before recursion in fixes to avoid internal error #3658

Merged
merged 8 commits into from Jul 25, 2022

Conversation

alanmcruickshank
Copy link
Member

This resolves #3656 .

The issue was caused by child segments trying to apply fixes to segments inserted or edited by a parent which hadn't yet assigned position markers using _position_segments. This simply adds an intermediate step after applying fixes to the parent where we optionally reposition self before applying fixes to children.

This will add a very slight performance overhead, but I don't think the fix routine is currently the bottleneck. Potentially in future we might be able to more selectively run this routine, but for now this feels ok. Added a test case too.

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a simple enough fix. But would be good if @barrywhart can review too.

Copy link
Member

@barrywhart barrywhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, elegant fix! My intuition was that we needed to do the positioning "top down", but there was a high risk I'd fumble around for a loonngg time working out the details.

Thanks!! 🙌

@barrywhart
Copy link
Member

A dbt test is failing:

E               {% snapshot dim_aggregated_brand_hierarchy_snapshot %}
E               
E               {{
E                   config(
E                     strategy='check',
E                     unique_key='c1',
E                     target_schema='snapshots',
E                     check_cols='all'
E                   )
E               }}
E               
E             -     select c1
E             ?           ---
E             +     select
E             +         c1
E                   from
E                       foo
E               
E               {% endsnapshot %}

@alanmcruickshank
Copy link
Member Author

A dbt test is failing:

Yeah I saw this, and I'm really not sure why 🤔 . I feel like I've uncovered a bigger bug.

@alanmcruickshank
Copy link
Member Author

Ok, no I understand what's going on - by repositioning early - the matching of fixes to segments goes wrong. They no longer "find" their target because it's not the same segment. Will rethink approach.

@alanmcruickshank
Copy link
Member Author

NOTE: This now includes the changes from #3661 to confirm that they solve the test fails I was otherwise getting. That will make the diff look weird but means we should merge the other PR first if all looks good.

@codecov
Copy link

codecov bot commented Jul 24, 2022

Codecov Report

Merging #3658 (26c842c) into main (1977bc9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##             main     #3658   +/-   ##
========================================
  Coverage   99.99%   100.00%           
========================================
  Files         176       176           
  Lines       13348     13350    +2     
========================================
+ Hits        13347     13350    +3     
+ Misses          1         0    -1     
Impacted Files Coverage Δ
src/sqlfluff/core/parser/segments/base.py 100.00% <100.00%> (ø)
src/sqlfluff/core/config.py 100.00% <0.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1977bc9...26c842c. Read the comment docs.

@alanmcruickshank alanmcruickshank merged commit f9a3fe8 into main Jul 25, 2022
@alanmcruickshank alanmcruickshank deleted the ac/L032 branch July 25, 2022 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal error on fixing L032
3 participants