Skip to content
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

feat(web-console): add materialized views support #405

Merged
merged 26 commits into from
Mar 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0601da4
feat(web-console): add materialized views support
emrberk Mar 13, 2025
b50f1c4
fix test failures
emrberk Mar 13, 2025
65abd14
add mat views e2e tests
emrberk Mar 13, 2025
7136d48
update submodule
emrberk Mar 13, 2025
7cf7b82
add env variable to context path test
emrberk Mar 13, 2025
4e3d5a3
Update packages/web-console/src/scenes/Schema/Table/index.tsx
emrberk Mar 14, 2025
1b38893
Update packages/web-console/src/scenes/Schema/VirtualTables/index.tsx
emrberk Mar 14, 2025
e862f1b
address review comments
emrberk Mar 14, 2025
641df5f
Update packages/web-console/src/scenes/Schema/Table/index.tsx
emrberk Mar 14, 2025
9104ea6
address reviews round 2
emrberk Mar 14, 2025
012d75d
add warning icon when base table is missing
emrberk Mar 15, 2025
6d17ca8
add ss debug
emrberk Mar 15, 2025
18e8001
disable expanding when there is no data source
emrberk Mar 15, 2025
62363af
latest revision
emrberk Mar 18, 2025
39cd00d
update submodule
emrberk Mar 18, 2025
cf60d3d
simplified view for table listing
emrberk Mar 19, 2025
ce5780a
remove react-contextmenu & introduce new context menu styling
emrberk Mar 19, 2025
636b73b
bring data-hooks back
emrberk Mar 20, 2025
df21284
update submodule
emrberk Mar 20, 2025
15fb26b
fixes for unresponsiveness and ci
emrberk Mar 20, 2025
3b0fb50
update submodule
emrberk Mar 20, 2025
b7dadcb
don't select children text on double click
emrberk Mar 20, 2025
67b3415
remove italic style in column types
emrberk Mar 20, 2025
2d32555
introduce icons for column types
emrberk Mar 20, 2025
304928e
tables expanded by default
emrberk Mar 20, 2025
4ddadfb
update submodule
emrberk Mar 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add mat views e2e tests
  • Loading branch information
emrberk committed Mar 13, 2025
commit 65abd1497d215c35fabd508a973a18a80e5c99a4
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ jobs:
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh start -d ./tmp/dbroot
env:
QDB_DEV_MODE_ENABLED: "true"
QDB_CAIRO_MAT_VIEW_ENABLED: "true"

- uses: actions/setup-node@v4
with:
48 changes: 48 additions & 0 deletions packages/browser-tests/cypress/commands.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,12 @@ const tableSchemas = {
my_secrets2: "CREATE TABLE IF NOT EXISTS 'my_secrets2' (secret STRING);",
};

const materializedViewSchemas = {
btc_trades_mv:
"CREATE MATERIALIZED VIEW IF NOT EXISTS btc_trades_mv WITH BASE btc_trades as (" +
"SELECT timestamp, avg(amount) FROM btc_trades SAMPLE BY 1m) PARTITION BY week;",
};

before(() => {
Cypress.on("uncaught:exception", (err) => {
// this error can be safely ignored
@@ -218,6 +224,19 @@ Cypress.Commands.add("createTable", (name) => {
});
});

Cypress.Commands.add("createMaterializedView", (name) => {
const authHeader = localStorage.getItem("basic.auth.header");
cy.request({
method: "GET",
url: `${baseUrl}/exec?query=${encodeURIComponent(
materializedViewSchemas[name]
)};`,
headers: {
Authorization: authHeader,
},
});
});

Cypress.Commands.add("dropTable", (name) => {
const authHeader = localStorage.getItem("basic.auth.header");
cy.request({
@@ -229,6 +248,19 @@ Cypress.Commands.add("dropTable", (name) => {
});
});

Cypress.Commands.add("dropMaterializedView", (name) => {
const authHeader = localStorage.getItem("basic.auth.header");
cy.request({
method: "GET",
url: `${baseUrl}/exec?query=${encodeURIComponent(
`DROP MATERIALIZED VIEW ${name};`
)}`,
headers: {
Authorization: authHeader,
},
});
});

Cypress.Commands.add("interceptQuery", (query, alias, response) => {
cy.intercept(
{
@@ -297,6 +329,22 @@ Cypress.Commands.add("expandTables", () => {
});
});

Cypress.Commands.add("collapseTables", () => {
cy.get("body").then((body) => {
if (body.find('[data-hook="collapse-tables"]').length > 0) {
cy.get('[data-hook="collapse-tables"]').click();
}
});
});

Cypress.Commands.add("expandMatViews", () => {
cy.get("body").then((body) => {
if (body.find('[data-hook="expand-materialized-views"]').length > 0) {
cy.get('[data-hook="expand-materialized-views"]').click();
}
});
});

Cypress.Commands.add("getEditorTabs", () => {
return cy.get(".chrome-tab");
});
56 changes: 56 additions & 0 deletions packages/browser-tests/cypress/integration/console/schema.spec.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ const tables = [
"gitlog",
];

const materializedViews = ["btc_trades_mv"];

describe("questdb schema with working tables", () => {
before(() => {
cy.loadConsoleWithAuth();
@@ -211,3 +213,57 @@ describe("questdb schema in read-only mode", () => {
cy.getByDataHook("create-table-panel").should("not.exist");
});
});

describe("materialized views", () => {
before(() => {
cy.loadConsoleWithAuth();

tables.forEach((table) => {
cy.createTable(table);
});
materializedViews.forEach((mv) => {
cy.createMaterializedView(mv);
});
cy.refreshSchema();
});

it("should create materialized views", () => {
cy.getByDataHook("expand-tables").contains(`Tables (${tables.length})`);
cy.getByDataHook("expand-materialized-views").contains(
`Materialized Views (${materializedViews.length})`
);

cy.expandTables();
cy.getByDataHook("schema-table-title").should("contain", "btc_trades");
cy.expandMatViews();
cy.getByDataHook("schema-table-title").should("contain", "btc_trades_mv");
});

it("should show the base table and copy DDL for a materialized view", () => {
cy.collapseTables();
cy.getByDataHook("schema-table-title").contains("btc_trades_mv").click();
cy.getByDataHook("schema-info-title").contains("DDL").should("exist");
cy.getByDataHook("copyable-value").should("exist").and("be.visible");
cy.getByDataHook("copy-value").should("exist").click({ force: true });

cy.window()
.its("navigator.clipboard")
.invoke("readText")
.should(
"match",
/^CREATE MATERIALIZED VIEW.*'btc_trades_mv' WITH BASE 'btc_trades'/
);
});

after(() => {
cy.loadConsoleWithAuth();

materializedViews.forEach((mv) => {
cy.dropMaterializedView(mv);
});

tables.forEach((table) => {
cy.dropTable(table);
});
});
});
3 changes: 2 additions & 1 deletion packages/web-console/src/scenes/Schema/Row/index.tsx
Original file line number Diff line number Diff line change
@@ -338,12 +338,13 @@ const Row = ({
<ValueWrapper>
<PopperHover
placement="top"
trigger={<TruncatedBox>{value}</TruncatedBox>}
trigger={<TruncatedBox data-hook="copyable-value">{value}</TruncatedBox>}
>
<Tooltip>{value}</Tooltip>
</PopperHover>
<CopyValueButton
skin="transparent"
data-hook="copy-value"
onClick={(e) => {
e.stopPropagation()
handleCopy(value)
3 changes: 3 additions & 0 deletions run_browser_tests.sh
Original file line number Diff line number Diff line change
@@ -36,6 +36,9 @@ echo "Proxy started, PID=$PID1"
# Switch dev mode on
export QDB_DEV_MODE_ENABLED=true

# Enable Materialized Views
export QDB_CAIRO_MAT_VIEW_ENABLED=true

# Running tests which assume authentication is off
./tmp/questdb-*/bin/questdb.sh start -d tmp/dbroot
yarn workspace browser-tests test:auth
Loading
Oops, something went wrong.