Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-java@v4
with:
java-version: "17"
java-version: "25"
distribution: "temurin"
cache: maven

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_with_context_path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-java@v4
with:
java-version: "17"
java-version: "25"
distribution: "temurin"
cache: maven

Expand Down
3 changes: 3 additions & 0 deletions e2e/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const materializedViewSchemas = {
btc_trades_mv:
"CREATE MATERIALIZED VIEW IF NOT EXISTS btc_trades_mv WITH BASE btc_trades as (" +
"SELECT timestamp, avg(amount) avg FROM btc_trades SAMPLE BY 1m) PARTITION BY week;",
btc_trades_mv_on_mv:
"CREATE MATERIALIZED VIEW IF NOT EXISTS btc_trades_mv_on_mv as (" +
"SELECT timestamp, avg(avg) avg FROM btc_trades_mv SAMPLE BY 1h) PARTITION BY week;",
}

const viewSchemas = {
Expand Down
2 changes: 1 addition & 1 deletion e2e/questdb
Submodule questdb updated 1098 files
8 changes: 8 additions & 0 deletions e2e/tests/console/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ describe("appendQuery", () => {
cy.getEditorContent().should("have.value", expected)
cy.getSelectedLines().should("have.length", 1)
})

it("should inject a semicolon when the existing query is unterminated", () => {
cy.typeQuery(`select 1`)
cy.selectQuery(0)
const expected = `select 1;\n${queries[0]}`
cy.getEditorContent().should("have.value", expected)
cy.getSelectedLines().should("have.length", 1)
})
})

describe("&query URL param", () => {
Expand Down
96 changes: 96 additions & 0 deletions e2e/tests/console/schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,99 @@ describe("materialized views", () => {
})
})
})

describe("create materialized view from context menu", () => {
const sourceTable = "btc_trades"
const nonWalTable = "btc_trades_no_wal"
const nonPartitionedTable = "my_publics"
// btc_trades is PARTITION BY DAY → derived SAMPLE BY 1h → view name btc_trades_1h.
const generatedMatView = "btc_trades_1h"

before(() => {
cy.loadConsoleWithAuth()
cy.createTable(sourceTable)
cy.createTable(nonWalTable)
cy.createTable(nonPartitionedTable)
cy.refreshSchema()
})

after(() => {
cy.loadConsoleWithAuth()
cy.dropMaterializedView(generatedMatView)
cy.dropTableIfExists(sourceTable)
cy.dropTableIfExists(nonWalTable)
cy.dropTableIfExists(nonPartitionedTable)
})

it("disables the menu item for non-WAL and non-partitioned tables, and generates a runnable matview DDL from a valid source", () => {
cy.getByDataHook("schema-table-title").contains(nonWalTable).rightclick()
cy.getByDataHook("table-context-menu-create-matview").should(
"have.attr",
"data-disabled",
)
cy.realPress("Escape")

cy.getByDataHook("schema-table-title")
.contains(nonPartitionedTable)
.rightclick()
cy.getByDataHook("table-context-menu-create-matview").should(
"have.attr",
"data-disabled",
)
cy.realPress("Escape")

cy.clearEditor()
cy.getByDataHook("schema-table-title").contains(sourceTable).rightclick()
cy.getByDataHook("table-context-menu-create-matview")
.should("not.be.disabled")
.click()

cy.getEditorContent().should("contain.value", "CREATE MATERIALIZED VIEW")
cy.runLine().clearEditor()

cy.refreshSchema()
cy.expandMatViews()
cy.getByDataHook("schema-matview-title").should("contain", generatedMatView)
})
})

describe("create materialized view from matview context menu", () => {
const sourceTable = "btc_trades"
const sourceMatView = "btc_trades_mv"
// btc_trades_mv is SAMPLE BY 1m → next rung 5m; name has no period token,
// so the generator appends `_5m`.
const generatedMatView = "btc_trades_mv_5m"

before(() => {
cy.loadConsoleWithAuth()
cy.createTable(sourceTable)
cy.createMaterializedView(sourceMatView)
cy.refreshSchema()
})

after(() => {
cy.loadConsoleWithAuth()
cy.dropMaterializedView(generatedMatView)
cy.dropMaterializedView(sourceMatView)
cy.dropTableIfExists(sourceTable)
})

it("generates a runnable chained matview DDL from a matview source", () => {
cy.expandMatViews()

cy.clearEditor()
cy.getByDataHook("schema-matview-title")
.contains(sourceMatView)
.rightclick()
cy.getByDataHook("table-context-menu-create-matview")
.should("not.be.disabled")
.click()

cy.getEditorContent().should("contain.value", "CREATE MATERIALIZED VIEW")
cy.runLine().clearEditor()

cy.refreshSchema()
cy.expandMatViews()
cy.getByDataHook("schema-matview-title").should("contain", generatedMatView)
})
})
48 changes: 48 additions & 0 deletions e2e/tests/console/tableDetails.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
const TEST_TABLE = "btc_trades"
const TEST_TABLE_NO_WAL = "btc_trades_no_wal"
const TEST_MATVIEW = "btc_trades_mv"
const TEST_MATVIEW_ON_MV = "btc_trades_mv_on_mv"
const TEST_VIEW = "btc_trades_view"

function interceptTablesQuery(modifications) {
Expand Down Expand Up @@ -637,6 +638,53 @@ describe("TableDetailsDrawer", () => {
})
})

describe("materialized view based on another materialized view", () => {
before(() => {
cy.loadConsoleWithAuth()
cy.createTable(TEST_TABLE)
cy.createMaterializedView(TEST_MATVIEW)
cy.createMaterializedView(TEST_MATVIEW_ON_MV)
})

beforeEach(() => {
cy.loadConsoleWithAuth()
cy.refreshSchema()
cy.expandMatViews()
})

it("should open as matview and navigate to a matview base table preserving the matview kind", () => {
cy.openDetailsDrawer(TEST_MATVIEW_ON_MV, "matview")

cy.getByDataHook("table-details-type-badge").should(
"contain",
"Materialized View",
)

cy.getByDataHook("table-details-tab-details").click()

cy.getByDataHook("table-details-base-table-section").should("be.visible")
cy.getByDataHook("table-details-base-table-link").should(
"contain",
TEST_MATVIEW,
)

cy.getByDataHook("table-details-base-table-link").click()

cy.getByDataHook("table-details-name").should("have.value", TEST_MATVIEW)
cy.getByDataHook("table-details-type-badge").should(
"contain",
"Materialized View",
)
})

after(() => {
cy.loadConsoleWithAuth()
cy.dropMaterializedView(TEST_MATVIEW_ON_MV)
cy.dropMaterializedView(TEST_MATVIEW)
cy.dropTable(TEST_TABLE)
})
})

describe("materialized view invalid state (R2)", () => {
before(() => {
cy.loadConsoleWithAuth()
Expand Down
1 change: 1 addition & 0 deletions src/modules/ConsoleEventTracker/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export enum ConsoleEvent {
SCHEMA_RESUME_WAL_SUBMIT = "schema.resume_wal_submit",
SCHEMA_CONTEXT_COPY_DDL = "schema.context_copy_ddl",
SCHEMA_CONTEXT_EXPLAIN = "schema.context_explain",
SCHEMA_CONTEXT_CREATE_MATVIEW = "schema.context_create_matview",
SCHEMA_COPY_MULTIPLE = "schema.copy_multiple",

TABLE_DETAILS_TAB_SWITCH = "table_details.tab_switch",
Expand Down
1 change: 0 additions & 1 deletion src/modules/OAuth2/views/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { RawDqlResult } from "utils/questdb/types"
import { LoadingSpinner } from "../../../components/LoadingSpinner"
import { Box } from "../../../components/Box"


const LoginContainer = styled.div`
width: 100%;
height: 100%;
Expand Down
7 changes: 3 additions & 4 deletions src/providers/EditorProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import React, {
} from "react"
import {
appendQuery,
AppendQueryOptions,
clearModelMarkers,
insertTextAtCursor,
QuestDBLanguageName,
Expand Down Expand Up @@ -76,7 +75,7 @@ export type EditorContext = {
editorRef: MutableRefObject<IStandaloneCodeEditor | null>
monacoRef: MutableRefObject<Monaco | null>
insertTextAtCursor: (text: string) => void
appendQuery: (query: string, options?: AppendQueryOptions) => void
appendQuery: (query: string) => void
tabsDisabled: boolean
setTabsDisabled: (disabled: boolean) => void
buffers: Buffer[]
Expand Down Expand Up @@ -726,9 +725,9 @@ export const EditorProvider: React.FC = ({ children }) => {
insertTextAtCursor(editorRef.current, text)
}
},
appendQuery: (text, options) => {
appendQuery: (text) => {
if (editorRef?.current) {
appendQuery(editorRef.current, text, options)
appendQuery(editorRef.current, text)
}
},
tabsDisabled,
Expand Down
1 change: 0 additions & 1 deletion src/scenes/Console/import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const Import = () => (
eventBus.publish(EventType.MSG_QUERY_SCHEMA)
eventBus.publish(EventType.MSG_QUERY_FIND_N_EXEC, {
query: `"${result.location}"`,
options: { appendAt: "end" },
})
}
}}
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/Editor/Monaco/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ const MonacoEditor = ({ hidden = false }: { hidden?: boolean }) => {
})
// otherwise, append the query
} else {
appendQuery(editor, trimmedQuery, { appendAt: "end" })
appendQuery(editor, trimmedQuery)
const newValue = editor.getValue()
void updateBuffer(activeBuffer.id as number, { value: newValue })
}
Expand Down
6 changes: 3 additions & 3 deletions src/scenes/Editor/Monaco/legacy-event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* limitations under the License.
*
******************************************************************************/
import { appendQuery, AppendQueryOptions } from "./utils"
import { appendQuery } from "./utils"
import { eventBus } from "../../../modules/EventBus"
import { EventType } from "../../../modules/EventBus/types"
import type { editor } from "monaco-editor"
Expand All @@ -34,12 +34,12 @@ export const registerLegacyEventBusEvents = ({
editor: editor.IStandaloneCodeEditor
toggleRunning: (runningType?: RunningType) => void
}) => {
eventBus.subscribe<{ query: string; options?: AppendQueryOptions }>(
eventBus.subscribe<{ query: string }>(
EventType.MSG_QUERY_FIND_N_EXEC,
(payload) => {
if (payload) {
const text = `${payload.query};`
appendQuery(editor, text, payload.options)
appendQuery(editor, text)
toggleRunning()
}
},
Expand Down
Loading
Loading