Skip to content

feat(sql): add IF EXISTS support to TRUNCATE TABLE statement#5856

Closed
akashadsare wants to merge 3 commits intoquestdb:masterfrom
akashadsare:feature/truncate-table-if-exists
Closed

feat(sql): add IF EXISTS support to TRUNCATE TABLE statement#5856
akashadsare wants to merge 3 commits intoquestdb:masterfrom
akashadsare:feature/truncate-table-if-exists

Conversation

@akashadsare
Copy link
Copy Markdown
Contributor

@akashadsare akashadsare commented Jul 6, 2025

Description

This PR implements support for the IF EXISTS clause in TRUNCATE TABLE statements, addressing issue #5763.

Changes

  • ✅ Added parsing for TRUNCATE TABLE IF EXISTS table_name syntax
  • ✅ Implemented graceful handling of non-existent tables when IF EXISTS is used
  • ✅ Maintained full backward compatibility with existing TRUNCATE TABLE functionality
  • ✅ Added comprehensive test coverage

Examples

-- New syntax that succeeds silently if table doesn't exist
TRUNCATE TABLE IF EXISTS my_table;

-- Works with multiple tables
TRUNCATE TABLE IF EXISTS table1, table2, table3;

-- Compatible with all existing options
TRUNCATE TABLE IF EXISTS my_table KEEP SYMBOL MAPS;

Note

CI/CD pipeline shows infrastructure errors unrelated to this change:

  • Rust test failures (this is a Java-only change)
  • Missing log files (build system issue)
  • Artifact publishing problems (infrastructure issue)

Local testing shows all functionality works correctly.

Fixed typo: 'Ukranian' -> 'Ukrainian' in the translations list
- Add support for 'TRUNCATE TABLE IF EXISTS table_name' syntax
- Silently succeeds when truncating non-existent tables with IF EXISTS
- Maintains backward compatibility with existing TRUNCATE TABLE syntax
- Add comprehensive test coverage for new functionality

Fixes questdb#5763
@akashadsare akashadsare changed the title feat: Add IF EXISTS support to TRUNCATE TABLE statement addressing issue #5763 Feature: Add IF EXISTS support to TRUNCATE TABLE statement addressing issue #5763 Jul 6, 2025
@nwoolmer nwoolmer added the SQL Issues or changes relating to SQL execution label Jul 6, 2025
@bhavya-gupta0802
Copy link
Copy Markdown

@akashadsare please provide this issue to me

@bhavya-gupta0802
Copy link
Copy Markdown

@mationai please provide this bug to me

@ideoma ideoma changed the title Feature: Add IF EXISTS support to TRUNCATE TABLE statement addressing issue #5763 feat(sql): add IF EXISTS support to TRUNCATE TABLE statement Jul 8, 2025
@mationai
Copy link
Copy Markdown
Contributor

@mationai please provide this bug to me

Sorry, not involved with this issue

@bluestreak01
Copy link
Copy Markdown
Member

work merged into #6020

thank you @akashadsare - your contribution will be acknowledged in the release notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants