Skip to content

feat(sql): add support for indexing of symbol columns in materialized views#5961

Merged
bluestreak01 merged 4 commits intomasterfrom
vi_mat_view_index
Jul 20, 2025
Merged

feat(sql): add support for indexing of symbol columns in materialized views#5961
bluestreak01 merged 4 commits intomasterfrom
vi_mat_view_index

Conversation

@bluestreak01
Copy link
Copy Markdown
Member

@bluestreak01 bluestreak01 commented Jul 18, 2025

Supported syntax:

SQL will calculate correct index capacity automatically based on the current data in the view:

alter materialized view view_1 alter column sym add index;

Index capacity can still be specified manually:

alter materialized view view_1 alter column sym add index capacity 16;

Drop index:

alter materialized view view_1 alter column sym drop index;

@bluestreak01 bluestreak01 changed the title feat(core): add support for indexing of symbol columns in materialized views feat(sql): add support for indexing of symbol columns in materialized views Jul 18, 2025
@bluestreak01 bluestreak01 added the SQL Issues or changes relating to SQL execution label Jul 19, 2025
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 51 / 55 (92.73%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/SqlCompilerImpl.java 51 55 92.73%

@rohit-7620
Copy link
Copy Markdown

Fix #: Prevent Crash on NULL in WHERE Clause

Description
This PR fixes a crash in QuestDB when executing a SELECT query with a NULL value in the WHERE clause, as reported in #. The issue was caused by a missing null check in the WhereClauseParser. This PR adds a null check to handle NULL comparisons safely, ensuring the query returns an empty result set instead of crashing.

Changes Made

Added null check in WhereClauseParser.evaluate to handle NULL values in WHERE clauses.

Added a new test case to verify the fix.

No changes to public APIs or documentation required.

Reproducer
To verify the fix:

Start QuestDB (version 7.4.0 or later with this patch).

Create a table:

CREATE TABLE test (ts TIMESTAMP, value INT) TIMESTAMP(ts);

Insert a record with a NULL value:

INSERT INTO test VALUES ('2025-07-19T10:00:00', NULL);

Run the query:

SELECT * FROM test WHERE value = NULL;

Expected result: Query returns an empty result set without crashing.

Testing

Added JUnit test testNullInWhereClause in core/src/test/java/io/questdb/test/WhereClauseTest.java.

Ran mvn test to confirm all tests pass.

Manually tested the reproducer query on a local QuestDB instance.

Related Issue
Fixes #

Checklist

Code adheres to QuestDB coding standards.

Tests added to cover the fix.

No breaking changes introduced.

Reproducer provided for verification.

Additional Notes
Please let me know if further tests or modifications are needed. Happy to address any feedback!

Submitted by
rohit-7620

@bluestreak01
Copy link
Copy Markdown
Member Author

@rohit-7620 please don't spam the PRs

@bluestreak01 bluestreak01 merged commit c06f408 into master Jul 20, 2025
34 checks passed
@bluestreak01 bluestreak01 deleted the vi_mat_view_index branch July 20, 2025 13:26
javier added a commit to questdb/documentation that referenced this pull request Sep 3, 2025
Added docs pages for alter matview.. add index/drop index, related to
questdb/questdb#5961
Changed concept pages for indices and matviews
Sorted the left sidebar slightly, as it was out of alphabetical order
for some SQL subsections.
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.

3 participants