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
latest revision
  • Loading branch information
emrberk committed Mar 18, 2025
commit 62363af043ed29dc4eeb90fb4518748638e5f064
60 changes: 38 additions & 22 deletions packages/browser-tests/cypress/integration/console/schema.spec.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ describe("questdb schema with working tables", () => {
cy.getByDataHook("schema-table-title").should("contain", table);
});
cy.getByDataHook("schema-filter-suspended-button").should("not.exist");
cy.getByDataHook("schema-suspension-popover-trigger").should("not.exist");
cy.getByDataHook("schema-row-error-icon").should("not.exist");
});

it("should filter the table with input field", () => {
@@ -101,9 +101,11 @@ describe("questdb schema with suspended tables with Linux OS error codes", () =>
cy.getByDataHook("schema-filter-suspended-button").click();
});

it("should show the suspension dialog on click with details for btc_trades", () => {
cy.get('input[name="table_filter"]').click().type("btc_trades");
cy.getByDataHook("schema-suspension-dialog-trigger").click();
it("should show the suspension dialog on context menu click with details for btc_trades", () => {
cy.getByDataHook("schema-table-title").contains("btc_trades").rightclick();
cy.getByDataHook("table-context-menu-resume-wal")
.filter(":visible")
.click();
cy.getByDataHook("schema-suspension-dialog").should(
"have.attr",
"data-table-name",
@@ -121,8 +123,10 @@ describe("questdb schema with suspended tables with Linux OS error codes", () =>
});

it("should resume WAL for btc_trades from the suspension popover", () => {
cy.get('input[name="table_filter"]').click().type("btc_trades");
cy.contains("Suspended").click();
cy.getByDataHook("schema-table-title").contains("btc_trades").rightclick();
cy.getByDataHook("table-context-menu-resume-wal")
.filter(":visible")
.click();
cy.getByDataHook("schema-suspension-dialog-restart-transaction").click();
cy.getByDataHook("schema-suspension-dialog-dismiss").click();
cy.getByDataHook("schema-suspension-dialog").should("not.exist");
@@ -241,15 +245,19 @@ describe("materialized views", () => {
cy.expandTables();
cy.getByDataHook("schema-table-title").should("contain", "btc_trades");
cy.expandMatViews();
cy.getByDataHook("schema-table-title").should("contain", "btc_trades_mv");
cy.getByDataHook("schema-matview-title").should("contain", "btc_trades_mv");
});

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

if (Cypress.isBrowser("electron")) {
cy.window()
@@ -262,22 +270,30 @@ describe("materialized views", () => {
}
});

it("should show a warning icon when base table is dropped", () => {
cy.loadConsoleWithAuth();
cy.dropTable("btc_trades");
cy.wait(1000);
it("should show a warning icon and tooltip when the view is invalidated", () => {
cy.intercept({
method: "GET",
pathname: "/exec",
query: {
query: "materialized_views()",
},
},
(req) => {
req.continue((res) => {
// [view_name, refresh_type, base_table_name, last_refresh_timestamp, view_sql, view_table_dir_name, invalidation_reason, view_status, base_table_txn, applied_base_table_txn]
res.body.dataset[0][6] = "this is an invalidation reason";
res.body.dataset[0][7] = "invalid";
return res;
});
}
);
cy.refreshSchema();

cy.expandMatViews();
cy.getByDataHook("schema-table-title").contains("btc_trades_mv").click();

cy.get('[data-hook="base-table-warning"]')
.should("exist")
.trigger("mouseover");
cy.getByDataHook("schema-row-error-icon").trigger("mouseover");

cy.getByDataHook("tooltip").should(
"contain",
"Base table has been dropped"
"Materialized view is invalid: this is an invalidation reason"
);
});

22 changes: 6 additions & 16 deletions packages/web-console/src/components/ContextMenu/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -29,28 +29,18 @@ import { color } from "../../utils"

const StyledMenuItem = styled(ReactMenuItem)`
color: ${color("foreground")};
padding: 0.5rem 1.5rem;
display: flex;
justify-content: space-between;
cursor: pointer;
padding: 0.5rem 1rem;

&:hover {
background: ${color("selection")};
}
`

const StyledDivider = styled(ReactMenuItem)`
background: ${color("foreground")};
height: 1px;
width: 100%;
margin: 0.5rem 0;
padding: 0 1rem;
`

type Props = {} & MenuItemProps

const MenuItem = ({ children, divider, ...rest }: PropsWithChildren<Props>) => {
const Component = divider ? StyledDivider : StyledMenuItem

return <Component {...rest}>{children}</Component>
}
const MenuItem = ({ children, ...rest }: PropsWithChildren<MenuItemProps>) => (
<StyledMenuItem {...rest}>{children}</StyledMenuItem>
)

export default MenuItem
4 changes: 2 additions & 2 deletions packages/web-console/src/components/Tree/index.tsx
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ import Row from "../../scenes/Schema/Row"
import styled from "styled-components"
import { WrapWithIf } from "../"

export type TreeNodeKind = "column" | "table" | "folder" | "info"
export type TreeNodeKind = "column" | "table" | "matview" | "folder"

export type TreeNodeRenderParams = {
toggleOpen: ToggleOpen
@@ -65,7 +65,7 @@ const Ul = styled.ul`

const Li = styled.li`
list-style: none;
padding: 0 1rem;
padding-left: 1rem;
`

const Leaf = (leaf: TreeNode) => {
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.