Skip to content

Fix language injections sticking after language comment removed (#46134) (cherry-pick to preview)#47790

Merged
JosephTLyons merged 1 commit intov0.221.xfrom
cherry-pick-v0.221.x-797ad8cf
Jan 27, 2026
Merged

Fix language injections sticking after language comment removed (#46134) (cherry-pick to preview)#47790
JosephTLyons merged 1 commit intov0.221.xfrom
cherry-pick-v0.221.x-797ad8cf

Conversation

@zed-zippy
Copy link
Contributor

@zed-zippy zed-zippy bot commented Jan 27, 2026

Cherry-pick of #46134 to preview


Closes #46104

Release Notes:

  • Fixed language injections sticking after language comment removed

This is working well for the Python SQL comments

comment_sync_demo

from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()

# sql
cmd = "SELECT col1, col2 FROM tbl"

df = spark.sql(  # sql
    """
    WITH cte AS (
        SELECT col1, col2, COUNT(*) AS n
        FROM tbl
        GROUP BY ALL
    )
    SELECT * FROM cte
    """
)

And go comments

comment_sync_demo_go_updated

package main

func test() {
    var _ = /* sql */ `SELECT id, name FROM products`
    var _ = /* sql */ "SELECT id, name FROM products"

    var _ = /* sql */ `SELECT id, name FROM products`

    var _ = /* sql*/ "SELECT id, name FROM products"
}

Note: f04b252dd9 was a simpler implementation that worked for
non-inline comments in Python, but produced the following Go behavior

comment_sync_demo_go


Co-authored-by: Joseph T. Lyons JosephTLyons@gmail.com

Closes #46104

Release Notes: 

- Fixed language injections sticking after language comment removed

---

This is working well for the Python SQL comments

![comment_sync_demo](https://github.com/user-attachments/assets/ba5160ce-4867-4b49-9f44-141ddc2730a1)

```python
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()

# sql
cmd = "SELECT col1, col2 FROM tbl"

df = spark.sql(  # sql
    """
    WITH cte AS (
        SELECT col1, col2, COUNT(*) AS n
        FROM tbl
        GROUP BY ALL
    )
    SELECT * FROM cte
    """
)
```


And go comments

![comment_sync_demo_go_updated](https://github.com/user-attachments/assets/73e81a94-e8fc-4dc3-82f8-09e966d35bc9)


```go
package main

func test() {
    var _ = /* sql */ `SELECT id, name FROM products`
    var _ = /* sql */ "SELECT id, name FROM products"

    var _ = /* sql */ `SELECT id, name FROM products`

    var _ = /* sql*/ "SELECT id, name FROM products"
}
```

Note: `f04b252dd9` was a simpler implementation that worked for
non-inline comments in Python, but produced the following Go behavior

![comment_sync_demo_go](https://github.com/user-attachments/assets/40336705-9799-4b0a-b457-4974d172e1c8)

---------

Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 27, 2026
@JosephTLyons JosephTLyons merged commit 26699ff into v0.221.x Jan 27, 2026
43 of 45 checks passed
@JosephTLyons JosephTLyons deleted the cherry-pick-v0.221.x-797ad8cf branch January 27, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants