Skip to content

Conversation

isabelizimm
Copy link
Contributor

@isabelizimm isabelizimm commented Aug 21, 2025

Since we store the active where and sort clauses, we can probably just reuse them to show to users. Since these are what is filtering/sorting the data explorer, I assume they won't be stale. I haven't dug around too much to see if there are any other drawbacks to reusing these, but it does make this feature quite simple!

Release Notes

New Features

Bug Fixes

  • N/A

QA Notes

  • Open up "flights.parquet" file in positron-qa-examples
  • Do some filters, sorts, etc. DuckDB displays the number of rows only if it's less than 9999, so if you want to do a quick sanity check that it's equivalent to number of rows in the data explorer, make sure you narrow it down accordingly!
  • Convert to Code button -> copy to clipboard
  • In Python, pip install duckdb
  • Run ⏬
import duckdb

conn = duckdb.connect()
conn.execute("CREATE TABLE flights AS SELECT * FROM 'data-files/flights/flights.parquet'")

conn.execute(""" 
ADD COPIED SQL HERE
""").df()

Copy link

github-actions bot commented Aug 21, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@isabelizimm isabelizimm marked this pull request as ready for review September 2, 2025 21:13
@isabelizimm isabelizimm requested a review from Copilot September 2, 2025 21:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements DuckDB SQL backend support for the "convert to code" feature in the data explorer. The change enables users to convert their current data explorer view (including filters and sorts) into executable SQL code that can be copied and run in Python with DuckDB.

Key changes:

  • Added support for converting data explorer state to SQL code
  • Implemented code syntax suggestion functionality
  • Updated backend state to indicate convert-to-code support

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
extensions/positron-duckdb/src/extension.ts Implements convert-to-code functionality with SQL generation and adds RPC handler support
extensions/positron-duckdb/src/test/extension.test.ts Updates test expectations to reflect convert-to-code support status

convert_to_code: {
support_status: SupportStatus.Supported,
code_syntaxes: [{
code_syntax_name: "SQL"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

by default, it doesn't seem like there is syntax highlighting available unless you have an extension with a sql lsp

@isabelizimm isabelizimm requested a review from wesm September 2, 2025 21:37
@wesm
Copy link
Contributor

wesm commented Sep 3, 2025

Do you want to try to add some extension tests? I can also add some in a follow up PR. The code changes look good to me though

@isabelizimm
Copy link
Contributor Author

I can add some extension tests! It looks like there are context files for positron-duckdb, so I'll try my hand at using Claude Code for building them out. 🤞

@isabelizimm isabelizimm merged commit 9efe836 into main Sep 4, 2025
9 checks passed
@isabelizimm isabelizimm deleted the sql-convert branch September 4, 2025 19:37
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants