Skip to content

feat(query): apply pragmas setting to Table Preview queries #2575

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

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 16, 2025

Fixes #2574

This PR implements pragma support for Table Preview queries, ensuring that the "Pragmas" setting from the Query Settings Dialog is consistently applied to all query executions, including table previews.

🎯 Changes Made

Core Implementation

  • Modified TablePreview.tsx: Added integration with query settings
    • Import useQueryExecutionSettings hook to access current user settings
    • Import prepareQueryWithPragmas utility function from existing pragma infrastructure
    • Apply pragmas to preview queries before execution using the same logic as regular queries

Test Coverage

  • Added TablePreview.test.tsx: Comprehensive unit tests covering:
    • ✅ Pragma prepending for table preview queries
    • ✅ Empty pragmas handling
    • ✅ Multiple pragmas support
    • ✅ Pragmas without semicolon handling

🔧 Technical Implementation

Before:

const query = `select * from \`${path}\` limit 101`;

After:

const [querySettings] = useQueryExecutionSettings();
const baseQuery = `select * from \`${path}\` limit 101`;
const query = prepareQueryWithPragmas(baseQuery, querySettings.pragmas);

This approach:

🧪 Testing

  • ✅ All new tests pass (4/4 table preview pragma tests)
  • ✅ All existing pragma tests continue to pass (6/6 existing tests)
  • ✅ TypeScript compilation passes without errors
  • ✅ No regression in existing functionality

📸 UI Verification

YDB Embedded UI Screenshot

Frontend successfully builds and runs - network error shown is expected when no YDB backend is available

🚀 Usage

When a user sets pragmas in the Query Settings Dialog (e.g., PRAGMA OrderedColumns;), table preview queries now automatically include these pragmas:

User's pragma setting:

PRAGMA OrderedColumns;

Resulting table preview query:

PRAGMA OrderedColumns;

select * from `myTable` limit 101

This ensures consistent behavior between regular query execution and table previews, completing the pragma feature implementation across all query types in the YDB Embedded UI.

This pull request was created as a result of the following prompt from Copilot chat.

Implement the feature described in Issue #2574, so that whenever a Table Preview query is run, the value of the current 'Pragmas' setting from the Query Settings Dialog is prepended to the SQL query, just like regular query executions.

Requirements:

  • Extract the pragmas setting from the user's Query Settings when running table preview queries.
  • Prepend pragmas to the SQL query for all table preview executions.
  • Update/add tests to verify the new behavior.
  • Update documentation and i18n as needed.

Reference: #2574


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

CI Results

Test Status: ❌ FAILED

📊 Full Report

Total Passed Failed Flaky Skipped
354 348 1 3 2
Test Changes Summary ⏭️2

⏭️ Skipped Tests (2)

  1. Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view (tenant/diagnostics/tabs/queries.test.ts)
  2. Copy result button copies to clipboard (tenant/queryEditor/queryEditor.test.ts)

Bundle Size: ✅

Current: 85.17 MB | Main: 85.16 MB
Diff: +0.49 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Co-authored-by: adameat <34044711+adameat@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Apply pragmas setting to Table Preview queries feat(query): apply pragmas setting to Table Preview queries Jul 16, 2025
Copilot finished work on behalf of adameat July 16, 2025 10:32
@Copilot Copilot AI requested a review from adameat July 16, 2025 10:32
@adameat adameat marked this pull request as ready for review July 16, 2025 11:07
@Raubzeug Raubzeug added this pull request to the merge queue Jul 16, 2025
Merged via the queue into main with commit ff85ffc Jul 16, 2025
12 of 17 checks passed
@Raubzeug Raubzeug deleted the copilot/fix-c9216e01-cc23-4ee4-821f-7d0416dfba72 branch July 16, 2025 11:14
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.

Use pragmas setting in Table Preview queries
3 participants