question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snowflake, Postgres: Parse failure on concatention operator `||`

See original GitHub issue

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Concatenate operand || incorrectly parsed as two pipes. Both Snowflake and Postgres recognize || as concatenation operand, thus 'a' || 'b' -- => 'ab'. SQLFluff blames it’s incorrect syntax.

Expected Behaviour

'a' || 'b' should pass linting

Observed Behaviour

'a' || 'b' fails linting with:

Expected single whitespace between pipe ‘|’ and pipe ‘|’.

How to reproduce

echo “SELECT ‘a’ || ‘b’ AS c;” | sqlfluff lint --dialect postgres --disable-progress-bar - echo “SELECT ‘a’ || ‘b’ AS c;” | sqlfluff lint --dialect snowflake --disable-progress-bar -

Dialect

Snowflake Postgres

Version

sqlfluff, version 1.4.3 Python 3.10.9

Configuration

[sqlfluff] templater = jinja

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

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tunethewebcommented, Dec 14, 2022

SQLFluff 1.4.4 has been released with this fixed in it.

Apologies!

1reaction
tunethewebcommented, Dec 14, 2022

FYI adding this to your config fixes it:

[sqlfluff:layout:type:binary_operator]
spacing_within = touch

We’re adding it to the default config in #4168 and releasing another fix tonight, but if you can’t wait then apply above addition to your config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CONCAT , || — Snowflake Documentation
Concatenates one or more strings, or concatenates one or more binary values. If any of the values is null, the result is also...
Read more >
COPY TEXT array from Postgres to Snowflake - Stack Overflow
I am using Snowflake Python connector and it complains that "JSON parsing error". Any workaround this?
Read more >
PostgreSQL Cast Function 101: How to Convert One Data ...
The PostgreSQL CAST operator enables you to accomplish this. ... PostgreSQL Cast With Concatenation; PostgreSQL Cast String to Boolean ...
Read more >
From Postgres to Snowflake - Towards Data Science
It was a migration of ETL scripts from PostgreSQL to Snowflake. ... In other words, Snowflake won't give any error but everything will...
Read more >
15: 9.13. Text Search Functions and Operators - PostgreSQL
Returns the number of lexemes plus operators in the tsquery . ... The results are then concatenated in document order to produce the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found